File size: 6,857 Bytes
1aa2044 fdd11fb 1aa2044 fdd11fb 1aa2044 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | #!/bin/bash
# 1. Menyiapkan folder untuk Skill AI
mkdir -p $HOME/.openclaw/workspace/skills/image_generator
# 2. Merakit file openclaw.json secara dinamis (Menggunakan Secrets HF agar aman)
cat << EOF > $HOME/.openclaw/openclaw.json
{
"gateway": {
"mode": "local",
"auth": {
"mode": "token",
"token": "${GATEWAY_TOKEN}"
}
},
"browser": {
"enabled": true,
"executablePath": "/usr/bin/chromium",
"headless": true,
"noSandbox": true
},
"channels": {
"telegram": {
"enabled": true,
"dmPolicy": "open",
"botToken": "${TELEGRAM_BOT_TOKEN}",
"allowFrom": ["*"],
"groupPolicy": "allowlist",
"streaming": "partial"
}
},
"models": {
"providers": {
"openai": {
"baseUrl": "https://integrate.api.nvidia.com/v1",
"apiKey": "${NVIDIA_API_KEY}",
"models": [
{
"id": "openai/gpt-oss-20b",
"name": "NVIDIA GPT OSS"
}
]
},
"openrouter": {
"baseUrl": "https://openrouter.ai/api/v1",
"apiKey": "${OPENROUTER_API_KEY}",
"models": [
{
"id": "qwen/qwen3.6-plus:free",
"name": "Qwen 3.6 Plus"
},
{
"id": "nvidia/nemotron-nano-12b-v2-vl:free",
"name": "Nemotron Vision"
},
{
"id": "stepfun/step-3.5-flash:free",
"name": "Step-3.5-Flash"
}
]
}
}
},
"plugins": {
"entries": {
"tavily": {
"enabled": true,
"config": {
"webSearch": {
"apiKey": "${TAVILY_API_KEY}"
}
}
}
}
},
"tools": {
"web": {
"search": {
"provider": "tavily"
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "openrouter/qwen/qwen3.6-plus:free",
"fallbacks": [
"openai/openai/gpt-oss-20b"
]
},
"imageModel": {
"primary": "openrouter/nvidia/nemotron-nano-12b-v2-vl:free"
}
}
},
"commands": {
"native": "auto",
"nativeSkills": "auto",
"restart": true,
"ownerDisplay": "raw"
},
"meta": {
"lastTouchedVersion": "2026.3.28"
}
}
EOF
# 3. Merakit script generate_image.js (Menyesuaikan output ke photo.png)
cat << 'EOF' > $HOME/.openclaw/workspace/generate_image.js
import fs from "fs";
const apiKey = process.env.NVIDIA_API_KEY;
if (!apiKey) process.exit(1);
function readInput() {
return new Promise((resolve) => {
let data = "";
process.stdin.on("data", (chunk) => { data += chunk; });
process.stdin.on("end", () => { resolve(data.trim()); });
});
}
const invokeUrl = "https://ai.api.nvidia.com/v1/genai/stabilityai/stable-diffusion-3-medium";
// Nama file disesuaikan ke photo.png sesuai instruksi terbarumu
const outputPath = process.env.HOME + "/.openclaw/workspace/photo.png";
async function main() {
let userPrompt = await readInput();
let finalPrompt = userPrompt;
try {
const parsedJSON = JSON.parse(userPrompt);
finalPrompt = Object.values(parsedJSON)[0] || userPrompt;
} catch (e) {}
if (!finalPrompt) finalPrompt = "beautiful landscape";
const payload = {
"prompt": `${finalPrompt}\n`,
"cfg_scale": 5,
"aspect_ratio": "16:9",
"seed": 0,
"steps": 50,
"negative_prompt": "buruk, jelek, cacat, buram"
};
try {
let response = await fetch(invokeUrl, {
method: "post",
body: JSON.stringify(payload),
headers: { "Content-Type": "application/json", "Authorization": `Bearer ${apiKey}`, "Accept": "application/json" }
});
let response_body = await response.json();
let base64Image = response_body.image || (response_body.artifacts && response_body.artifacts[0].base64);
if (base64Image) {
fs.writeFileSync(outputPath, base64Image, 'base64');
console.log(`SUKSES: ${outputPath}`);
}
} catch (error) {
console.error("Error:", error);
}
}
main();
EOF
# 4. Merakit file SKILL.md (Menggunakan langkah mutlak dan path dinamis HF)
cat << EOF > $HOME/.openclaw/workspace/skills/image_generator/SKILL.md
---
name: custom_image_generator
description: Alat khusus untuk membuat atau melukis gambar (image generation).
---
# Image Generator Skill
Ketika pengguna meminta untuk dibuatkan gambar, lukisan, atau foto, kamu WAJIB mengeksekusi script generator.
**Langkah mutlak:**
1. Terjemahkan permintaan ke prompt bahasa Inggris.
2. Eksekusi perintah terminal ini dengan tool exec:
\`echo '{"prompt": "PROMPT_INGGRIS"}' | node $HOME/.openclaw/workspace/generate_image.js\`
3. Setelah sukses, kirim gambar sebagai attachment Telegram, bukan Markdown image.
Gunakan message send dengan media file:
`openclaw message send --channel telegram --target <TARGET> --media $HOME/.openclaw/workspace/photo.png --force-document`
EOF
# 4.5 Tambahin script screenshot viewport (ANTI FULL PAGE)
cat << 'EOF' > $HOME/.openclaw/workspace/screenshot_viewport.sh
#!/bin/bash
URL="$1"
OUT="$2"
if [ -z "$URL" ]; then
echo "URL kosong!"
exit 1
fi
if [ -z "$OUT" ]; then
OUT="$HOME/.openclaw/workspace/screenshot.png"
fi
chromium \
--headless \
--no-sandbox \
--disable-gpu \
--disable-dev-shm-usage \
--window-size=1280,720 \
--screenshot="$OUT" \
"$URL"
echo "SUKSES: $OUT"
EOF
chmod +x $HOME/.openclaw/workspace/screenshot_viewport.sh
mkdir -p $HOME/.openclaw/workspace/skills/web_screenshot
cat << EOF > $HOME/.openclaw/workspace/skills/web_screenshot/SKILL.md
---
name: web_screenshot_viewport
description: Ambil screenshot website hanya viewport (bukan full page).
---
# Web Screenshot Viewport
Jika user meminta screenshot website:
1. Ambil URL dari user atau cari dulu URL yang valid
2. Jalankan perintah ini:
\`$HOME/.openclaw/workspace/screenshot_viewport.sh "URL" "$HOME/.openclaw/workspace/screenshot.png"\`
3. Kirim hasilnya:
Gunakan message send dengan media file:
`openclaw message send --channel telegram --target <TARGET> --media $HOME/.openclaw/workspace/photo.png --force-document`

EOF
# 5. Trik Anti-Nganggur (Dummy Web Server agar HF tetap hijau)
cat << 'EOF' > $HOME/server.js
import http from 'http';
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('OpenClaw Bot sedang aktif melayanimu di Telegram!\n');
});
// HF butuh listen di 0.0.0.0 agar status berubah jadi Running
server.listen(7860, '0.0.0.0', () => {
console.log('Web server pancingan untuk port 7860 sudah menyala.');
});
EOF
node $HOME/server.js &
# 6. Bangunkan si Lobster!
echo "Menyalakan OpenClaw Gateway..."
openclaw gateway |