client-finder/scripts/async-run.ts

41 lines
1.4 KiB
TypeScript

#!/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 "<query>" "<country>" "<client_key>"
*/
import { $ } from "bun";
const [,, query, country, clientKey] = process.argv;
if (!query || !clientKey) {
console.error("Usage: bun run async-run.ts <query> <country> <client_key>");
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.");