Skill: ai-hub-admin/generate-lego-3d-build-plan (version 1.0.5)

--- name: generate-lego-3D-build-plan description: Call Craftsman Agent API OneKey Router to generate a LEGO 3D step-by-step instruction build plan. env: DEEPNLP_ONEKEY_ROUTER_ACCESS: required: true description: OneKey Gateway API key (DEEPNLP_ONEKEY_ROUTER_ACCESS) --- # Generate LEGO 3D Build Plan Call Craftsman Agent API OneKey Router to generate a LEGO 3D step-by-step instruction build plan. ## Quick Start 1. Set your environment variable `DEEPNLP_ONEKEY_ROUTER_ACCESS`. 2. Use the CLI (primary suggested method) or the provided scripts. ## Usage ### 1. CLI (Recommended) #### CLI Illustration ```shell onekey agent <unique_id> <api_id> $JSON --timeout 30000 ``` - `<unique_id>`: the unique identifier of the onekey routed agents, "owner/repo". - `<api_id>`: refers to the unique endpoint name of API. - `$JSON`: the json string passed to cli. - `--timeout`: controlls the timeout of API calling, unit is mill seconds. #### Example ```bash export DEEPNLP_ONEKEY_ROUTER_ACCESS=YOUR_ACCESS_KEY onekey agent craftsman-agent/craftsman-agent generate_lego_build_plan '{"prompt":"Build Lego yacht with 5 decks using blue and white bricks","images":[],"mode":"basic"}' --timeout 30000 ``` ### 2. Python REST API ```bash python3 scripts/generate_lego_build_plan.py --prompt "pink lego phone" --mode basic ``` ### 3. TypeScript REST API ```bash node scripts/generate_lego_build_plan.ts --prompt "pink lego phone" --mode basic ``` ## Authentication Remember to set the environment variable: ```bash export DEEPNLP_ONEKEY_ROUTER_ACCESS=YOUR_ACCESS_KEY ``` Get your key at [DeepNLP Workspace](https://www.deepnlp.org/workspace/keys). ## Demo Result ```json {"success":true,"inventory_list":[{"color":"bright_blue","size":[1,1,1],"position":[4,0,0]},{"color":"bright_blue","size":[1,1,1],"position":[4,1,0]},{"color":"bright_blue","size":[1,1,1],"position":[4,2,0]},{"color":"bright_blue","size":[1,1,1],"position":[3,3,0]},{"color":"bright_blue","size":[1,1,1],"position":[4,3,0]},{"color":"bright_blue","size":[1,1,1],"position":[5,3,0]},{"color":"bright_blue","size":[1,1,1],"position":[3,4,0]},{"color":"bright_blue","size":[1,1,1],"position":[4,4,0]},{"color":"bright_blue","size":[1,1,1],"position":[5,4,0]},{"color":"bright_blue","size":[1,1,1],"position":[2,5,0]},{"color":"bright_blue","size":[1,1,1],"position":[3,5,0]},{"color":"bright_blue","size":[1,1,1],"position":[4,5,0]},{"color":"bright_blue","size":[1,1,1],"position":[5,5,0]},{"color":"bright_blue","size":[1,1,1],"position":[6,5,0]},{"color":"bright_blue","size":[1,1,1],"position":[2,6,0]},{"color":"bright_blue","size":[1,1,1],"position":[3,6,0]},{"color":"bright_blue","size":[1,1,1],"position":[4,6,0]},{"color":"bright_blue","size":[1,1,1],"position":[5,6,0]},{"color":"bright_blue","size":[1,1,1],"position":[6,6,0]},{"color":"bright_blue","size":[1,1,1],"position":[1,7,0]},{"color":"bright_blue","size":[1,1,1],"position":[2,7,0]},{"color":"bright_blue","size":[1,1,1],"position":[3,7,0]},{"color":"bright_blue","size":[1,1,1],"position":[4,7,0]},{"color":"bright_blue","size":[1,1,1],"position":[5,7,0]},{"color":"bright_blue","size":[1,1,1],"position":[6,7,0]},{"color":"bright_blue","size":[1,1,1],"position":[7,7,0]},{"color":"bright_blue","size":[1,1,1],"position":[1,8,0]},{"color":"bright_blue","size":[1,1,1],"position":[2,8,0]},{"color":"bright_blue","size":[1,1,1],"position":[3,8,0]},{"color":"bright_blue","size":[1,1,1],"position":[4,8,0]},{"color":"bright_blue","size":[1,1,1],"position":[5,8,0]},{"color":"bright_blue","size":[1,1,1],"position":[6,8,0]},{"color":"bright_blue","size":[1,1,1],"position":[7,8,0]},{"color":"bright_blue","size":[1,1,1],"position":[1,9,0]},{"color":"bright_blue","size":[1,1,1],"position":[2,9,0]},{"color":"bright_blue","size":[1,1,1],"position":[3,9,0]},{"color":"bright_blue","size":[1,1,1],"position":[4,9,0]},{"color":"bright_blue","size":[1,1,1],"position":[5,9,0]},{"color":"bright_blue","size":[1,1,1],"position":[6,9,0]},{"color":"bright_blue","size":[1,1,1],"position":[7,9,0]},{"color":"bright_blue","size":[1,1,1],"position":[1,10,0]},{"color":"bright_blue","size":[1,1,1],"position":[2,10,0]},{"color":"bright_blue","size":[1,1,1],"position":[3,10,0]},{"color":"bright_blue","size":[1,1,1],"position":[4,10,0]},{"color":"bright_blue","size":[1,1,1],"position":[5,10,0]},{"color":"bright_blue","size":[1,1,1],"position":[6,10,0]},{"color":"bright_blue","size":[1,1,1],"position":[7,10,0]},{"color":"bright_blue","size":[1,1,1],"position":[1,11,0]},{"color":"bright_blue","size":[1,1,1],"position":[2,11,0]},{"color":"bright_blue","size":[1,1,1],"position":[3,11,0]},{"color":"bright_blue","size":[1,1,1],"position":[4,11,0]},{"color":"bright_blue","size":[1,1,1],"position":[5,11,0]},{"color":"bright_blue","size":[1,1,1],"position":[6,11,0]},{"color":"bright_blue","size":[1,1,1],"position":[7,11,0]},{"color":"bright_blue","size":[1,1,1],"position":[2,12,0]},{"color":"bright_blue","size":[1,1,1],"position":[3,12,0]},{"color":"bright_blue","size":[1,1,1],"position":[4,12,0]},{"color":"bright_blue","size":[1,1,1],"position":[5,12,0]},{"color":"bright_blue","size":[1,1,1],"position":[6,12,0]},{"color":"bright_blue","size":[1,1,1],"position":[2,13,0]},{"color":"bright_blue","size":[1,1,1],"position":[3,13,0]},{"color":"bright_blue","size":[1,1,1],"position":[4,13,0]},{"color":"bright_blue","size":[1,1,1],"position":[5,13,0]},{"color":"bright_blue","size":[1,1,1],"position":[6,13,0]},{"color":"bright_blue","size":[1,1,1],"position":[3,14,0]},{"color":"bright_blue","size":[1,1,1],"position":[4,14,0]},{"color":"bright_blue","size":[1,1,1],"position":[5,14,0]},{"color":"bright_blue","size":[1,1,1],"position":[3,15,0]},{"color":"bright_blue","size":[1,1,1],"position":[4,15,0]},{"color":"bright_blue","size":[1,1,1],"position":[5,15,0]},{"color":"bright_blue","size":[1,1,1],"position":[4,16,0]},{"color":"bright_blue","size":[1,1,1],"position":[4,17,0]},{"color":"bright_red","size":[1,1,1],"position":[4,0,1]},{"color":"bright_red","size":[1,1,1],"position":[4,1,1]},{"color":"bright_red","size":[1,1,1],"position":[3,2,1]},{"color":"bright_red","size":[1,1,1],"position":[4,2,1]},{"color":"bright_red","size":[1,1,1],"position":[5,2,1]},{"color":"bright_red","size":[1,1,1],"position":[3,3,1]},{"color":"bright_red","size":[1,1,1],"position":[4,3,1]},{"color":"bright_red","size":[1,1,1],"position":[5,3,1]},{"color":"bright_red","size":[1,1,1],"position":[2,4,1]},{"color":"bright_red","size":[1,1,1],"position":[3,4,1]},{"color":"bright_red","size":[1,1,1],"position":[4,4,1]},{"color":"bright_red","size":[1,1,1],"position":[5,4,1]},{"color":"bright_red","size":[1,1,1],"position":[6,4,1]},{"color":"bright_red","size":[1,1,1],"position":[2,5,1]},{"color":"bright_red","size":[1,1,1],"position":[3,5,1]},{"color":"bright_red","size":[1,1,1],"position":[4,5,1]},{"color":"bright_red","size":[1,1,1],"position":[5,5,1]},{"color":"bright_red","size":[1,1,1],"position":[6,5,1]},{"color":"bright_red","size":[1,1,1],"position":[1,6,1]},{"color":"bright_red","size":[1,1,1],"position":[2,6,1]},{"color":"bright_red","size":[1,1,1],"position":[3,6,1]},{"color":"bright_red","size":[1,1,1],"position":[4,6,1]},{"color":"bright_red","size":[1,1,1],"position":[5,6,1]},{"color":"bright_red","size":[1,1,1],"position":[6,6,1]},{"color":"bright_red","size":[1,1,1],"position":[7,6,1]},{"color":"bright_red","size":[1,1,1],"position":[1,7,1]},{"color":"bright_red","size":[1,1,1],"position":[2,7,1]},{"color":"bright_red","size":[1,1,1],"position":[3,7,1]},{"color":"bright_red","size":[1,1,1],"position":[4,7,1]},{"color":"bright_red","size":[1,1,1],"position":[5,7,1]},{"color":"bright_red","size":[1,1,1],"position":[6,7,1]},{"color":"bright_red","size":[1,1,1],"position":[7,7,1]},{"color":"bright_red","size":[1,1,1],"position":[0,8,1]},{"color":"bright_red","size":[1,1,1],"position":[1,8,1]},{"color":"bright_red","size":[1,1,1],"position":[2,8,1]},{"color":"bright_red","size":[1,1,1],"position":[3,8,1]},{"color":"bright_red","size":[1,1,1],"position":[4,8,1]},{"color":"bright_red","size":[1,1,1],"position":[5,8,1]},{"color":"bright_red","size":[1,1,1],"position":[6,8,1]},{"color":"bright_red","size":[1,1,1],"position":[7,8,1]},{"color":"bright_red","size":[1,1,1],"position":[8,8,1]},{"color":"bright_red","size":[1,1,1],"position":[0,9,1]},{"color":"bright_red","size":[1,1,1],"position":[1,9,1]},{"color":"bright_red","size":[1,1,1],"position":[2,9,1]},{"color":"bright_red","size":[1,1,1],"position":[3,9,1]},{"color":"bright_red","size":[1,1,1],"position":[4,9,1]},{"color":"bright_red","size":[1,1,1],"position":[5,9,1]},{"color":"bright_red","size":[1,1,1],"position":[6,9,1]},{"color":"bright_red","size":[1,1,1],"position":[7,9,1]},{"color":"bright_red","size":[1,1,1],"position":[8,9,1]},{"color":"bright_red","size":[1,1,1],"position":[0,10,1]},{"color":"bright_red","size":[1,1,1],"position":[1,10,1]},{"color":"bright_red","size":[1,1,1],"position":[2,10,1]},{"color":"bright_red","size":[1,1,1],"position":[3,10,1]},{"color":"bright_red","size":[1,1,1],"position":[4,10,1]},{"color":"bright_red","size":[1,1,1],"position":[5,10,1]},{"color":"bright_red","size":[1,1,1],"position":[6,10,1]},{"color":"bright_red","size":[1,1,1],"position":[7,10,1]},{"color":"bright_red","size":[1,1,1],"position":[8,10,1]},{"color":"bright_red","size":[1,1,1],"position":[1,11,1]},{"color":"bright_red","size":[1,1,1],"position":[2,11,1]},{"color":"bright_red","size":[1,1,1],"position":[3,11,1]},{"color":"bright_red","size":[1,1,1],"position":[4,11,1]},{"color":"bright_red","size":[1,1,1],"position":[5,11,1]},{"color":"bright_red","size":[1,1,1],"position":[6,11,1]},{"color":"bright_red","size":[1,1,1],"position":[7,11,1]},{"color":"bright_red","size":[1,1,1],"position":[1,12,1]},{"color":"bright_red","size":[1,1,1],"position":[2,12,1]},{"color":"bright_red","size":[1,1,1],"position":[3,12,1]},{"color":"bright_red","size":[1,1,1],"position":[4,12,1]},{"color":"bright_red","size":[1,1,1],"position":[5,12,1]},{"color":"bright_red","size":[1,1,1],"position":[6,12,1]},{"color":"bright_red","size":[1,1,1],"position":[7,12,1]},{"color":"bright_red","size":[1,1,1],"position":[2,13,1]},{"color":"bright_red","size":[1,1,1],"position":[3,13,1]},{"color":"bright_red","size":[1,1,1],"position":[4,13,1]},{"color":"bright_red","size":[1,1,1],"position":[5,13,1]},{"color":"bright_red","size":[1,1,1],"position":[6,13,1]},{"color":"bright_red","size":[1,1,1],"position":[2,14,1]},{"color":"bright_red","size":[1,1,1],"position":[3,14,1]},{"color":"bright_red","size":[1,1,1],"position":[4,14,1]},{"color":"bright_red","size":[1,1,1],"position":[5,14,1]},{"color":"bright_red","size":[1,1,1],"position":[6,14,1]},{"color":"bright_red","size":[1,1,1],"position":[3,15,1]},{"color":"bright_red","size":[1,1,1],"position":[4,15,1]},{"color":"bright_red","size":[1,1,1],"position":[5,15,1]},{"color":"bright_red","size":[1,1,1],"position":[3,16,1]},{"color":"bright_red","size":[1,1,1],"position":[4,16,1]},{"color":"bright_red","size":[1,1,1],"position":[5,16,1]},{"color":"bright_red","size":[1,1,1],"position":[4,17,1]},{"color":"trans_blue","size":[1,1,1],"position":[3,4,2]},{"color":"trans_blue","size":[1,1,1],"position":[4,4,2]},{"color":"trans_blue","size":[1,1,1],"position":[5,4,2]},{"color":"trans_blue","size":[1,1,1],"position":[3,5,2]},{"color":"trans_blue","size":[1,1,1],"position":[4,5,2]},{"color":"trans_blue","size":[1,1,1],"position":[5,5,2]},{"color":"trans_blue","size":[1,1,1],"position":[3,6,2]},{"color":"trans_blue","size":[1,1,1],"position":[4,6,2]},{"color":"trans_blue","size":[1,1,1],"position":[5,6,2]},{"color":"trans_blue","size":[1,1,1],"position":[2,7,2]},{"color":"trans_blue","size":[1,1,1],"position":[3,7,2]},{"color":"trans_blue","size":[1,1,1],"position":[4,7,2]},{"color":"trans_blue","size":[1,1,1],"position":[5,7,2]},{"color":"trans_blue","size":[1,1,1],"position":[6,7,2]},{"color":"trans_blue","size":[1,1,1],"position":[2,8,2]},{"color":"trans_blue","size":[1,1,1],"position":[3,8,2]},{"color":"trans_blue","size":[1,1,1],"position":[4,8,2]},{"color":"trans_blue","size":[1,1,1],"position":[5,8,2]},{"color":"trans_blue","size":[1,1,1],"position":[6,8,2]},{"color":"trans_blue","size":[1,1,1],"position":[2,9,2]},{"color":"trans_blue","size":[1,1,1],"position":[3,9,2]},{"color":"trans_blue","size":[1,1,1],"position":[4,9,2]},{"color":"trans_blue","size":[1,1,1],"position":[5,9,2]},{"color":"trans_blue","size":[1,1,1],"position":[6,9,2]},{"color":"trans_blue","size":[1,1,1],"position":[2,10,2]},{"color":"trans_blue","size":[1,1,1],"position":[3,10,2]},{"color":"trans_blue","size":[1,1,1],"position":[4,10,2]},{"color":"trans_blue","size":[1,1,1],"position":[5,10,2]},{"color":"trans_blue","size":[1,1,1],"position":[6,10,2]},{"color":"trans_blue","size":[1,1,1],"position":[2,11,2]},{"color":"trans_blue","size":[1,1,1],"position":[3,11,2]},{"color":"trans_blue","size":[1,1,1],"position":[4,11,2]},{"color":"trans_blue","size":[1,1,1],"position":[5,11,2]},{"color":"trans_blue","size":[1,1,1],"position":[6,11,2]},{"color":"trans_blue","size":[1,1,1],"position":[3,12,2]},{"color":"trans_blue","size":[1,1,1],"position":[4,12,2]},{"color":"trans_blue","size":[1,1,1],"position":[5,12,2]},{"color":"trans_blue","size":[1,1,1],"position":[3,13,2]},{"color":"trans_blue","size":[1,1,1],"position":[4,13,2]},{"color":"trans_blue","size":[1,1,1],"position":[5,13,2]},{"color":"trans_blue","size":[1,1,1],"position":[2,5,3]},{"color":"trans_blue","size":[1,1,1],"position":[3,5,3]},{"color":"trans_blue","size":[1,1,1],"position":[4,5,3]},{"color":"trans_blue","size":[1,1,1],"position":[5,5,3]},{"color":"trans_blue","size":[1,1,1],"position":[6,5,3]},{"color":"trans_blue","size":[1,1,1],"position":[2,6,3]},{"color":"trans_blue","size":[1,1,1],"position":[3,6,3]},{"color":"trans_blue","size":[1,1,1],"position":[4,6,3]},{"color":"trans_blue","size":[1,1,1],"position":[5,6,3]},{"color":"trans_blue","size":[1,1,1],"position":[6,6,3]},{"color":"trans_blue","size":[1,1,1],"position":[2,7,3]},{"color":"trans_blue","size":[1,1,1],"position":[3,7,3]},{"color":"trans_blue","size":[1,1,1],"position":[4,7,3]},{"color":"trans_blue","size":[1,1,1],"position":[5,7,3]},{"color":"trans_blue","size":[1,1,1],"position":[6,7,3]},{"color":"trans_blue","size":[1,1,1],"position":[2,8,3]},{"color":"trans_blue","size":[1,1,1],"position":[3,8,3]},{"color":"trans_blue","size":[1,1,1],"position":[4,8,3]},{"color":"trans_blue","size":[1,1,1],"position":[5,8,3]},{"color":"trans_blue","size":[1,1,1],"position":[6,8,3]},{"color":"trans_blue","size":[1,1,1],"position":[2,9,3]},{"color":"trans_blue","size":[1,1,1],"position":[3,9,3]},{"color":"trans_blue","size":[1,1,1],"position":[4,9,3]},{"color":"trans_blue","size":[1,1,1],"position":[5,9,3]},{"color":"trans_blue","size":[1,1,1],"position":[6,9,3]},{"color":"trans_blue","size":[1,1,1],"position":[2,10,3]},{"color":"trans_blue","size":[1,1,1],"position":[3,10,3]},{"color":"trans_blue","size":[1,1,1],"position":[4,10,3]},{"color":"trans_blue","size":[1,1,1],"position":[5,10,3]},{"color":"trans_blue","size":[1,1,1],"position":[6,10,3]},{"color":"trans_blue","size":[1,1,1],"position":[2,11,3]},{"color":"trans_blue","size":[1,1,1],"position":[3,11,3]},{"color":"trans_blue","size":[1,1,1],"position":[4,11,3]},{"color":"trans_blue","size":[1,1,1],"position":[5,11,3]},{"color":"trans_blue","size":[1,1,1],"position":[6,11,3]},{"color":"trans_blue","size":[1,1,1],"position":[3,8,4]},{"color":"trans_blue","size":[1,1,1],"position":[4,8,4]},{"color":"trans_blue","size":[1,1,1],"position":[5,8,4]},{"color":"trans_blue","size":[1,1,1],"position":[3,9,4]},{"color":"trans_blue","size":[1,1,1],"position":[4,9,4]},{"color":"trans_blue","size":[1,1,1],"position":[5,9,4]},{"color":"trans_blue","size":[1,1,1],"position":[3,10,4]},{"color":"trans_blue","size":[1,1,1],"position":[4,10,4]},{"color":"trans_blue","size":[1,1,1],"position":[5,10,4]},{"color":"white","size":[0.2,0.2,2],"position":[4,9,5]}],"overall_image":{"iso":"https://craftsman-agent.aiagenta2z.com/craftsman-agent/static/TEMP_c0b498a3/lego_plan/view_iso.png","top":"https://craftsman-agent.aiagenta2z.com/craftsman-agent/static/TEMP_c0b498a3/lego_plan/view_top.png","front":"https://craftsman-agent.aiagenta2z.com/craftsman-agent/static/TEMP_c0b498a3/lego_plan/view_front.png","side":"https://craftsman-agent.aiagenta2z.com/craftsman-agent/static/TEMP_c0b498a3/lego_plan/view_side.png"},"inventory_image":{"inventory_parts":"https://craftsman-agent.aiagenta2z.com/craftsman-agent/static/TEMP_c0b498a3/lego_plan/inventory_parts.png","description":["Color bright_red, Size 1 x 1 x 1, Quantity 90","Color trans_blue, Size 1 x 1 x 1, Quantity 84","Color bright_blue, Size 1 x 1 x 1, Quantity 72","Color white, Size 0 x 0 x 2, Quantity 1"]},"assembly_step_image":{"0":"https://craftsman-agent.aiagenta2z.com/craftsman-agent/static/TEMP_c0b498a3/lego_plan/step_0.png","1":"https://craftsman-agent.aiagenta2z.com/craftsman-agent/static/TEMP_c0b498a3/lego_plan/step_1.png","2":"https://craftsman-agent.aiagenta2z.com/craftsman-agent/static/TEMP_c0b498a3/lego_plan/step_2.png","3":"https://craftsman-agent.aiagenta2z.com/craftsman-agent/static/TEMP_c0b498a3/lego_plan/step_3.png","4":"https://craftsman-agent.aiagenta2z.com/craftsman-agent/static/TEMP_c0b498a3/lego_plan/step_4.png","5":"https://craftsman-agent.aiagenta2z.com/craftsman-agent/static/TEMP_c0b498a3/lego_plan/step_5.png","6":"https://craftsman-agent.aiagenta2z.com/craftsman-agent/static/TEMP_c0b498a3/lego_plan/step_6.png","7":"https://craftsman-agent.aiagenta2z.com/craftsman-agent/static/TEMP_c0b498a3/lego_plan/step_7.png","8":"https://craftsman-agent.aiagenta2z.com/craftsman-agent/static/TEMP_c0b498a3/lego_plan/step_8.png","9":"https://craftsman-agent.aiagenta2z.com/craftsman-agent/static/TEMP_c0b498a3/lego_plan/step_9.png"}} ```

