# ozyrionhaha/agentscope architecture

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

- Interactive diagram: https://gitdiagram.com/ozyrionhaha/agentscope
- Repository: https://github.com/ozyrionhaha/agentscope

## Overview

AgentScope is a local-first agent workspace that connects user-selected models to project tools, skills, and workflows. The primary flow is a user prompt through the workspace UI and local API into the agent runtime, which gathers project context, calls a provider, and may dispatch permission-controlled tools; events and results return to the UI. The graph also preserves provider and vault management, indexing, memory, terminal, browser, MCP, and persistent state. Some feature links are documented in the README; unsampled implementation details are not inferred beyond those references.

Main entry points: [`server/tools.ts`](https://github.com/ozyrionhaha/agentscope/blob/main/server/tools.ts) (Tool Registry), [`server/runtime.ts`](https://github.com/ozyrionhaha/agentscope/blob/main/server/runtime.ts) (Agent Runtime), [`server/storage.ts`](https://github.com/ozyrionhaha/agentscope/blob/main/server/storage.ts) (SQLite Store), [`server/app.ts`](https://github.com/ozyrionhaha/agentscope/blob/main/server/app.ts) (Local API Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Workspace UI"]
  node_ui["Workspace UI<br/>[WorkspacePage.tsx]"]
  node_appui["App Navigation<br/>[App.tsx]"]
  node_api["API Client<br/>[api.ts]"]
  node_usage["Usage Tracking<br/>[UsagePage.tsx]"]
end

subgraph group_agent["Agent Runtime"]
  node_server["Local API Server<br/>[app.ts]"]
  node_runtime["Agent Runtime<br/>[runtime.ts]"]
  node_tools["Tool Registry<br/>[tools.ts]"]
  node_permissions["Permissions<br/>[permissions.ts]"]
end

subgraph group_project["Project Capabilities"]
  node_context["Project Context<br/>[context.ts]"]
  node_workspace["Workspace Files<br/>[workspace.ts]"]
  node_terminal["Terminal Sessions<br/>[terminal.ts]"]
  node_skills["Skills &amp; Plugins<br/>[skills.ts]"]
  node_workflow["Workflows<br/>[app.ts]"]
end

subgraph group_integrations["Models &amp; Integrations"]
  node_providers["Model Providers<br/>[providers.ts]"]
  node_browser["Browser Automation<br/>[browser.ts]"]
  node_mcp["MCP Servers<br/>[mcp.ts]"]
end

subgraph group_state["Local State"]
  node_vault["Credential Vault<br/>[vault.ts]"]
  node_store[("SQLite Store<br/>[storage.ts]")]
end

node_user(("User"))

node_user -->|"prompts"| node_ui
node_appui -->|"requests"| node_api
node_ui -->|"requests"| node_api
node_api -->|"calls API"| node_server
node_server -->|"dispatches tasks"| node_runtime
node_runtime -->|"calls model"| node_providers
node_runtime -->|"builds context"| node_context
node_runtime -->|"dispatches tools"| node_tools
node_tools -->|"checks access"| node_permissions
node_tools -->|"edits files"| node_workspace
node_tools -->|"runs commands"| node_terminal
node_tools -->|"loads skills"| node_skills
node_tools -->|"automates pages"| node_browser
node_tools -->|"calls MCP"| node_mcp
node_context -->|"indexes files"| node_workspace
node_context -->|"persists index"| node_store
node_workspace -->|"saves checkpoints"| node_store
node_terminal -->|"saves sessions"| node_store
node_runtime -->|"records events"| node_store
node_providers -->|"reads credentials"| node_vault
node_vault -->|"stores encrypted data"| node_store
node_server -->|"initializes state"| node_store
node_ui -->|"streams task events"| node_server
node_usage -->|"loads usage"| node_api
node_user -->|"selects workflow"| node_workflow
node_runtime -.->|"executes workflows"| node_workflow
node_user -.->|"enables browser"| node_browser

click node_ui "https://github.com/ozyrionhaha/agentscope/blob/main/src/WorkspacePage.tsx"
click node_appui "https://github.com/ozyrionhaha/agentscope/blob/main/src/App.tsx"
click node_api "https://github.com/ozyrionhaha/agentscope/blob/main/src/api.ts"
click node_server "https://github.com/ozyrionhaha/agentscope/blob/main/server/app.ts"
click node_runtime "https://github.com/ozyrionhaha/agentscope/blob/main/server/runtime.ts"
click node_tools "https://github.com/ozyrionhaha/agentscope/blob/main/server/tools.ts"
click node_permissions "https://github.com/ozyrionhaha/agentscope/blob/main/server/permissions.ts"
click node_context "https://github.com/ozyrionhaha/agentscope/blob/main/server/context.ts"
click node_workspace "https://github.com/ozyrionhaha/agentscope/blob/main/server/workspace.ts"
click node_terminal "https://github.com/ozyrionhaha/agentscope/blob/main/server/terminal.ts"
click node_skills "https://github.com/ozyrionhaha/agentscope/blob/main/server/skills.ts"
click node_providers "https://github.com/ozyrionhaha/agentscope/blob/main/server/providers.ts"
click node_vault "https://github.com/ozyrionhaha/agentscope/blob/main/server/vault.ts"
click node_browser "https://github.com/ozyrionhaha/agentscope/blob/main/server/browser.ts"
click node_mcp "https://github.com/ozyrionhaha/agentscope/blob/main/server/mcp.ts"
click node_store "https://github.com/ozyrionhaha/agentscope/blob/main/server/storage.ts"
click node_usage "https://github.com/ozyrionhaha/agentscope/blob/main/src/UsagePage.tsx"
click node_workflow "https://github.com/ozyrionhaha/agentscope/blob/main/server/app.ts"

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_ui,node_appui,node_api,node_usage,node_user toneBlue
class node_server,node_runtime,node_tools,node_permissions toneAmber
class node_context,node_workspace,node_terminal,node_skills,node_workflow toneMint
class node_providers,node_browser,node_mcp toneRose
class node_vault,node_store toneIndigo
```

## Components

### Workspace UI

- [Workspace UI](https://github.com/ozyrionhaha/agentscope/blob/main/src/WorkspacePage.tsx): `src/WorkspacePage.tsx`
- [App Navigation](https://github.com/ozyrionhaha/agentscope/blob/main/src/App.tsx): `src/App.tsx`
- [API Client](https://github.com/ozyrionhaha/agentscope/blob/main/src/api.ts): `src/api.ts`
- [Usage Tracking](https://github.com/ozyrionhaha/agentscope/blob/main/src/UsagePage.tsx): `src/UsagePage.tsx`

### Agent Runtime

- [Local API Server](https://github.com/ozyrionhaha/agentscope/blob/main/server/app.ts): `server/app.ts`
- [Agent Runtime](https://github.com/ozyrionhaha/agentscope/blob/main/server/runtime.ts): `server/runtime.ts`
- [Tool Registry](https://github.com/ozyrionhaha/agentscope/blob/main/server/tools.ts): `server/tools.ts`
- [Permissions](https://github.com/ozyrionhaha/agentscope/blob/main/server/permissions.ts): `server/permissions.ts`

### Project Capabilities

- [Project Context](https://github.com/ozyrionhaha/agentscope/blob/main/server/context.ts): `server/context.ts`
- [Workspace Files](https://github.com/ozyrionhaha/agentscope/blob/main/server/workspace.ts): `server/workspace.ts`
- [Terminal Sessions](https://github.com/ozyrionhaha/agentscope/blob/main/server/terminal.ts): `server/terminal.ts`
- [Skills & Plugins](https://github.com/ozyrionhaha/agentscope/blob/main/server/skills.ts): `server/skills.ts`
- [Workflows](https://github.com/ozyrionhaha/agentscope/blob/main/server/app.ts): `server/app.ts`

### Models & Integrations

- [Model Providers](https://github.com/ozyrionhaha/agentscope/blob/main/server/providers.ts): `server/providers.ts`
- [Browser Automation](https://github.com/ozyrionhaha/agentscope/blob/main/server/browser.ts): `server/browser.ts`
- [MCP Servers](https://github.com/ozyrionhaha/agentscope/blob/main/server/mcp.ts): `server/mcp.ts`

### Local State

- [Credential Vault](https://github.com/ozyrionhaha/agentscope/blob/main/server/vault.ts): `server/vault.ts`
- [SQLite Store](https://github.com/ozyrionhaha/agentscope/blob/main/server/storage.ts): `server/storage.ts`

### Other components

- **User**

## Connections

- User → Workspace UI: prompts
- App Navigation → API Client: requests (evidence: `src/App.tsx`)
- Workspace UI → API Client: requests (evidence: `src/WorkspacePage.tsx`)
- API Client → Local API Server: calls API (evidence: `src/api.ts`)
- Local API Server → Agent Runtime: dispatches tasks (evidence: `server/app.ts`)
- Agent Runtime → Model Providers: calls model (evidence: `server/runtime.ts`)
- Agent Runtime → Project Context: builds context (evidence: `server/runtime.ts`)
- Agent Runtime → Tool Registry: dispatches tools (evidence: `server/runtime.ts`)
- Tool Registry → Permissions: checks access (evidence: `server/tools.ts`)
- Tool Registry → Workspace Files: edits files (evidence: `server/tools.ts`)
- Tool Registry → Terminal Sessions: runs commands (evidence: `server/tools.ts`)
- Tool Registry → Skills & Plugins: loads skills (evidence: `server/tools.ts`)
- Tool Registry → Browser Automation: automates pages (evidence: `server/tools.ts`)
- Tool Registry → MCP Servers: calls MCP (evidence: `server/tools.ts`)
- Project Context → Workspace Files: indexes files (evidence: `server/context.ts`)
- Project Context → SQLite Store: persists index (evidence: `server/context.ts`)
- Workspace Files → SQLite Store: saves checkpoints (evidence: `server/workspace.ts`)
- Terminal Sessions → SQLite Store: saves sessions (evidence: `server/terminal.ts`)
- Agent Runtime → SQLite Store: records events (evidence: `server/runtime.ts`)
- Model Providers → Credential Vault: reads credentials (evidence: `server/providers.ts`)
- Credential Vault → SQLite Store: stores encrypted data (evidence: `server/vault.ts`)
- Local API Server → SQLite Store: initializes state (evidence: `server/app.ts`)
- Workspace UI → Local API Server: streams task events (evidence: `src/WorkspacePage.tsx`)
- Usage Tracking → API Client: loads usage (evidence: `src/UsagePage.tsx`)
- User → Workflows: selects workflow
- Agent Runtime → Workflows: executes workflows (evidence: `server/app.ts`)
- User → Browser Automation: enables browser
