website_manager · diff
git:20260729.70bd73d to git:20260730.13a8f56
33 added, 27 removed. Audit A to A.
---
name: website_manager
description: >
- Quản lý và deploy websites Cloudflare Workers. Extension cung cấp danh sách website dạng card,
- thêm website thủ công, tạo website tự động từ templates (git clone → build OpenNext → wrangler deploy → D1 + R2).
- Tích hợp với cloud_api để lấy Cloudflare credentials (CF_API_TOKEN + CF_ACCOUNT_ID).
+ Manage and deploy Cloudflare Workers websites. Provides a card list of websites,
+ manual add, and automatic creation from templates (git clone → build OpenNext → wrangler deploy → D1 + R2).
+ Integrates with cloud_api for Cloudflare credentials (CF_API_TOKEN + CF_ACCOUNT_ID, or Global API Key + email).
---
# Website Manager Extension
- ## Chức năng
- - **Danh sách websites**: card grid với tên, URL, token (user_token, wp_token), trạng thái (active/deploying/failed)
- - **Thêm website thủ công**: Dialog nhập tên, user_token, wp_token, thumbnail
- - **Tạo website tự động**: Chọn theme → nhập site_name + CF credentials → deploy pipeline tự động
- - **Live deploy log**: SSE stream real-time terminal output
- - **Cloudflare credentials**: Lấy từ Cloud Keys (cloud_api extension, provider cloudflare) hoặc nhập thủ công
+ ## Features
+ - **Website list**: card grid with name, URL, tokens (user_token, wp_token), status (active/deploying/failed)
+ - **Add manually**: dialog to enter name, user_token, wp_token, thumbnail
+ - **Create automatically**: pick a theme → enter site_name + CF credentials → automatic deploy pipeline
+ - **Live deploy log**: real-time SSE terminal stream (with a Cancel button to abort a running deploy)
+ - **Cloudflare credentials**: taken from Cloud Keys (cloud_api extension, cloudflare provider) or entered manually; supports both API Token and Global API Key (with email)
+ - **Agent skills**: exposes `🌐 Quản lý Website` (list) and `🚀 Tạo Website` (deploy) as runnable skills attached to the Web Agent
## API Endpoints
### Website CRUD
- - `GET /api/v1/website-manager/sites` — list all websites
- - `POST /api/v1/website-manager/sites` — add website manually
- - `PUT /api/v1/website-manager/sites/{id}` — update website
- - `DELETE /api/v1/website-manager/sites/{id}` — delete website
+ - `GET /api/v1/website-manager/sites` — list all websites (secrets masked)
+ - `POST /api/v1/website-manager/sites` — add a website manually
+ - `PUT /api/v1/website-manager/sites/{id}` — update a website
+ - `DELETE /api/v1/website-manager/sites/{id}` — delete a website
### Deploy
- - `POST /api/v1/website-manager/sites/deploy` — start deploy (cf_api_token, cf_account_id optional if saved in cloud_api)
+ - `POST /api/v1/website-manager/sites/deploy` — start a deploy (cf_api_token / cf_account_id / cf_email optional if saved in cloud_api)
+ - `POST /api/v1/website-manager/sites/{name}/cancel` — cancel a running deploy (kills the whole process tree)
- `GET /api/v1/website-manager/sites/{name}/logs` — SSE log stream
+ ### Skill endpoints (for agents)
+ - `POST /api/v1/website-manager/skill/websites` — human-readable site list
+ - `POST /api/v1/website-manager/skill/deploy` — deploy from a natural-language request (name + template)
+
### Templates & CF
- `GET /api/v1/website-manager/templates` — fetch from autoweb.tubecreate.com/api/templates
- `GET /api/v1/website-manager/cloudflare-profiles` — list CF profiles from cloud_api
### Cloudflare Keys (cloud_api)
- `GET /api/v1/cloud-api/cloudflare/profiles` — list CF profiles
- - `POST /api/v1/cloud-api/cloudflare/profiles` — add CF profile (api_token + account_id)
- - `POST /api/v1/cloud-api/cloudflare/profiles/{label}/test` — verify CF token
- - `DELETE /api/v1/cloud-api/cloudflare/profiles/{label}` — remove profile
+ - `POST /api/v1/cloud-api/cloudflare/profiles` — add a CF profile (api_token + account_id [+ email for Global API Key])
+ - `POST /api/v1/cloud-api/cloudflare/profiles/{label}/test` — verify the CF token
+ - `DELETE /api/v1/cloud-api/cloudflare/profiles/{label}` — remove a profile
- ## Deploy Pipeline Steps
- 1. git clone template từ githubUrl
+ ## Deploy Pipeline Steps (deploy_runner.js)
+ 1. git clone the template from githubUrl (`--` guards against argument injection)
2. npm install
- 3. wrangler d1 create → lấy database_id
- 4. wrangler d1 execute schema.sql --remote
- 5. Viết wrangler.toml (name, d1_databases, assets)
+ 3. wrangler d1 create → get database_id; and `wrangler r2 bucket create` (skipped gracefully if R2 is not enabled)
+ 4. wrangler d1 execute schema.sql --remote (auto-fixes JS-style `\'` → SQL `''` escaping)
+ 5. Write wrangler.toml (name, d1_databases, assets, r2_buckets when available)
6. npx @opennextjs/cloudflare build
7. npx wrangler deploy
- 8. fetch {deployUrl}/api/admin/init?adminPassword=...
- 9. Generate wptoken (login admin → lấy JWT)
+ 8. Seed admin: GET {deployUrl}/api/admin/init?adminPassword=... — if the template pre-seeds an admin, log in as the default admin (admin/admin123) first, then call init with the cookie + force=true so the user's password and template content are applied
+ 9. Emit a machine-readable `DEPLOY_RESULT {url, adminSeeded}` marker + `__DEPLOY_DONE__`. Note: the `wp_xxxx` application password is NOT generated during deploy — it is created separately via the api_keys table when explicitly requested.
## Data Storage
- - Websites: `EXTENSIONS_DATA_DIR/website_manager/websites.json`
+ - Websites: `EXTENSIONS_DATA_DIR/website_manager/websites.json` (atomic write, chmod 0600)
- Deploy logs: `EXTENSIONS_DATA_DIR/website_manager/logs/{site_name}.log`
- - Build temp: `EXTENSIONS_DATA_DIR/website_manager/build/{site_name}/` (xóa sau deploy)
- - CF credentials: `data/cloud_api_keys.json` (provider: cloudflare, dùng compound key format)
+ - Build temp: `EXTENSIONS_DATA_DIR/website_manager/build/{site_name}/` (removed after deploy)
+ - CF credentials: `data/cloud_api_keys.json` (provider: cloudflare, compound key format)