path: scripts/generate_lego_build_plan.ts
content: #!/usr/bin/env node

const ENDPOINT = "https://agent.deepnlp.org/agent_router";
const UNIQUE_ID = "craftsman-agent/craftsman-agent";
const API_ID = "generate_lego_build_plan";
const ENV_KEY = "DEEPNLP_ONEKEY_ROUTER_ACCESS";
const ONEKEY_HEADER = "X-OneKey";

function validateImageUrls(urls: string[]) {
  for (const url of urls) {
    try {
      const parsed = new URL(url);
      if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
        throw new Error(`Invalid ref image URL scheme: ${url}`);
      }
    } catch (err) {
      throw new Error(`Invalid ref image URL: ${url}`);
    }
  }
}

function parseArgs(argv: string[]) {
  const args: Record<string, string | string[]> = {};
  for (let i = 0; i < argv.length; i += 1) {
    const [REDACTED_SECRET];
    if (token === "--prompt" || token === "--mode" || token === "--images") {
      const value = argv[i + 1];
      i += 1;
      if (token === "--images") {
        const list = (args[token] as string[]) || [];
        list.push(value);
        args[token] = list;
      } else {
        args[token] = value;
      }
    }
  }

  return {
    prompt: (args["--prompt"] as string) || "",
    mode: (args["--mode"] as string) || "basic",
    images: (args["--images"] as string[]) || [],
  };
}

