Loading...
Loading...
Use when building or modifying websites with AI Staff (零号员工/万小智) via Alibaba Cloud OpenAPI. Supports conversation creation, async chat with requirement collection, PRD generation, code generation, and incremental SSE event polling.
npx skill4agent add aliyun/alibabacloud-aiops-skills alibabacloud-wxz-website-buildermkdir -p output/alibabacloud-wxz-website-builder
for f in skills/ai/service/alibabacloud-wxz-website-builder/scripts/*.py; do
python3 -m py_compile "$f"
done
echo "py_compile_ok" > output/alibabacloud-wxz-website-builder/validate.txtoutput/alibabacloud-wxz-website-builder/validate.txtoutput/alibabacloud-wxz-website-builder/pip install alibabacloud_tea_openapi>=0.4.4 alibabacloud_tea_util>=0.3.14ALIBABACLOUD_ACCESS_KEY_IDALIBABACLOUD_ACCESS_KEY_SECRET~/.alibabacloud/credentialsALIBABACLOUD_REGION_IDcn-hangzhoureferences/ak-setup-guide.mdzero2staff:CreateAIStaffConversationzero2staff:CreateAIStaffChatzero2staff:ListAIStaffChatEventszero2staff:ListAIStaffChatMessages~/.alibabacloud/credentialsreferences/ak-setup-guide.mdchatpollprogressDetailPhase 1: Create Conversation
↓
Phase 2: Fire requirement chat → poll → HITL → Fire resume → poll → ... → PRD ready
↓
Phase 3: Fire code generation → Show link → poll loop with progress → Site readyCONV=$(python scripts/aistaff_api.py create-conversation --text "做个popmart首页")
CONV_ID=$(echo $CONV | jq -r '.ConversationId')
CHAT_ID=$(echo $CONV | jq -r '.ChatId')
SITE_ID=$(echo $CONV | jq -r '.SiteId'){ConversationId, SiteId, ChatId, SectionId, BotId, Title}python scripts/aistaff_api.py chat \
--text "做个popmart首页" \
--conversation-id $CONV_ID \
--biz-id $SITE_IDpollphasewaiting_for_inputpython scripts/aistaff_api.py poll \
--conversation-id $CONV_ID \
--biz-id $SITE_ID \
--last-event-id 0phaseprocessingfetching_referencewaiting_for_inputquestionsmetaData.argumentsmessage.toolname: "AskUserQuestion"--phase generate_prd--phase generate_prd --user-navigation generate_prdpython scripts/aistaff_api.py chat \
--text '{"应用名称": "POP MART 官网", "主营服务": "潮流玩具", "目标用户": "Z世代潮流青年", "参考网站": "无"}' \
--conversation-id $CONV_ID \
--biz-id $SITE_ID \
--chat-id $CHAT_ID \
--chat-status interrupt \
--phase generate_prd \
--user-navigation generate_prd \
--hidden --without-refer--textheaderphasesummaryphase == "waiting_for_input"answersAskUserQuestionphase == "generating_prd"phase == "fetching_reference"summary.chatStatus == "success"summary.hasPrd == truesummary.chatStatus == "fail"# Poll example:
python scripts/aistaff_api.py poll \
--conversation-id $CONV_ID \
--biz-id $SITE_ID \
--last-event-id $LAST_EVENT_ID
# Auto-fill example (use the "answers" field from the AskUserQuestion event):
python scripts/aistaff_api.py chat \
--text '{"核心功能": ["商品展示", "品牌故事", "新闻资讯"]}' \
--conversation-id $CONV_ID \
--biz-id $SITE_ID \
--chat-id $CHAT_ID \
--chat-status interrupt \
--phase generate_prd \
--user-navigation generate_prd \
--hidden --without-referAskUserQuestionanswerspython scripts/aistaff_api.py chat \
--text "确认生成应用" \
--conversation-id $CONV_ID \
--biz-id $SITE_ID \
--phase generate_code \
--without-referhttps://wanwang.aliyun.com/webdesign/home#/ai/manage/prd?conversationId=<CONV_ID>python scripts/aistaff_api.py poll \
--conversation-id $CONV_ID \
--biz-id $SITE_ID \
--last-event-id $LAST_EVENT_IDprogressDetailphase == "processing"progressDetail.latestFilephase == "processing"latestFilephase == "processing"progressDetail.lastMessagephase == "success"phase == "fail"summary.chatStatus == "success"summary.chatStatus == "fail"summary.hasError == truechat--conversation-id | | Phase | Action |
|---|---|---|---|
| — | 2 (first round) | Parse AskUserQuestion, collect answers from user, resume with |
| — | 2 (subsequent) | Auto-fill with default |
| | 2 | PRD ready → proceed to Phase 3 |
| | 3 | Site is ready → show link |
| — | any | Ask user whether to retry |
| — | any | Poll timed out → use |
python scripts/aistaff_api.py create-conversation --text "用户问题"{ConversationId, SiteId, ChatId, SectionId, BotId, Title}pollpython scripts/aistaff_api.py chat --text "description" --conversation-id <ID> --biz-id <ID> [options]--text TEXT--conversation-id ID--biz-id ID--chat-id ID--chat-status interrupt--phase {requirement_collect,generate_prd,generate_code}--user-navigation TARGETgenerate_prd--phase generate_prd--hidden--without-refer--verbose{
"conversationId": "conv-xxx",
"chatId": "chat-xxx",
"status": "fired",
"error": null
}python scripts/aistaff_api.py poll --conversation-id <ID> --biz-id <ID> [--last-event-id N]--last-event-id NlastEventIdpoll--max-output-events N{
"conversationId": "conv-xxx",
"lastEventId": 45,
"newEvents": 3,
"phase": "generating_prd",
"summary": {
"chatStatus": "processing",
"hasError": false,
"errorMsg": "",
"hasPrd": false,
"toolsCalled": ["FetchWebsiteInfo"]
},
"progressDetail": {
"filesWrittenCount": 5,
"activeTools": ["Write"],
"latestFile": {
"path": "/home/wuying/workspace/src/components/Hero.tsx",
"semantic": "首页 Hero 轮播组件",
"status": "wait"
},
"allFiles": [
{"path": "/home/wuying/workspace/src/types/order.ts", "semantic": "订单类型定义"},
{"path": "/home/wuying/workspace/src/components/Hero.tsx", "semantic": "首页 Hero 轮播组件"}
],
"lastMessage": "好的,正在为您生成首页组件...",
"toolProgress": [
{"name": "Write", "status": "done", "semantic": "订单类型定义"},
{"name": "Write", "status": "wait", "semantic": "首页 Hero 轮播组件"}
]
},
"events": ["(last 10 events)"]
}progressDetailfilesWrittenCountactiveToolswaitlatestFilesemanticallFilespathsemanticlastMessagetoolProgressnamestatuswaitdonesemanticprogressDetaillatestFilestatus == "wait"latestFilestatus == "done"activeToolsfilesWrittenCount > 0activeToolslastMessagephase| Phase | Meaning | Suggested user message |
|---|---|---|
| General processing | "处理中..." |
| Fetching reference site | "正在获取参考网站信息..." |
| HITL form ready | (parse form and handle) |
| PRD generation in progress | "PRD 方案生成中..." |
| Completed successfully | "完成!" |
| Failed | (ask user whether to retry) |
python scripts/aistaff_api.py list-messages --conversation-id <ID> [--tail 10]ChatStatuschatpolllastEventIdpoll| Error | Action |
|---|---|
| Auth error | Ensure credentials are configured via default credential chain (env vars, config file, or RAM role) |
| Ask user whether to retry. Do NOT auto-retry |
| Poll shows no progress for 5+ minutes | Use |
cd skills/ai/service/alibabacloud-wxz-website-builder
# Phase 1: Create conversation
CONV=$(python scripts/aistaff_api.py create-conversation --text "做个popmart首页")
CONV_ID=$(echo $CONV | jq -r '.ConversationId')
CHAT_ID=$(echo $CONV | jq -r '.ChatId')
SITE_ID=$(echo $CONV | jq -r '.SiteId')
# Phase 2 Step 1: Fire requirement collection
python scripts/aistaff_api.py chat \
--text "做个popmart首页" \
--conversation-id $CONV_ID \
--biz-id $SITE_ID
# → Tell user: "正在分析您的需求,请稍候..."
# Phase 2 Step 2: Poll until first HITL form arrives
# (agent calls this every ~5s, shows progress between calls)
python scripts/aistaff_api.py poll \
--conversation-id $CONV_ID \
--biz-id $SITE_ID \
--last-event-id 0
# → Check phase: "waiting_for_input" means form is ready
# Phase 2 Step 3: Parse AskUserQuestion → collect from user (FIRST round only)
# Phase 2 Step 4: Fire resume with user answers
python scripts/aistaff_api.py chat \
--text '{"应用名称": "POP MART 官网", "主营服务": "潮流玩具", "目标用户": "Z世代潮流青年", "参考网站": "无"}' \
--conversation-id $CONV_ID \
--biz-id $SITE_ID \
--chat-id $CHAT_ID \
--chat-status interrupt \
--phase generate_prd \
--user-navigation generate_prd \
--hidden --without-refer
# → Tell user: "已收到您的需求,正在生成产品方案..."
# Phase 2 Step 5: Poll loop (agent-driven, ~5s interval)
# - phase="waiting_for_input" → auto-fill with defaults, fire resume
# → Tell user: "正在完善需求细节..."
# - phase="generating_prd" → Tell user: "PRD 方案生成中..."
# - summary.chatStatus="success" + summary.hasPrd=true → PRD ready, proceed
# Phase 3 Step 1: Fire code generation
python scripts/aistaff_api.py chat \
--text "确认生成应用" \
--conversation-id $CONV_ID \
--biz-id $SITE_ID \
--phase generate_code \
--without-refer
# Phase 3 Step 2: Show link immediately
echo "Link: https://wanwang.aliyun.com/webdesign/home#/ai/manage/prd?conversationId=$CONV_ID"
# → Tell user: "代码生成已启动,通常需要 2-5 分钟..."
# Phase 3 Step 3: Poll loop with progress (~10s interval)
python scripts/aistaff_api.py poll \
--conversation-id $CONV_ID \
--biz-id $SITE_ID \
--last-event-id $LAST_EVENT_ID
# → Use progressDetail.latestFile.semantic for rich messages
# → phase="success" → show link again, done!
# Modify site (optional, same chat+poll pattern)
python scripts/aistaff_api.py chat \
--text "首页title改下" \
--conversation-id $CONV_ID \
--biz-id $SITE_ID
# → poll loop...