# ianloe/ai-office architecture

> Architecture diagram of the GitHub repository ianloe/ai-office, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ianloe/ai-office
- Repository: https://github.com/ianloe/ai-office

## Overview

TS-Office is a multi-agent AI back office. An office manager or incoming enquiry initiates work; the Orchestrator routes tasks through the Redis Streams runtime to specialist agents, which prepare business outputs and, where needed, request human approval before external actions through the MCP gateway. The distinct stages include enquiry handling, scheduling, CRM, finance, proposals, training operations, content, research, governance, and knowledge administration. Shared runtime services provide LLM access, budgets, quarantine, and audit. README statements describe several capabilities not verifiable in sampled agent implementations, so those branches are represented without speculative internal links.

Main entry points: [`libs/ts_agent_core/base_agent.py`](https://github.com/ianloe/ai-office/blob/main/libs/ts_agent_core/base_agent.py) (Agent execution), [`services/mcp_gateway/app.py`](https://github.com/ianloe/ai-office/blob/main/services/mcp_gateway/app.py) (MCP tool gateway), [`services/approval_gateway/app.py`](https://github.com/ianloe/ai-office/blob/main/services/approval_gateway/app.py) (Approval gateway), [`libs/ts_agent_core/audit.py`](https://github.com/ianloe/ai-office/blob/main/libs/ts_agent_core/audit.py) (Immutable audit log)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_business["Business agents"]
  node_enquiry["Enquiry handling<br/>[agent.py]"]
  node_orchestrator["Task orchestration<br/>[agent.py]"]
  node_scheduler["Scheduling<br/>[agent.py]"]
  node_crm["CRM management<br/>[agent.py]"]
  node_finance["Finance operations<br/>[agent.py]"]
  node_proposals["Proposals and contracts<br/>[agent.py]"]
  node_training["Training operations<br/>[agent.py]"]
  node_content["Content marketing<br/>[agent.py]"]
  node_research["Research intelligence<br/>[agent.py]"]
  node_governance["Governance audit<br/>[agent.py]"]
  node_knowledge["Knowledge administration<br/>[agent.py]"]
end

subgraph group_runtime["Agent runtime"]
  node_runner["Agent worker<br/>[runner.py]"]
  node_base["Agent execution<br/>[base_agent.py]"]
  node_bus["Signed task bus<br/>[bus.py]"]
  node_llm["LLM client<br/>[llm.py]"]
  node_config["Agent configuration<br/>[config.py]"]
  node_budgets["Budget controls<br/>[budgets.py]"]
  node_quarantine["Input quarantine<br/>[quarantine.py]"]
  node_models["Shared task models<br/>[models.py]"]
  node_logging["Structured logging<br/>[logging.py]"]
  node_hardening["HTTP hardening<br/>[http_hardening.py]"]
end

subgraph group_gateways["Human and tool gateways"]
  node_mcp["MCP tool gateway<br/>[app.py]"]
  node_connectors["External connectors<br/>[connectors.py]"]
  node_email["Email integration<br/>[email_imap_smtp.py]"]
  node_tokens["Action tokens<br/>[tokens.py]"]
  node_approval["Approval gateway<br/>[app.py]"]
  node_dashboard["Dashboard admin<br/>[admin.py]"]
end

subgraph group_oversight["Governance and records"]
  node_audit[("Immutable audit log<br/>[audit.py]")]
end

node_office(("Office manager"))

node_office -.->|"submits enquiry"| node_enquiry
node_office -.->|"assigns work"| node_orchestrator
node_orchestrator -->|"routes tasks"| node_bus
node_runner -->|"consumes tasks"| node_bus
node_runner -->|"runs agent"| node_base
node_enquiry -->|"extends runtime"| node_base
node_scheduler -->|"extends runtime"| node_base
node_crm -->|"extends runtime"| node_base
node_finance -->|"extends runtime"| node_base
node_proposals -->|"extends runtime"| node_base
node_training -->|"extends runtime"| node_base
node_content -->|"extends runtime"| node_base
node_research -->|"extends runtime"| node_base
node_governance -->|"extends runtime"| node_base
node_knowledge -->|"extends runtime"| node_base
node_base -->|"requests completion"| node_llm
node_base -->|"calls tools"| node_mcp
node_base -->|"requests approval"| node_approval
node_base -->|"records events"| node_audit
node_base -->|"checks limits"| node_budgets
node_base -->|"uses task models"| node_models
node_enquiry -->|"sanitizes input"| node_quarantine
node_research -->|"sanitizes input"| node_quarantine
node_mcp -->|"validates tokens"| node_tokens
node_mcp -->|"dispatches tools"| node_connectors
node_mcp -->|"dispatches email"| node_email
node_approval -->|"issues action tokens"| node_tokens
node_office -->|"reviews work"| node_dashboard
node_dashboard -.->|"submits decisions"| node_approval
node_approval -->|"records decisions"| node_audit
node_governance -.->|"reviews chain"| node_audit
node_dashboard -->|"records controls"| node_audit

click node_enquiry "https://github.com/ianloe/ai-office/blob/main/agents/enquiry/agent.py"
click node_orchestrator "https://github.com/ianloe/ai-office/blob/main/agents/orchestrator/agent.py"
click node_scheduler "https://github.com/ianloe/ai-office/blob/main/agents/scheduler/agent.py"
click node_crm "https://github.com/ianloe/ai-office/blob/main/agents/crm/agent.py"
click node_finance "https://github.com/ianloe/ai-office/blob/main/agents/finance/agent.py"
click node_proposals "https://github.com/ianloe/ai-office/blob/main/agents/proposals/agent.py"
click node_training "https://github.com/ianloe/ai-office/blob/main/agents/training_ops/agent.py"
click node_content "https://github.com/ianloe/ai-office/blob/main/agents/content/agent.py"
click node_research "https://github.com/ianloe/ai-office/blob/main/agents/research/agent.py"
click node_governance "https://github.com/ianloe/ai-office/blob/main/agents/governance/agent.py"
click node_knowledge "https://github.com/ianloe/ai-office/blob/main/agents/knowledge/agent.py"
click node_runner "https://github.com/ianloe/ai-office/blob/main/agents/runner.py"
click node_base "https://github.com/ianloe/ai-office/blob/main/libs/ts_agent_core/base_agent.py"
click node_bus "https://github.com/ianloe/ai-office/blob/main/libs/ts_agent_core/bus.py"
click node_llm "https://github.com/ianloe/ai-office/blob/main/libs/ts_agent_core/llm.py"
click node_config "https://github.com/ianloe/ai-office/blob/main/libs/ts_agent_core/config.py"
click node_budgets "https://github.com/ianloe/ai-office/blob/main/libs/ts_agent_core/budgets.py"
click node_quarantine "https://github.com/ianloe/ai-office/blob/main/libs/ts_agent_core/quarantine.py"
click node_models "https://github.com/ianloe/ai-office/blob/main/libs/ts_agent_core/models.py"
click node_logging "https://github.com/ianloe/ai-office/blob/main/libs/ts_agent_core/logging.py"
click node_mcp "https://github.com/ianloe/ai-office/blob/main/services/mcp_gateway/app.py"
click node_connectors "https://github.com/ianloe/ai-office/blob/main/services/mcp_gateway/connectors.py"
click node_email "https://github.com/ianloe/ai-office/blob/main/services/mcp_gateway/email_imap_smtp.py"
click node_tokens "https://github.com/ianloe/ai-office/blob/main/services/mcp_gateway/tokens.py"
click node_approval "https://github.com/ianloe/ai-office/blob/main/services/approval_gateway/app.py"
click node_dashboard "https://github.com/ianloe/ai-office/blob/main/services/dashboard/admin.py"
click node_audit "https://github.com/ianloe/ai-office/blob/main/libs/ts_agent_core/audit.py"
click node_hardening "https://github.com/ianloe/ai-office/blob/main/libs/ts_agent_core/http_hardening.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_enquiry,node_orchestrator,node_scheduler,node_crm,node_finance,node_proposals,node_training,node_content,node_research,node_governance,node_knowledge toneBlue
class node_runner,node_base,node_bus,node_llm,node_config,node_budgets,node_quarantine,node_models,node_logging,node_hardening toneAmber
class node_mcp,node_connectors,node_email,node_tokens,node_approval,node_dashboard toneMint
class node_audit toneRose
class node_office toneIndigo
```

## Components

### Business agents

- [Enquiry handling](https://github.com/ianloe/ai-office/blob/main/agents/enquiry/agent.py): `agents/enquiry/agent.py`
- [Task orchestration](https://github.com/ianloe/ai-office/blob/main/agents/orchestrator/agent.py): `agents/orchestrator/agent.py`
- [Scheduling](https://github.com/ianloe/ai-office/blob/main/agents/scheduler/agent.py): `agents/scheduler/agent.py`
- [CRM management](https://github.com/ianloe/ai-office/blob/main/agents/crm/agent.py): `agents/crm/agent.py`
- [Finance operations](https://github.com/ianloe/ai-office/blob/main/agents/finance/agent.py): `agents/finance/agent.py`
- [Proposals and contracts](https://github.com/ianloe/ai-office/blob/main/agents/proposals/agent.py): `agents/proposals/agent.py`
- [Training operations](https://github.com/ianloe/ai-office/blob/main/agents/training_ops/agent.py): `agents/training_ops/agent.py`
- [Content marketing](https://github.com/ianloe/ai-office/blob/main/agents/content/agent.py): `agents/content/agent.py`
- [Research intelligence](https://github.com/ianloe/ai-office/blob/main/agents/research/agent.py): `agents/research/agent.py`
- [Governance audit](https://github.com/ianloe/ai-office/blob/main/agents/governance/agent.py): `agents/governance/agent.py`
- [Knowledge administration](https://github.com/ianloe/ai-office/blob/main/agents/knowledge/agent.py): `agents/knowledge/agent.py`

### Agent runtime

- [Agent worker](https://github.com/ianloe/ai-office/blob/main/agents/runner.py): `agents/runner.py`
- [Agent execution](https://github.com/ianloe/ai-office/blob/main/libs/ts_agent_core/base_agent.py): `libs/ts_agent_core/base_agent.py`
- [Signed task bus](https://github.com/ianloe/ai-office/blob/main/libs/ts_agent_core/bus.py): `libs/ts_agent_core/bus.py`
- [LLM client](https://github.com/ianloe/ai-office/blob/main/libs/ts_agent_core/llm.py): `libs/ts_agent_core/llm.py`
- [Agent configuration](https://github.com/ianloe/ai-office/blob/main/libs/ts_agent_core/config.py): `libs/ts_agent_core/config.py`
- [Budget controls](https://github.com/ianloe/ai-office/blob/main/libs/ts_agent_core/budgets.py): `libs/ts_agent_core/budgets.py`
- [Input quarantine](https://github.com/ianloe/ai-office/blob/main/libs/ts_agent_core/quarantine.py): `libs/ts_agent_core/quarantine.py`
- [Shared task models](https://github.com/ianloe/ai-office/blob/main/libs/ts_agent_core/models.py): `libs/ts_agent_core/models.py`
- [Structured logging](https://github.com/ianloe/ai-office/blob/main/libs/ts_agent_core/logging.py): `libs/ts_agent_core/logging.py`
- [HTTP hardening](https://github.com/ianloe/ai-office/blob/main/libs/ts_agent_core/http_hardening.py): `libs/ts_agent_core/http_hardening.py`

### Human and tool gateways

- [MCP tool gateway](https://github.com/ianloe/ai-office/blob/main/services/mcp_gateway/app.py): `services/mcp_gateway/app.py`
- [External connectors](https://github.com/ianloe/ai-office/blob/main/services/mcp_gateway/connectors.py): `services/mcp_gateway/connectors.py`
- [Email integration](https://github.com/ianloe/ai-office/blob/main/services/mcp_gateway/email_imap_smtp.py): `services/mcp_gateway/email_imap_smtp.py`
- [Action tokens](https://github.com/ianloe/ai-office/blob/main/services/mcp_gateway/tokens.py): `services/mcp_gateway/tokens.py`
- [Approval gateway](https://github.com/ianloe/ai-office/blob/main/services/approval_gateway/app.py): `services/approval_gateway/app.py`
- [Dashboard admin](https://github.com/ianloe/ai-office/blob/main/services/dashboard/admin.py): `services/dashboard/admin.py`

### Governance and records

- [Immutable audit log](https://github.com/ianloe/ai-office/blob/main/libs/ts_agent_core/audit.py): `libs/ts_agent_core/audit.py`

### Other components

- **Office manager**

## Connections

- Office manager → Enquiry handling: submits enquiry (evidence: `README.md`)
- Office manager → Task orchestration: assigns work (evidence: `README.md`)
- Task orchestration → Signed task bus: routes tasks (evidence: `agents/orchestrator/main.py`)
- Agent worker → Signed task bus: consumes tasks (evidence: `agents/runner.py`)
- Agent worker → Agent execution: runs agent (evidence: `agents/runner.py`)
- Enquiry handling → Agent execution: extends runtime (evidence: `agents/enquiry/agent.py`)
- Scheduling → Agent execution: extends runtime (evidence: `agents/scheduler/agent.py`)
- CRM management → Agent execution: extends runtime (evidence: `agents/crm/agent.py`)
- Finance operations → Agent execution: extends runtime (evidence: `agents/finance/agent.py`)
- Proposals and contracts → Agent execution: extends runtime (evidence: `agents/proposals/agent.py`)
- Training operations → Agent execution: extends runtime (evidence: `agents/training_ops/agent.py`)
- Content marketing → Agent execution: extends runtime
- Research intelligence → Agent execution: extends runtime (evidence: `agents/research/agent.py`)
- Governance audit → Agent execution: extends runtime (evidence: `agents/governance/agent.py`)
- Knowledge administration → Agent execution: extends runtime (evidence: `agents/knowledge/agent.py`)
- Agent execution → LLM client: requests completion (evidence: `libs/ts_agent_core/base_agent.py`)
- Agent execution → MCP tool gateway: calls tools (evidence: `libs/ts_agent_core/base_agent.py`)
- Agent execution → Approval gateway: requests approval (evidence: `libs/ts_agent_core/base_agent.py`)
- Agent execution → Immutable audit log: records events (evidence: `libs/ts_agent_core/base_agent.py`)
- Agent execution → Budget controls: checks limits (evidence: `libs/ts_agent_core/base_agent.py`)
- Agent execution → Shared task models: uses task models (evidence: `libs/ts_agent_core/base_agent.py`)
- Enquiry handling → Input quarantine: sanitizes input (evidence: `agents/enquiry/agent.py`)
- Research intelligence → Input quarantine: sanitizes input (evidence: `agents/research/agent.py`)
- MCP tool gateway → Action tokens: validates tokens (evidence: `services/mcp_gateway/app.py`)
- MCP tool gateway → External connectors: dispatches tools (evidence: `services/mcp_gateway/app.py`)
- MCP tool gateway → Email integration: dispatches email (evidence: `services/mcp_gateway/app.py`)
- Approval gateway → Action tokens: issues action tokens (evidence: `services/approval_gateway/app.py`)
- Office manager → Dashboard admin: reviews work (evidence: `README.md`)
- Dashboard admin → Approval gateway: submits decisions (evidence: `README.md`)
- Approval gateway → Immutable audit log: records decisions (evidence: `services/approval_gateway/app.py`)
- Governance audit → Immutable audit log: reviews chain (evidence: `README.md`)
- Dashboard admin → Immutable audit log: records controls (evidence: `services/dashboard/app.py`)