async function main() {
  const { prompt, mode, images } = parseArgs(process.argv.slice(2));
  if (!prompt) {
    console.error("Missing --prompt");
    process.exit(1);
  }

  let [REDACTED_SECRET];
  if (!apiKey) {
    console.error("DEEPNLP_ONEKEY_ROUTER_ACCESS is not set. Set it before running.");
    console.error("Set with: export DEEPNLP_ONEKEY_ROUTER_ACCESS=YOUR_API_KEY");
    apiKey = "";
  }

  const url = new URL(ENDPOINT);
  validateImageUrls(images);

  const payload = {
    unique_id: UNIQUE_ID,
    api_id: API_ID,
    data: {
      prompt: prompt,
      images: images,
      mode,
    },
  };

  const response = await fetch(url.toString(), {
    method: "POST",
    headers: { "Content-Type": "application/json", [ONEKEY_HEADER]: apiKey },
    body: JSON.stringify(payload),
  });

  const text = await response.text();
  if (!response.ok) {
    console.error(`HTTP ${response.status}: ${text}`);
    process.exit(1);
  }

  try {
    const json = JSON.parse(text);
    console.log(JSON.stringify(json, null, 2));
  } catch {
    console.log(text);
  }
}

main().catch((err) => {
  console.error(err);
  process.exit(1);
});


