Skill: wangshengli0421/aiznt-volcseed (version 1.0.0)

--- name: aiznt-volcseed description: > 即梦 Volcseed 智能修图。Use when: 用户要按提示词改图、需提交参考图 URL 与轮询任务。 metadata: openclaw: primaryEnv: TS_TOKEN requires: env: - AIZNT_PROXY_URLS --- # 即梦 Volcseed (aiznt-volcseed) 通过天树 `ts_xxx` 与凭证中的 `aiznt_proxy_urls` 调用 **volcseededit** 提交与查询。 ## 配置 与 `aiznt-images` 等同类技能相同：`TS_TOKEN`、`AIZNT_PROXY_URLS`（JSON）。TsClaw **Skills** 页「同步天树凭证」会批量写入。 ## 命令 ```bash node scripts/volcseed.js submit --prompt "改成水彩风" --image-urls '["https://example.com/a.png"]' node scripts/volcseed.js fetch --task-id <task_id> ``` ## URL 键 - `volcseededit_submit` - `volcseededit_fetch`（`{task_id}`）

path: clawhub.json
content: {
  "name": "Volcseed",
  "tagline": "即梦 Volcseed 修图",
  "description": "Volcseed submit/fetch with TS_TOKEN and AIZNT_PROXY_URLS.",
  "category": "media",
  "tags": ["volcseed", "image", "tianshu"],
  "version": "1.0.0",
  "license": "MIT",
  "pricing": "free"
}


path: package.json
content: { "name": "aiznt-volcseed-skill", "private": true, "dependencies": {} }


path: scripts/client.js
content: /** 从环境变量读取 TS_TOKEN 与 AIZNT_PROXY_URLS */
function loadClient() {
  const [REDACTED_SECRET] || '').trim();
  if (!token) {
    throw new Error('缺少 TS_TOKEN（天树对话凭证 ts_xxx，对应 skills.entries 的 apiKey）');
  }
  const raw = process.env.AIZNT_PROXY_URLS;
  if (!raw || !String(raw).trim()) {
    throw new Error('缺少 AIZNT_PROXY_URLS（JSON 字符串，与 GET /miniapp/ai/chat/credentials 返回的 aiznt_proxy_urls 一致）');
  }
  let urls;
  try {
    urls = typeof raw === 'string' ? JSON.parse(raw) : raw;
  } catch {
    throw new Error('AIZNT_PROXY_URLS 不是合法 JSON');
  }
  if (!urls || typeof urls !== 'object') {
    throw new Error('AIZNT_PROXY_URLS 必须是对象');
  }
  return { token, urls };
}

function expandUrl(template, replacements = {}) {
  if (!template || typeof template !== 'string') {
    throw new Error('URL 模板无效');
  }
  let u = template;
  for (const [k, v] of Object.entries(replacements)) {
    u = u.split(`{${k}}`).join(String(v));
  }
  if (u.includes('{')) {
    throw new Error(`URL 仍有未替换占位符: ${u}`);
  }
  return u;
}

function authHeaders(token, extra = {}) {
  return {
    Authorization: `Bearer ${token}`,
    ...extra,
  };
}

async function fetchJson(url, options = {}) {
  const res = await fetch(url, options);
  const text = await res.text();
  let data;
  try {
    data = text ? JSON.parse(text) : {};
  } catch {
    throw new Error(`非 JSON 响应 (${res.status}): ${text.slice(0, 200)}`);
  }
  if (!res.ok) {
    const msg = data?.message || data?.error?.message || text.slice(0, 200);
    throw new Error(`HTTP ${res.status}: ${msg}`);
  }
  if (data.code !== undefined && data.code !== 0) {
    throw new Error(data.message || `业务错误 code=${data.code}`);
  }
  return data.data !== undefined ? data.data : data;
}

module.exports = {
  loadClient,
  expandUrl,
  authHeaders,
  fetchJson,
};


path: scripts/volcseed.js
content: #!/usr/bin/env node
const { loadClient, expandUrl, authHeaders, fetchJson } = require('./client.js');

function parseArgs(argv) {
  const args = argv.slice(2);
  const cmd = args[0];
  const rest = args.slice(1);
  const opts = { _: [] };
  for (let i = 0; i < rest.length; i++) {
    const a = rest[i];
    if (a.startsWith('--')) {
      const key = a.slice(2);
      const next = rest[i + 1];
      if (next !== undefined && !next.startsWith('--')) {
        opts[key] = next;
        i++;
      } else {
        opts[key] = true;
      }
    } else {
      opts._.push(a);
    }
  }
  return { cmd, opts };
}

function readJson(val, label) {
  if (!val) return undefined;
  try {
    return JSON.parse(val);
  } catch {
    throw new Error(`${label} 须为合法 JSON 字符串`);
  }
}

async function main() {
  const { cmd, opts } = parseArgs(process.argv);
  if (!cmd || cmd === 'help' || cmd === '-h') {
    console.log(`用法:
  submit --prompt "..." --image-urls '["https://..."]'
  fetch --task-id <id>`);
    process.exit(0);
  }
  const { token, urls } = loadClient();

  if (cmd === 'submit') {
    const prompt = opts.prompt;
    const imageUrls = readJson(opts['image-urls'], '--image-urls');
    if (!prompt || !Array.isArray(imageUrls)) {
      throw new Error('submit 需要 --prompt 与 --image-urls JSON 数组');
    }
    const url = urls.volcseededit_submit;
    if (!url) throw new Error('AIZNT_PROXY_URLS 缺少 volcseededit_submit');
    const data = await fetchJson(url, {
      method: 'POST',
      headers: authHeaders(token, { 'Content-Type': 'application/json' }),
      body: JSON.stringify({ prompt, image_urls: imageUrls }),
    });
    console.log(JSON.stringify(data, null, 2));
    return;
  }
  if (cmd === 'fetch') {
    const taskId = opts['task-id'];
    if (!taskId) throw new Error('需要 --task-id');
    const tpl = urls.volcseededit_fetch;
    if (!tpl) throw new Error('AIZNT_PROXY_URLS 缺少 volcseededit_fetch');
    const url = expandUrl(tpl, { task_id: taskId });
    const data = await fetchJson(url, { headers: authHeaders(token) });
    console.log(JSON.stringify(data, null, 2));
    return;
  }
  throw new Error(`未知命令: ${cmd}`);
}

main().catch((e) => {
  console.error('Error:', e.message);
  process.exit(1);
});


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: clean (LOW)