- Python 54.4%
- JavaScript 26.9%
- CSS 11.1%
- HTML 6.9%
- Shell 0.7%
| .vscode | ||
| agent_hub | ||
| deploy | ||
| materials | ||
| tests | ||
| .env.example | ||
| .gitignore | ||
| app.py | ||
| README.md | ||
| README.zh-CN.md | ||
| requirements.txt | ||
Multi-Agent Business Workbench for Global Expansion V2.0.0
Empowering global expansion with AI.
English | 简体中文
A multi-account AI agent platform built for Chinese brands going global. The UI follows the Microsoft 365 Copilot layout. Every user gets a private workspace with their own agents, models and conversations, and can share an agent with specific colleagues or publish it to the shared agent library.
Eight ready-to-use export specialists ship out of the box — and you can build your own:
| Agent | What it solves |
|---|---|
| 🎯 Brand Strategy | Positioning, naming & slogan, value proposition, cultural localization |
| 💹 Finance | Fund repatriation, VAT / tariff estimation, FX risk, profit modeling |
| 🔍 Product Selection | Six-dimension scoring: demand, competition, margin, compliance |
| 💬 Private Domain | WhatsApp / LINE / Telegram acquisition, segmentation, SOP, repurchase |
| 🌍 Market Research | TAM/SAM/SOM, personas, channel landscape, entry strategy |
| ⚖️ Compliance & Legal | Certifications, IP, data privacy, advertising & platform policies |
| 🚢 Logistics & Supply Chain | First-mile options, overseas warehouses, fulfillment cost, replenishment |
| 🎧 Cross-border Support | Multilingual scripts, negative reviews & disputes, support knowledge base |
Visibility model
| Scope | Who can see it | Notes |
|---|---|---|
| 🔒 Private (default) | Creator only | Every new agent starts here |
| 🤝 Shared | Creator + selected users | Use-only; recipients cannot edit or re-share |
| 🌍 Public (library) | Everyone | Listed in the library tab, one-click "Add to mine" |
| 🏛 Built-in | Everyone | The 8 presets; read-only for users, editable by admins |
Isolation rules:
- Agents — you only see your own, agents shared with you, public library agents and built-in ones. Accessing someone else's private agent always returns 404 so its existence is never leaked.
- Models — model credentials are per-account and never cross accounts. Models registered
from
.envare site-wide shared and read-only. - Conversations — strictly private; other users cannot list or open them.
- The first registered account becomes the administrator, who can edit built-in agents and restore the presets.
Features
- Sign-up / sign-in — email and password, PBKDF2 salted hashes, signed cookie sessions (14 days).
- Agent library — Mine / Shared with me / Library tabs, category filters, search, enable and disable.
- Agent editor — name, icon, accent color, category, system prompt, greeting, suggested questions, capability tags, temperature and model binding, with a live preview card.
- Sharing — search a user and share in one click, see or revoke the access list, and a single switch publishes the agent to the library.
- Model management — any OpenAI-compatible endpoint (OpenAI, DeepSeek, Qwen, Kimi, Zhipu, Ollama, vLLM, one-api…), Azure OpenAI and Anthropic Claude; set a default model and run a connectivity test.
- Chat — Copilot-like experience with SSE streaming, Markdown rendering (tables, code blocks, quotes, lists), multi-turn context, conversation history, and a list of the knowledge snippets actually cited in each answer.
- Knowledge bases — turn product manuals, policies and FAQs into a knowledge base. Use a local document library (upload txt / md / csv / json / html and search by keyword) or connect Dify datasets, RAGFlow or a generic JSON retrieval API. Pick multiple knowledge bases next to the input box and retrieved snippets are injected into the prompt.
- Chat attachments — upload files with the “+” button; attachments stay available to the model for the current conversation and can be removed at any time.
- Demo mode — with no model configured, the app still works end to end and returns structured sample answers while guiding you to add a model.
Mobile support
The web app works directly in mobile browsers — no separate app:
| Behavior | Breakpoint |
|---|---|
| Sidebar becomes a drawer (close via overlay, nav item or Esc; content is not squeezed) | ≤ 860px |
| Top bar hides product name and user name; form grids become single column | ≤ 860px |
| Dialogs become bottom sheets | ≤ 640px |
| Tab bars scroll horizontally; suggested questions and cards go single column | ≤ 640px |
Implementation notes:
- Inputs use a 16px font size on mobile — iOS zooms the page when focusing smaller inputs.
- Larger touch targets: 40px primary buttons, 42px icon buttons, 44px nav items.
- Hover-only actions such as copy and delete are always visible by default and only
collapse inside
@media (hover: hover) and (min-width: 641px); otherwise they are unreachable on touch devices. - Grids use
minmax(min(100%, 300px), 1fr)so narrow screens never scroll horizontally. - Heights use
100dvhand padding usesenv(safe-area-inset-*)for mobile browser bars and notches. - Static assets are always referenced through
asset_url(), which appends?v=<file mtime>; without it, a reverse proxy that caches/static/would keep serving outdated CSS/JS after a release.
Tech stack
| Layer | Choice |
|---|---|
| Backend | Python 3.12 + Flask 3 (application factory + blueprints) |
| Storage | SQLite via the standard-library sqlite3 (WAL, foreign keys) — no external DB |
| Auth | Flask signed sessions + werkzeug.security PBKDF2 |
| Frontend | Jinja templates + vanilla JavaScript (no build step, no frontend framework) |
| Streaming | Server-Sent Events, forwarded with requests streaming |
| Styling | Hand-written CSS design system (Fluent / M365 Copilot look) |
Dependencies: Flask and requests only.
Quick start
# 1. Dependencies
pip install -r requirements.txt
# 2. Run
python app.py
# → http://127.0.0.1:5000
# 3. Open the page and register the first account (it becomes the administrator)
Optional environment variables:
| Variable | Default | Description |
|---|---|---|
PORT |
5000 |
Listening port |
HOST |
127.0.0.1 |
Listening address |
AGENT_HUB_DB |
./data/app.db |
SQLite file location |
AGENT_HUB_SECRET |
auto-generated | Session signing key; generated and stored in data/secret_key when unset |
AGENT_HUB_ALLOW_REGISTRATION |
1 |
Set to 0 to disable self-registration (registration stays open while no account exists, so you can bootstrap) |
AGENT_HUB_INVITE_CODE |
empty | When set, registration requires this invite code |
AGENT_HUB_SECURE_COOKIES |
0 |
Set to 1 when the site is served over HTTPS |
AGENT_HUB_DEBUG / AGENT_HUB_RELOAD |
1 |
Set to 0 to disable |
Account management
With self-registration disabled, manage accounts from the CLI. Passwords are read interactively and are never written to shell history:
flask --app agent_hub create-user # the first account becomes the administrator
flask --app agent_hub list-users
flask --app agent_hub set-admin --email someone@example.com
flask --app agent_hub reset-password --email someone@example.com
flask --app agent_hub delete-user --email someone@example.com
flask --app agent_hub stats
Without the
flaskexecutable on yourPATH, usepython -m flask --app agent_hub ....
--account accepts either an email address or a plain account name (such as admin).
Registration requires a real email address; the CLI accepts both forms, which is why the
login field is a plain text input.
Configuring models
Two options — pick either or both:
- In the UI (recommended) — Model management → Add model, pick a provider to pre-fill the form, enter the API key and model ID, save, then run Test to verify connectivity. The model is visible only to you.
- A
.envfile (shared) — copy.env.exampleto.envand fill in keys. On first start these are registered as site-wide shared models: everyone can use them, nobody but an administrator can edit them.
Supported key variables: OPENAI_API_KEY, DEEPSEEK_API_KEY, DASHSCOPE_API_KEY,
MOONSHOT_API_KEY, ZHIPUAI_API_KEY, ANTHROPIC_API_KEY, plus optional *_MODEL,
*_BASE_URL and *_LABEL overrides.
Project layout
.
├── app.py # Development entry point: python app.py
├── requirements.txt
├── .env.example
├── data/ # app.db / secret_key (created automatically, git-ignored)
├── tests/
│ ├── _helpers.py # Assertions and register/login helpers
│ ├── smoke_test.py # Login guard, registration, agent/model CRUD, chat
│ ├── sharing_test.py # Multi-account isolation, sharing, publishing, 404/403
│ ├── provider_test.py # Streaming parsing for OpenAI / Anthropic against a mock
│ ├── migration_test.py # Upgrading an old single-user database
│ ├── cli_test.py # Account CLI and the registration switch
│ ├── invite_test.py # Invite codes and plain account names
│ └── knowledge_test.py # Knowledge bases, uploads, retrieval injection, attachments
└── agent_hub/
├── __init__.py # create_app() factory, session key, cache headers
├── db.py # Schema plus idempotent migrations
├── auth.py # Register / login / logout, permission decorators, switches
├── cli.py # create-user / list-users / reset-password / stats …
├── repository.py # All SQL access, always filtered by the viewer
├── bootstrap.py # First-paint payload, trimmed per user
├── llm.py # Provider adapters, streaming, connectivity probe, demo mode
├── api.py # /api/* JSON endpoints and the SSE chat endpoint
├── views.py # Page routes (login required) plus /healthz
├── knowledge.py # Knowledge connectors and local keyword retrieval
├── presets.py / seed.py # Built-in agents and models from environment variables
├── icons.py # Inline SVG icon set for templates
├── templates/ # login / register / base / chat / agents / agent_editor / models / knowledge
└── static/
├── css/app.css # Design system (tokens, components, responsive rules)
└── js/ # markdown / core / share / shell / chat / agents / agent-editor / models
Styling and caching
- All styles live in
agent_hub/static/css/app.css; reuse its CSS variables and component classes instead of inline styles. - Reference static files with
{{ asset_url('js/xxx.js') }}, which appends the file modification time for cache busting. - HTML responses are sent with
Cache-Control: private, no-cacheso browsers never reuse a logged-in page from cache.
HTTP API
Every /api/* endpoint requires a signed-in user; otherwise it returns
401 {"ok": false, "error": "登录状态已失效,请重新登录。"}. All responses use
{"ok": true, ...} or {"ok": false, "error": "..."}.
| Method | Path | Description |
|---|---|---|
GET |
/api/bootstrap |
First-paint data: current user, usable agents, library agents, models, conversations, counters |
GET |
/api/me |
Current user |
GET |
/api/users?q= |
Search other users (for sharing) |
GET |
/api/agents?scope=mine|shared|library|usable |
List agents by visibility scope |
GET/POST |
/api/agents |
List / create an agent (private by default) |
GET/PATCH/DELETE |
/api/agents/<id> |
Read / update / delete (404 when invisible, 403 when not editable) |
POST |
/api/agents/<id>/duplicate |
Copy an agent into your own workspace |
POST |
/api/agents/<id>/visibility |
{"visibility": "public"|"private"} publish / unpublish |
GET/POST |
/api/agents/<id>/shares |
List / add a share ({"userId": "usr_x"}) |
DELETE |
/api/agents/<id>/shares/<user_id> |
Revoke a share |
POST |
/api/agents/reseed |
Restore built-in agents (administrators only) |
GET/POST |
/api/models |
List (own + shared) / create |
PATCH/DELETE |
/api/models/<id> |
Update / delete; an empty apiKey keeps the current key; system models return 403 |
POST |
/api/models/<id>/test |
Connectivity test, returns elapsed time |
GET/POST |
/api/knowledge-bases |
List (own + system presets) / create |
GET/PATCH/DELETE |
/api/knowledge-bases/<id> |
Detail (with documents) / update / delete; 404 / 403 when not allowed |
POST |
/api/knowledge-bases/<id>/documents |
Upload local documents (multipart, field name files) |
DELETE |
/api/knowledge-bases/<id>/documents/<doc_id> |
Delete a document |
POST |
/api/knowledge-bases/<id>/test |
Retrieval test ({"query": "…"} optional) |
GET/POST |
/api/conversations |
List / create conversations (always scoped to you) |
GET/PATCH/DELETE |
/api/conversations/<id> |
Detail / rename or switch knowledge bases (kbIds) / delete |
POST |
/api/conversations/<id>/files |
Upload chat attachments (multipart, field name files) |
DELETE |
/api/conversations/<id>/files/<file_id> |
Remove a chat attachment |
POST |
/api/chat |
SSE chat stream: start (with sources / warnings) → delta* → done (error on failure) |
Tests
python tests/smoke_test.py # Login guard, registration validation, agent/model CRUD, chat
python tests/sharing_test.py # Three-account isolation, sharing, publishing, 404/403
python tests/provider_test.py # Streaming parsing, auth errors, connection failures
python tests/migration_test.py # Legacy database upgrade, ownership, idempotency
python tests/cli_test.py # Account CLI, registration switch, cascade cleanup
python tests/invite_test.py # Invite codes, plain account names, login and password reset
python tests/knowledge_test.py # Knowledge bases, uploads, retrieval injection, attachments
All seven scripts use temporary databases and never touch data/app.db.
Before committing, also run:
python -m compileall -q agent_hub app.py tests
Upgrading from V1
Just replace the code and start the app. Ownership columns are added to agents, models
and conversations, and built-in agents are marked public. Agents, models and
conversations created before the upgrade are assigned to the first registered account, so
other users will not see them. The startup log lists which columns were migrated.
Security notes
- Passwords are stored as salted PBKDF2 hashes; API responses never include them.
- Sessions use signed cookies (
HttpOnly+SameSite=Lax); cross-site requests do not carry the session, which gives basic CSRF protection. Serve the app over HTTPS in any shared deployment. - The session key comes from
AGENT_HUB_SECRET, otherwise a random value is generated and stored indata/secret_keywith mode600. - Model API keys are stored only in the local database and always masked in responses (first
and last four characters). They are not encrypted at rest, so never expose the
data/directory or the database file. - Agents you cannot see return 404 rather than 403, so the API never reveals their existence.