path: scripts/generate_lego_build_plan.py
content: #!/usr/bin/env python3
"""Call Craftsman Agent OneKey Router to generate a LEGO build plan."""

import argparse
import json
import os
import sys
from urllib import request, parse, error

ENDPOINT = "https://agent.deepnlp.org/agent_router"
UNIQUE_ID = "craftsman-agent/craftsman-agent"
API_ID = "generate_lego_build_plan"
ENV_KEY = "DEEPNLP_ONEKEY_ROUTER_ACCESS"
ONEKEY_HEADER = "X-OneKey"


def die_missing_key():
    sys.stderr.write(
        "DEEPNLP_ONEKEY_ROUTER_ACCESS is not set. "
        "Set it before running this script.\n"
    )
    sys.stderr.write("Set with: export DEEPNLP_ONEKEY_ROUTER_ACCESS=YOUR_API_KEY\n")
    return

def validate_image_urls(urls):
    for url in urls:
        parsed = parse.urlparse(url)
        if parsed.scheme not in ("http", "https"):
            raise ValueError(f"Invalid ref image URL scheme: {url}")

def build_payload(prompt, images, mode):
    return {
        "unique_id": UNIQUE_ID,
        "api_id": API_ID,
        "data": {
            "prompt": prompt,
            "images": images,
            "mode": mode,
        },
    }


