Arknights Operator Gacha
Generate a random Arknights operator agent with authentic lore-based personality.
Architecture
This skill uses a worker script + LLM generation architecture:
- 1. Worker script (
gacha_worker.py): Executes all deterministic tasks (roll, fetch, create, download) - LLM (this agent): Generates creative content (SOUL.md) and spawns operator
Language Detection
CRITICAL: Detect user language from their gacha command:
- - If command is in Chinese (e.g., "抽卡", "召唤干员") → cn / zh
- If command is in English (e.g., "gacha", "pull") → en
Store detected language and use it for ALL subsequent steps (SOUL.md writing, spawn task, etc.).
Workflow
Step 1: Execute Worker Script
Run the deterministic worker:
CODEBLOCK0
Worker performs:
- 1. Roll star rating (1-100)
- Fetch operator list from INLINECODE1
- Parses the
mrfz-wtable table to extract operator info
- Returns a dict:
{operator_name: {"avatar_url": "...", "detail_url": "..."}}
- 3. Randomly select operator (with avatar and detail URLs)
- Fetch Chinese name from Fandom page (data-source="cnname")
- Check for duplicates (auto re-roll if exists)
- Create agent via INLINECODE4
- Create template IDENTITY.md (bilingual)
- Download avatar (using URL from step 2, with domain whitelist and validation)
- Git commit initial files
- Output JSON to stdout
Worker output format:
CODEBLOCK1
Note: The worker provides both English and Chinese URLs:
- -
en_detail_url: Fandom wiki page (English lore) - INLINECODE6 : PRTS wiki page (Chinese lore)
- INLINECODE7 : Fandom Dialogue page (voice lines, always English)
- INLINECODE8 : Operator icon from Fandom
Step 2: Handle Result
If duplicate: true:
- - Inform user: "检测到重复干员,正在重新抽取..." / "Duplicate operator detected, re-rolling..."
- Return to Step 1 (worker will re-roll)
If success: false:
- - Show error message
- Stop workflow
If success: true:
- - Announce: "恭喜你抽到了 [cnname] ([stars]★)!" / "Congratulations! You've pulled [enname] ([stars]★)!"
- Continue to Step 3
Step 3: Generate SOUL.md
Fetch lore from URLs provided by worker:
CODEBLOCK2
Parse lore sections from both sources:
- - File/档案: Basic background, origin, personality
- Story: Detailed story appearances across main chapters and side stories; shows character's actions, decisions, and development in actual plot contexts
- Dialogue: Voice lines that reveal character personality
- Trivia/模组: Additional character details, relationships, and module stories
Generate comprehensive SOUL.md:
CRITICAL - Write SOUL.md in detected language
Structure:
- 1. Core Identity - Background, motivation, personality (blend EN+CN sources)
- Voice and Mannerisms - Speech patterns, catchphrases (from Dialogue)
- Relationships - Connections to other characters
- Themes - Internal conflicts, philosophy
- How to Embody - Acting guidance
- Reference: Original Voice Lines - Key quotes (EN with CN)
Write to: INLINECODE12
Step 4: Update IDENTITY.md
Fill in the [TO_BE_FILLED_BY_LLM] fields with actual Class and Faction from fetched lore.
Step 5: Final Git Commit
CODEBLOCK3
Step 6: Roleplay Scene - Operator Arrival
Spawn the operator in a roleplay scenario consistent with Arknights game lore. In this universe, operators join Rhodes Island through standard recruitment channels and are unaware of the meta "gacha" system.
For Chinese users:
CODEBLOCK4
For English users:
CODEBLOCK5
Step 7: Present Summary
Report to user:
- - Operator name (both EN and CN)
- Rarity (Stars)
- Key personality traits
- Workspace path
- Available via INLINECODE14
Worker Script Security
The worker script (gacha_worker.py) implements:
- - Input validation: Agent names sanitized (alphanumeric + hyphens only)
- Path traversal prevention: Rejects
.., /, \ in names - URL whitelist: Only
static.wikia.nocookie.net and INLINECODE20 - HTTPS enforced: All downloads use HTTPS
- Content validation: Only image/png, jpeg, webp accepted
- Size limits: Max 5MB for avatars
- Safe subprocess: All commands use argument lists, INLINECODE21
Scripts
| Script | Purpose |
|---|
| INLINECODE22 | Deterministic tasks (roll, fetch, create, download, commit) |
Data Flow
CODEBLOCK6
Notes
- - Worker does: All deterministic operations (HTTP, filesystem, subprocess), provides bilingual URLs
- LLM does: Creative generation (SOUL.md writing), fetches lore from provided URLs, interpretation, spawning
- Progress visibility: Worker prints to stderr; user sees real-time updates
- Security: All external inputs validated in worker before use
- Bilingual: Both English and Chinese sources are always fetched; LLM can blend them creatively
明日方舟干员抽卡
生成一位具有基于原设性格的随机明日方舟干员角色。
架构
本技能采用 工作脚本 + 大语言模型生成 架构:
- 1. 工作脚本(gacha_worker.py):执行所有确定性任务(抽卡、获取、创建、下载)
- 大语言模型(本智能体):生成创意内容(SOUL.md)并召唤干员
语言检测
关键: 根据用户的抽卡指令检测语言:
- - 如果指令为中文(如抽卡、召唤干员)→ cn / zh
- 如果指令为英文(如gacha、pull)→ en
存储检测到的语言,并在所有后续步骤(编写SOUL.md、召唤任务等)中使用。
工作流程
第一步:执行工作脚本
运行确定性工作脚本:
python
result = exec(
python3 ~/.openclaw/workspace/skills/arknights-operator-gacha/scripts/gacha_worker.py,
timeout=120
)
工作脚本执行:
- 1. 抽取星级(1-100)
- 从 https://arknights.fandom.com/wiki/Operator/{N}-star 获取干员列表
- 解析 mrfz-wtable 表格提取干员信息
- 返回字典:{operator
name: {avatarurl: ..., detail_url: ...}}
- 3. 随机选择干员(包含头像和详情链接)
- 从Fandom页面获取中文名(data-source=cnname)
- 检查重复(自动重新抽取)
- 通过 openclaw agents add 创建智能体
- 创建模板 IDENTITY.md(双语)
- 下载头像(使用第二步的链接,包含域名白名单和验证)
- Git提交初始文件
- 输出JSON到标准输出
工作脚本输出格式:
json
{
success: true,
stars: 6,
operator: {
en_name: Lin,
cn_name: 林,
avatarurl: https://static.wikia.nocookie.net/.../Linicon.png,
endetailurl: https://arknights.fandom.com/wiki/Lin,
cndetailurl: https://prts.wiki/w/%E6%9E%97
},
agent_name: lin,
workspace: ~/.openclaw/workspace-lin,
duplicate: false,
dialogue_url: https://arknights.fandom.com/wiki/Lin/Dialogue
}
注意: 工作脚本提供中英文链接:
- - endetailurl:Fandom维基页面(英文设定)
- cndetailurl:PRTS维基页面(中文设定)
- dialogueurl:Fandom对话页面(语音台词,始终为英文)
- avatarurl:来自Fandom的干员图标
第二步:处理结果
如果 duplicate: true:
- - 通知用户:检测到重复干员,正在重新抽取...
- 返回第一步(工作脚本将重新抽取)
如果 success: false:
如果 success: true:
- - 宣布:恭喜你抽到了 [cn_name] ([stars]★)!
- 继续到第三步
第三步:生成SOUL.md
从工作脚本提供的链接获取设定资料:
python
从Fandom获取英文设定(多个子页面)
en
file = webfetch(f{result[operator][en
detailurl]}/File) # 基础档案、属性、文件
en
story = webfetch(f{result[operator][en
detailurl]}/Story) # 剧情出场、剧情参与
en
trivia = webfetch(f{result[operator][en
detailurl]}/Trivia) # 轶事、人际关系、杂项信息
从PRTS获取中文设定
zh
lore = webfetch(result[operator][cn
detailurl])
从对话页面获取语音台词
dialogue = web
fetch(result[operator][dialogueurl])
从两个来源解析设定章节:
- - 档案/文件:基础背景、出身、性格
- 剧情:主线及支线剧情中的详细出场;展示角色在剧情中的行动、决策和发展
- 对话:揭示角色性格的语音台词
- 轶事/模组:额外的角色细节、人际关系和模组故事
生成全面的SOUL.md:
关键 - 使用检测到的语言编写SOUL.md
结构:
- 1. 核心身份 - 背景、动机、性格(融合中英文来源)
- 语音与举止 - 说话方式、口头禅(来自对话)
- 人际关系 - 与其他角色的联系
- 主题 - 内心冲突、哲学
- 如何扮演 - 表演指导
- 参考:原始语音台词 - 关键语录(英文附中文)
写入:[workspace]/SOUL.md
第四步:更新IDENTITY.md
用获取的设定资料中的实际职业和阵营填充 [TOBEFILLEDBYLLM] 字段。
第五步:最终Git提交
bash
cd ~/.openclaw/workspace-{agent_name}
git add -A
git commit -m 添加SOUL.md:{enname}({cnname})({stars}★)
第六步:角色扮演场景 - 干员报到
在符合明日方舟游戏设定的角色扮演场景中召唤干员。在这个世界中,干员通过标准招募渠道加入罗德岛,不知道元层面的抽卡系统。
中文用户:
python
sessions_spawn(
task=你现在是罗德岛的一名干员,刚刚完成入职手续,前来向博士报到。用你最自然的口吻打招呼,展示你的性格特点。参考你的语音记录中的干员报到或交谈部分的语气。\n\n⚠️ 重要:直接输出角色台词即可,不要包含任何元叙述、解释性文字或场景描述。只说你作为干员应该说的话。,
agentId={operator-name},
mode=run,
timeoutSeconds=60
)
英文用户:
python
sessions_spawn(
task=You are an operator of Rhodes Island who has just completed onboarding, now reporting to the Doctor. Introduce yourself naturally, showcasing your personality. Reference your Introduction or Talk voice lines for tone.\n\n⚠️ IMPORTANT: Output ONLY the characters dialogue. Do NOT include meta-commentary, explanations, or scene descriptions. Just speak as the operator would.,
agentId={operator-name},
mode=run,
timeoutSeconds=60
)
第七步:呈现摘要
向用户报告:
- - 干员名称(中英文)
- 稀有度(星级)
- 关键性格特征
- 工作空间路径
- 可通过 agentId={agent_name} 使用
工作脚本安全性
工作脚本(gacha_worker.py)实现了:
- - 输入验证:智能体名称经过净化(仅限字母数字和连字符)
- 路径遍历防护:拒绝名称中的 ..、/、\
- URL白名单:仅限 static.wikia.nocookie.net 和 media.prts.wiki
- 强制HTTPS:所有下载使用HTTPS
- 内容验证:仅接受 image/png、jpeg、webp
- 大小限制:头像最大5MB
- 安全子进程:所有命令使用参数列表,shell=False
脚本
| 脚本 | 用途 |
|---|
| gacha_worker.py | 确定性任务(抽卡、获取、创建、下载、提交) |
数据流
用户请求
↓
执行工作脚本
↓
工作脚本输出JSON(双语链接)
↓
大语言模型获取中英文设定 → 生成SOUL.md
↓
召唤干员(报到)
↓
用户看到干员问候
备注
- - 工作脚本负责:所有确定性操作(HTTP、文件系统、子进程),提供双语链接
- 大语言模型负责:创意生成(编写SOUL.md),从提供的链接获取设定,解读,召唤
- 进度可见性:工作脚本输出到标准错误;用户看到实时更新
- 安全性:所有外部输入在使用前在工作脚本中验证
- 双语:始终获取中英文来源;大语言模型可创意融合