Add purpose-aware property assessor intake

This commit is contained in:
2026-03-27 23:01:12 -05:00
parent c58a2a43c8
commit 301986fb25
16 changed files with 841 additions and 70 deletions

View File

@@ -0,0 +1,66 @@
import { execFile } from "node:child_process";
import { promisify } from "node:util";
const execFileAsync = promisify(execFile);
export interface ListingDiscoveryResult {
attempts: string[];
zillowUrl: string | null;
harUrl: string | null;
}
function parseJsonOutput(raw: string, context: string): any {
const text = raw.trim();
if (!text) {
throw new Error(`${context} produced no JSON output.`);
}
return JSON.parse(text);
}
async function runDiscoveryScript(
scriptName: string,
address: string
): Promise<{ listingUrl: string | null; attempts: string[] }> {
const scriptPath = `/Users/stefano/.openclaw/workspace/skills/web-automation/scripts/${scriptName}`;
const { stdout } = await execFileAsync(process.execPath, [scriptPath, address], {
timeout: 120000,
maxBuffer: 2 * 1024 * 1024
});
const payload = parseJsonOutput(stdout, scriptName);
return {
listingUrl: typeof payload.listingUrl === "string" && payload.listingUrl.trim() ? payload.listingUrl.trim() : null,
attempts: Array.isArray(payload.attempts) ? payload.attempts.map(String) : []
};
}
export async function discoverListingSources(address: string): Promise<ListingDiscoveryResult> {
const attempts: string[] = [];
let zillowUrl: string | null = null;
let harUrl: string | null = null;
try {
const result = await runDiscoveryScript("zillow-discover.js", address);
zillowUrl = result.listingUrl;
attempts.push(...result.attempts);
} catch (error) {
attempts.push(
`Zillow discovery failed: ${error instanceof Error ? error.message : String(error)}`
);
}
try {
const result = await runDiscoveryScript("har-discover.js", address);
harUrl = result.listingUrl;
attempts.push(...result.attempts);
} catch (error) {
attempts.push(
`HAR discovery failed: ${error instanceof Error ? error.message : String(error)}`
);
}
return {
attempts,
zillowUrl,
harUrl
};
}