内容生成工作流
PREREQUISITE:阅读../anygen-shared/SKILL.md 以了解认证、全局标志和安全规则。
规则
严格遵循以下规则。
模式:运行 anygen schema 以检查所需参数和响应(如果需要)。
长时间运行:--wait 命令将阻塞,必须使用 sessions_spawn 在后台运行。
在 Feishu/Lark 上发送文件:不要使用消息工具发送文件。它会将非 ASCII 文件名损坏为 %XX 垃圾。
严格按照“发送文件”的 curl 过程。
步骤
- 发现操作元数据:anygen task operations
不要猜测操作类型。始终运行以获取支持的操作及其预计时间和缩略图支持。
- 上传参考文件(如果没有参考文件,则跳过):anygen file upload --data '{"file":"./data.csv"}'
→ 保存 file_token 以供步骤 4 使用。
告诉用户文件已上传。
- 收集要求(如果要求已经明确,则跳过):anygen task prepare --data '{"operation":"slide","messages":[{"role":"user","content":"创建 Q4 报告 PPT"}]}'
向用户呈现回复,收集他们的答案,然后使用 prepare_session_id 和更新的消息再次调用:anygen task prepare --data '{"operation":"slide","prepare_session_id":"","messages":[...之前的消息...,{"role":"user","content":"用户的答案"}]}'
重复直到状态=ready。
→ 当准备就绪时,显示 suggested_task_params.prompt 作为大纲,确认用户,然后在步骤 4 中将其用作提示。
- 创建任务:anygen task create --data '{"operation":"slide","prompt":"...","file_tokens":[""]}'
→ 告诉用户任务已创建,共享 task_url 和预计时间(来自步骤 1)。
- 等待完成(长时间运行,必须通过 sessions_spawn 在后台运行):anygen task get --params '{"task_id":""}' --wait
- 交付(步骤 5 完成后,检查结果):
没有文件(output.files 为空):如果存在,则向用户显示消息。
有文件 + 有缩略图(来自步骤 1 的 has_thumbnail):anygen task +download --task-id --thumbnail
→ 将缩略图图像与 task_url 作为预览一起发送。
不要下载文件 - 等待用户请求下载或修改(→ 步骤 7)。
有文件 + 没有缩略图:anygen task +download --task-id
→ 将文件发送给用户(参见下面的“发送文件”)。
- 修改(在用户请求时):anygen task message send --params '{"task_id":""}' --data '{"content":"..."}'
然后等待结果(长时间运行,必须通过 sessions_spawn 在后台运行):anygen task message list --params '{"task_id":""}' --wait
→ 重复步骤 6 以重新导出和交付。
所有修改都重用相同的任务。
发送文件
当用户请求文件下载时,或当从步骤 6 交付文件时:anygen task +download --task-id
下载特定文件:anygen task +download --task-id --file report.pptx
Feishu/Lark(消息工具会损坏非 ASCII 文件名,请使用 curl 代替):
获取凭据:从配置文件中读取 app_id 和 app_secret(例如 cat ~/.openclaw/openclaw.json | jq '.channels.feishu' 代替 openclaw config get)。
确保使用与当前帐户匹配的凭据。
获取令牌:curl -X POST 'https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal' -H 'Content-Type: application/json' -d '{"app_id":"","app_secret":""}'
上传 + 发送每种文件类型:
图像(缩略图、png、jpg 等):上传:curl -X POST 'https://open.feishu.cn/open-apis/im/v1/images' -H 'Authorization: Bearer ' -F 'image_type=message' -F 'image=@./preview.png'
发送:curl -X POST 'https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=chat_id' -H 'Authorization: Bearer ' -H 'Content-Type: application/json' -d '{"receive_id":"","msg_type":"image","content":"{\"image_key\":\"\"}"}'
文档(pptx/docx/pdf 等):上传:curl -X POST 'https://open.feishu.cn/open-apis/im/v1/files' -H 'Authorization: Bearer ' -F 'file_type=ppt' -F 'file=@./output.pptx' -F 'file_name=output.pptx'
file_type 值:opus(音频)、mp4(视频)、pdf、doc、xls、ppt、stream(其他)。
发送:curl -X POST 'https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=chat_id' -H 'Authorization: Bearer ' -H 'Content-Type: application/json' -d '{"receive_id":"","msg_type":"file","content":"{\"file_key\":\"\"}"}'
其他平台:通过平台的消息工具发送。
请参阅
anygen-task-download — 下载已完成任务的工件