def post_json(url, payload, api_key):
    data = json.dumps(payload).encode("utf-8")
    req = request.Request(
        url,
        data=data,
        headers={"Content-Type": "application/json", ONEKEY_HEADER: api_key},
        method="POST",
    )
    with request.urlopen(req, timeout=60) as resp:
        body = resp.read().decode("utf-8")
        return resp.status, body


def main():
    parser = argparse.ArgumentParser(description="Generate LEGO build plan via Craftsman Agent")
    parser.add_argument("--prompt", required=True, help="Text prompt for the build")
    parser.add_argument(
        "--images",
        action="append",
        default=[],
        help="Reference image URL (repeatable)",
    )
    parser.add_argument("--mode", default="basic", help="demo|basic|standard|advanced")
    args = parser.parse_args()

    [REDACTED_SECRET])
    if not [REDACTED_SECRET])
        api_key = ""

    url = ENDPOINT
    try:
        validate_image_urls(args.images)
    except ValueError as exc:
        sys.stderr.write(f"{exc}\n")
        sys.exit(2)

    payload = build_payload(args.prompt, args.images, args.mode)

    try:
        status, body = post_json(url, payload, api_key)
    except error.HTTPError as e:
        error_body = e.read().decode("utf-8") if e.fp else ""
        sys.stderr.write(f"HTTP {e.code}: {error_body}\n")
        sys.exit(1)
    except error.URLError as e:
        sys.stderr.write(f"Network error: {e.reason}\n")
        sys.exit(1)

    try:
        parsed = json.loads(body)
        print(json.dumps(parsed, indent=2))
    except json.JSONDecodeError:
        print(body)


if __name__ == "__main__":
    main()


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