feat(server): add localized agent starter config endpoint

Add a public GET /api/ui/agent-starters endpoint returning localized
empty-state content (title, description, preview images, and starter
prompts) for the canvas Agent panel. Content is server-configurable via
AgentStarter config with built-in zh-CN/en-US fallbacks, and the route is
exempt from authentication so shared canvases render the same content.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-10 22:19:14 +08:00
parent 2df9ae6581
commit c94b163540
11 changed files with 373 additions and 1 deletions
+47
View File
@@ -20,6 +20,53 @@ Base path: `/api`
Returns credits, quick actions, recent projects, and inspiration items for the Moteva-style home screen.
## Agent Starters
`GET /api/ui/agent-starters?locale=zh-CN`
Returns the localized empty-state content used by the canvas Agent panel. The endpoint is public so shared canvases can render the same content. Supported locales are `zh-CN` and `en-US`; unsupported values fall back to `zh-CN`.
```json
{
"title": "今天想创作什么?",
"description": "输入提示词开始——或使用下方的起点",
"previewImages": [
"https://static.codia.ai/public/images/f788bdcc/lg.webp",
"https://static.codia.ai/public/images/ec25067a/lg.webp",
"https://static.codia.ai/public/images/d4ccbe39/lg.webp"
],
"starters": [
{
"id": "ecommerce",
"label": "电商商品图",
"prompt": "Create a premium ecommerce product image for a portable espresso machine, with realistic lighting, clean composition, benefit callouts, and marketplace-ready visual hierarchy"
}
]
}
```
The full block can be overridden through `AgentStarter` service configuration. `PreviewImages` accepts up to three URLs; each locale owns its ordered `Starters` list. Invalid or empty configured values fall back to the built-in content, preserving the frontend contract until an operations content store replaces the configuration source.
```yaml
AgentStarter:
PreviewImages:
- https://cdn.example.com/agent-entry-1.webp
ZhCN:
Title: 今天想创作什么?
Description: 输入提示词开始——或使用下方的起点
Starters:
- ID: campaign
Label: 运营活动
Prompt: Create a campaign visual for the current promotion
EnUS:
Title: What would you like to create today?
Description: Enter a prompt to begin, or use one of the starting points below.
Starters:
- ID: campaign
Label: Campaign
Prompt: Create a campaign visual for the current promotion
```
## Auth
Global mode is enabled in `etc/config.yaml`. Email verification codes are stored through the cache abstraction for 10 minutes; with `Cache.Driver: redis`, the code only lives in Redis until TTL or successful consumption.