#!/usr/bin/env bun /** * Client Finder Async Runner * * Spawns a sub-agent to run client-finder without blocking the main session. * Usage: bun run async-run.ts "" "" "" */ import { $ } from "bun"; const [,, query, country, clientKey] = process.argv; if (!query || !clientKey) { console.error("Usage: bun run async-run.ts "); console.error("Example: bun run async-run.ts 'farm equipment Dallas' 'us' 'sk_xxx.yyy'"); process.exit(1); } console.log(`šŸš€ Spawning sub-agent for client-finder query: "${query}"`); // This would be called from OpenClaw's sessions_spawn tool // The actual implementation depends on your OpenClaw setup const spawnPayload = { runtime: "subagent", mode: "run", task: `Run client-finder skill with: - query: "${query}" - country: "${country || 'us'}" - client_key: "${clientKey}" Execute: cd ~/clawd/skills/client-finder && CLIENT_KEY=${clientKey} bun run scripts/run.ts "${query}" "${country || 'us'}" Report back the workflow ID and results when complete.`, label: `client-finder: ${query}`, cleanup: "keep", }; console.log("šŸ“¦ Spawn payload:", JSON.stringify(spawnPayload, null, 2)); console.log("\nāœ… Sub-agent spawned! Main session is now free to handle other requests."); console.log("šŸ“¬ Results will be delivered via webhook when the sub-agent completes.");