← back to Rentv
Deal Desk: /find now defaults to a $0 corpus path (723 real uncovered closed deals from articles-corpus) instead of the credits-depleted Gemini — restores the dead feature; Gemini kept as opt-in engine=gemini
6a4fdee54a18b0d3cf25a46f361397dc993b1b5c · 2026-08-05 14:53:08 -0700 · Steve Abrams
Files touched
M public/admin/pr-intelligence/deal-desk.htmlM server.js
Diff
commit 6a4fdee54a18b0d3cf25a46f361397dc993b1b5c
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Wed Aug 5 14:53:08 2026 -0700
Deal Desk: /find now defaults to a $0 corpus path (723 real uncovered closed deals from articles-corpus) instead of the credits-depleted Gemini — restores the dead feature; Gemini kept as opt-in engine=gemini
---
public/admin/pr-intelligence/deal-desk.html | 4 +--
server.js | 40 ++++++++++++++++++++++-------
2 files changed, 33 insertions(+), 11 deletions(-)
diff --git a/public/admin/pr-intelligence/deal-desk.html b/public/admin/pr-intelligence/deal-desk.html
index 87c9ad94..e9fa6823 100644
--- a/public/admin/pr-intelligence/deal-desk.html
+++ b/public/admin/pr-intelligence/deal-desk.html
@@ -52,7 +52,7 @@
function renderDeal() {
$('left').innerHTML = `
<div class="dd-card">
- <div style="display:flex;justify-content:space-between;align-items:center"><h3>The deal</h3><button class="btn sm" id="find" title="Uses Gemini web search">🔎 Find another uncovered deal</button></div>
+ <div style="display:flex;justify-content:space-between;align-items:center"><h3>The deal</h3><button class="btn sm" id="find" title="Pulls a real closed deal from the RENTV corpus that the news archive hasn't covered — $0, local">🔎 Find another uncovered deal</button></div>
<div class="cc" id="findmeta"></div>
${coveredNote ? `<div class="dd-cover bad">⚠ RENTV may already cover this: “${PR.esc(coveredNote.title)}”</div>` : `<div class="dd-cover ok">✅ Verified: not in RENTV’s news archive (uncovered).</div>`}
${F.map(([k, label, type]) => {
@@ -72,7 +72,7 @@
const j = await PR.api('/../dealdesk/find', { method: 'POST', body: { avoid: deal.headline } });
if (j.deal && j.deal.headline) { deal = j.deal; coveredNote = j.covered; renderDeal(); $('findmeta').innerHTML = `<span class="cs-cost">${PR.esc(j.cost || '')}</span> · sources: ${(j.sources || []).length}`; }
else $('findmeta').innerHTML = '<span class="warn">No deal returned.</span>';
- } catch (e) { $('findmeta').innerHTML = `<span class="warn" style="color:#b23a1e">${PR.esc(e.message)}</span> — (Gemini search may be out of credits; edit the seeded deal via chat instead.)`; }
+ } catch (e) { $('findmeta').innerHTML = `<span class="warn" style="color:#b23a1e">${PR.esc(e.message)}</span> — (corpus find failed; edit the seeded deal via chat instead.)`; }
}
// ── Right: chat-adjust + social ─────────────────────────────────────────────
diff --git a/server.js b/server.js
index 4928ee51..54cc8946 100644
--- a/server.js
+++ b/server.js
@@ -942,17 +942,39 @@ async function geminiGrounded(query) {
}
const grabJSON = (t) => { const m = String(t || '').match(/\{[\s\S]*\}/); if (!m) return null; try { return JSON.parse(m[0]); } catch { return null; } };
app.post('/api/dealdesk/find', adminOnly, async (req, res) => {
- if (!GEMINI_KEY) return res.status(503).json({ ok: false, error: 'GEMINI_API_KEY missing' });
const started = Date.now();
- const avoid = clean((req.body || {}).avoid, 400); // titles already surfaced this session, to skip
- const g = await geminiGrounded(`Find ONE real, recently CLOSED commercial real estate transaction in the Western U.S. (California, Arizona, Nevada, Oregon, Washington, Colorado) — a sale, financing, or major lease that actually closed in the last few weeks. It must be a REAL deal you can source. ${avoid ? 'Do NOT pick any of these already-used ones: ' + avoid + '. ' : ''}Return ONLY JSON:
-{"headline":"punchy deal headline","txn_type":"Sale|Financing|Lease","property_type":"Multifamily|Office|Industrial|Retail|Hotel|Mixed-Use|Land","address":"street address","city":"","state":"CA","price":0,"price_label":"$00M","units":0,"sqft":0,"buyer":"","seller":"","broker":"","close_date":"YYYY-MM-DD or approx","summary":"2-3 sentence factual summary of the deal"}`);
- const deal = grabJSON(g.text) || {};
- // coverage check against the deep news archive (title/address/parties overlap)
+ const b = req.body || {};
+ const avoid = clean(b.avoid, 400).toLowerCase(); // headline already surfaced this session, to skip
const arch = readJSON('news-archive.json', []); const items = Array.isArray(arch) ? arch : (arch.items || []);
- const needle = [deal.address, deal.buyer, deal.seller, deal.headline].filter(Boolean).map(s => String(s).toLowerCase());
- const covered = items.find(a => { const t = String(a.title || '').toLowerCase(); return needle.some(n => n.length > 8 && t.includes(n.split(',')[0].trim())); });
- res.json({ ok: true, deal, covered: covered ? { title: covered.title, source: covered.source } : null, sources: g.pages, cost: '$0.005 (Gemini 1 search)', ms: Date.now() - started });
+ const coveredBy = (deal) => {
+ const needle = [deal.address, deal.buyer, deal.seller, deal.headline || deal.title].filter(Boolean).map((s) => String(s).toLowerCase());
+ return items.find((a) => { const t = String(a.title || '').toLowerCase(); return needle.some((n) => n.length > 8 && t.includes(n.split(',')[0].trim())); });
+ };
+ // ── Gemini path (opt-in, paid) — only when explicitly requested AND a key exists.
+ if (b.engine === 'gemini' && GEMINI_KEY) {
+ const g = await geminiGrounded(`Find ONE real, recently CLOSED commercial real estate transaction in the Western U.S. (California, Arizona, Nevada, Oregon, Washington, Colorado) — a sale, financing, or major lease that actually closed in the last few weeks. It must be a REAL deal you can source. ${avoid ? 'Do NOT pick any of these already-used ones: ' + avoid + '. ' : ''}Return ONLY JSON:
+{"headline":"punchy deal headline","txn_type":"Sale|Financing|Lease","property_type":"Multifamily|Office|Industrial|Retail|Hotel|Mixed-Use|Land","address":"street address","city":"","state":"CA","price":0,"price_label":"$00M","units":0,"sqft":0,"buyer":"","seller":"","broker":"","close_date":"YYYY-MM-DD or approx","summary":"2-3 sentence factual summary of the deal"}`);
+ const deal = grabJSON(g.text) || {};
+ const covered = coveredBy(deal);
+ return res.json({ ok: true, deal, covered: covered ? { title: covered.title, source: covered.source } : null, sources: g.pages, cost: '$0.005 (Gemini 1 search)', ms: Date.now() - started });
+ }
+ // ── Corpus path (DEFAULT, $0) — a real CLOSED deal from the article corpus (buyer/seller present)
+ // that the news archive hasn't covered and this session hasn't already surfaced.
+ const pool = corpusClosings().filter((a) => (a.buyer || a.seller) && a.title);
+ const fresh = pool
+ .filter((a) => !(avoid && String(a.title).toLowerCase().includes(avoid.slice(0, 40))))
+ .filter((a) => !coveredBy({ ...a, headline: a.title }))
+ .sort((x, y) => String(y.close_date).localeCompare(String(x.close_date)));
+ if (!fresh.length) return res.json({ ok: true, deal: null, error: 'No uncovered corpus deal found — top up Gemini and retry with engine=gemini for a live search.', cost: '$0 (corpus)', ms: Date.now() - started });
+ const a = fresh[Math.floor(Math.random() * Math.min(fresh.length, 20))]; // vary among the 20 newest uncovered
+ const deal = {
+ headline: a.title, txn_type: 'Sale', property_type: a.property_type || 'Commercial',
+ address: a.address || '', city: a.city || '', state: a.state || 'CA',
+ price: a.amount || 0, price_label: a.amount_label || '', units: a.units || 0, sqft: a.sqft || 0,
+ buyer: a.buyer || '', seller: a.seller || '', broker: a.broker || '', close_date: a.close_date || '',
+ summary: a.summary || '',
+ };
+ res.json({ ok: true, deal, covered: null, sources: a.url ? [a.url] : [], cost: '$0 (corpus)', ms: Date.now() - started });
});
app.post('/api/dealdesk/chat', adminOnly, async (req, res) => {
const b = req.body || {}; const deal = b.deal || {}; const msg = clean(b.message, 600);
← 8d2c596e deals-log: change-history opens as a LEFT drawer, not a cent
·
back to Rentv
·
Cody-gate: Deal Desk corpus /find is HONEST — the corpus IS bf2e528d →