# carlobeschi/agents-wrapper architecture

> Architecture diagram of the GitHub repository carlobeschi/agents-wrapper, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/carlobeschi/agents-wrapper
- Repository: https://github.com/carlobeschi/agents-wrapper

## Overview

agents-wrapper is a local Node application for orchestrating headless coding agents, with a browser UI for conversations and related scenarios. The main user workflow is browser request → server routing → configured agent execution → streamed/persisted transcript, with attachments available to prompts. The repository also contains separate collaboration, debate, puzzle, publishing, and research-runner tools. The supplied README documents conversation, review, puzzle, and story behavior; source excerpts are partial, so edges below are limited to documented or indexed references.

Main entry points: [`server.js`](https://github.com/carlobeschi/agents-wrapper/blob/main/server.js) (HTTP server), [`runner/run.js`](https://github.com/carlobeschi/agents-wrapper/blob/main/runner/run.js) (Study orchestration), [`talk.js`](https://github.com/carlobeschi/agents-wrapper/blob/main/talk.js) (Conversation engine), [`story.js`](https://github.com/carlobeschi/agents-wrapper/blob/main/story.js) (Story engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Local app"]
  node_browser["Browser UI"]
  node_server["HTTP server<br/>[server.js]"]
  node_config["Agent config<br/>[config.js]"]
  node_attach["File attachments<br/>[attach.js]"]
  node_process["Agent process<br/>[agent-process.js]"]
end

subgraph group_scenarios["Agent scenarios"]
  node_talk["Conversation engine<br/>[talk.js]"]
  node_story["Story engine<br/>[story.js]"]
  node_puzzles["Puzzle scenarios<br/>[puzzles.js]"]
  node_room["Shared artefact room<br/>[room.js]"]
  node_motion["Motion debate<br/>[motion.js]"]
  node_openrouter["OpenRouter agent<br/>[openrouter.js]"]
  node_publish["Publishing<br/>[publish.js]"]
end

subgraph group_research["Research runner"]
  node_runstudy["Study definition<br/>[study.js]"]
  node_session["Study session<br/>[session.js]"]
  node_providers["Model providers<br/>[providers.js]"]
  node_budget["Cost ledger<br/>[budget.js]"]
  node_events[("Event log<br/>[events.js]")]
  node_run["Study orchestration<br/>[run.js]"]
end

subgraph group_experiments["Other tools"]
  node_wrongnote["Wrong-note tool<br/>[wrongnote.js]"]
  node_studycore["Study 15 engine<br/>[core.py]"]
end

node_person(("User"))

node_person -->|"uses"| node_browser
node_browser -->|"sends requests"| node_server
node_server -->|"routes to"| node_talk
node_server -->|"routes to"| node_story
node_server -->|"handles uploads"| node_attach
node_server -->|"loads settings"| node_config
node_talk -->|"loads agents"| node_config
node_talk -->|"saves files"| node_attach
node_talk -->|"runs agent"| node_process
node_story -->|"loads agents"| node_config
node_story -->|"uses files"| node_attach
node_story -->|"runs agent"| node_process
node_motion -->|"loads settings"| node_config
node_motion -->|"runs agent"| node_process
node_motion -->|"publishes episode"| node_publish
node_run -->|"validates study"| node_runstudy
node_run -->|"runs sessions"| node_session
node_run -->|"tracks cost"| node_budget
node_run -->|"records events"| node_events
node_session -->|"requests models"| node_providers
node_session -->|"uses ledger"| node_budget
node_session -->|"records session"| node_events
node_budget -->|"records charges"| node_events
node_providers -.->|"optional provider"| node_openrouter

click node_server "https://github.com/carlobeschi/agents-wrapper/blob/main/server.js"
click node_config "https://github.com/carlobeschi/agents-wrapper/blob/main/config.js"
click node_attach "https://github.com/carlobeschi/agents-wrapper/blob/main/attach.js"
click node_process "https://github.com/carlobeschi/agents-wrapper/blob/main/agent-process.js"
click node_talk "https://github.com/carlobeschi/agents-wrapper/blob/main/talk.js"
click node_story "https://github.com/carlobeschi/agents-wrapper/blob/main/story.js"
click node_puzzles "https://github.com/carlobeschi/agents-wrapper/blob/main/puzzles.js"
click node_room "https://github.com/carlobeschi/agents-wrapper/blob/main/room.js"
click node_motion "https://github.com/carlobeschi/agents-wrapper/blob/main/motion.js"
click node_openrouter "https://github.com/carlobeschi/agents-wrapper/blob/main/openrouter.js"
click node_publish "https://github.com/carlobeschi/agents-wrapper/blob/main/publish.js"
click node_runstudy "https://github.com/carlobeschi/agents-wrapper/blob/main/runner/study.js"
click node_session "https://github.com/carlobeschi/agents-wrapper/blob/main/runner/session.js"
click node_providers "https://github.com/carlobeschi/agents-wrapper/blob/main/runner/providers.js"
click node_budget "https://github.com/carlobeschi/agents-wrapper/blob/main/runner/budget.js"
click node_events "https://github.com/carlobeschi/agents-wrapper/blob/main/runner/events.js"
click node_run "https://github.com/carlobeschi/agents-wrapper/blob/main/runner/run.js"
click node_wrongnote "https://github.com/carlobeschi/agents-wrapper/blob/main/wrongnote.js"
click node_studycore "https://github.com/carlobeschi/agents-wrapper/blob/main/study15/core.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_browser,node_server,node_config,node_attach,node_process,node_person toneBlue
class node_talk,node_story,node_puzzles,node_room,node_motion,node_openrouter,node_publish toneAmber
class node_runstudy,node_session,node_providers,node_budget,node_events,node_run toneMint
class node_wrongnote,node_studycore toneRose
```

## Components

### Local app

- **Browser UI**
- [HTTP server](https://github.com/carlobeschi/agents-wrapper/blob/main/server.js): `server.js`
- [Agent config](https://github.com/carlobeschi/agents-wrapper/blob/main/config.js): `config.js`
- [File attachments](https://github.com/carlobeschi/agents-wrapper/blob/main/attach.js): `attach.js`
- [Agent process](https://github.com/carlobeschi/agents-wrapper/blob/main/agent-process.js): `agent-process.js`

### Agent scenarios

- [Conversation engine](https://github.com/carlobeschi/agents-wrapper/blob/main/talk.js): `talk.js`
- [Story engine](https://github.com/carlobeschi/agents-wrapper/blob/main/story.js): `story.js`
- [Puzzle scenarios](https://github.com/carlobeschi/agents-wrapper/blob/main/puzzles.js): `puzzles.js`
- [Shared artefact room](https://github.com/carlobeschi/agents-wrapper/blob/main/room.js): `room.js`
- [Motion debate](https://github.com/carlobeschi/agents-wrapper/blob/main/motion.js): `motion.js`
- [OpenRouter agent](https://github.com/carlobeschi/agents-wrapper/blob/main/openrouter.js): `openrouter.js`
- [Publishing](https://github.com/carlobeschi/agents-wrapper/blob/main/publish.js): `publish.js`

### Research runner

- [Study definition](https://github.com/carlobeschi/agents-wrapper/blob/main/runner/study.js): `runner/study.js`
- [Study session](https://github.com/carlobeschi/agents-wrapper/blob/main/runner/session.js): `runner/session.js`
- [Model providers](https://github.com/carlobeschi/agents-wrapper/blob/main/runner/providers.js): `runner/providers.js`
- [Cost ledger](https://github.com/carlobeschi/agents-wrapper/blob/main/runner/budget.js): `runner/budget.js`
- [Event log](https://github.com/carlobeschi/agents-wrapper/blob/main/runner/events.js): `runner/events.js`
- [Study orchestration](https://github.com/carlobeschi/agents-wrapper/blob/main/runner/run.js): `runner/run.js`

### Other tools

- [Wrong-note tool](https://github.com/carlobeschi/agents-wrapper/blob/main/wrongnote.js): `wrongnote.js`
- [Study 15 engine](https://github.com/carlobeschi/agents-wrapper/blob/main/study15/core.py): `study15/core.py`

### Other components

- **User**

## Connections

- User → Browser UI: uses
- Browser UI → HTTP server: sends requests
- HTTP server → Conversation engine: routes to (evidence: `server.js`)
- HTTP server → Story engine: routes to (evidence: `server.js`)
- HTTP server → File attachments: handles uploads (evidence: `server.js`)
- HTTP server → Agent config: loads settings (evidence: `server.js`)
- Conversation engine → Agent config: loads agents (evidence: `talk.js`)
- Conversation engine → File attachments: saves files (evidence: `talk.js`)
- Conversation engine → Agent process: runs agent (evidence: `talk.js`)
- Story engine → Agent config: loads agents (evidence: `story.js`)
- Story engine → File attachments: uses files (evidence: `story.js`)
- Story engine → Agent process: runs agent (evidence: `story.js`)
- Motion debate → Agent config: loads settings (evidence: `motion.js`)
- Motion debate → Agent process: runs agent (evidence: `motion.js`)
- Motion debate → Publishing: publishes episode (evidence: `motion.js`)
- Study orchestration → Study definition: validates study (evidence: `runner/run.js`)
- Study orchestration → Study session: runs sessions (evidence: `runner/run.js`)
- Study orchestration → Cost ledger: tracks cost (evidence: `runner/run.js`)
- Study orchestration → Event log: records events (evidence: `runner/run.js`)
- Study session → Model providers: requests models (evidence: `runner/session.js`)
- Study session → Cost ledger: uses ledger (evidence: `runner/session.js`)
- Study session → Event log: records session (evidence: `runner/session.js`)
- Cost ledger → Event log: records charges (evidence: `runner/budget.js`)
- Model providers → OpenRouter agent: optional provider
