yirlo 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/dash.js +153 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -16,6 +16,20 @@ const hot = await y.listHotLeads();
|
|
|
16
16
|
|
|
17
17
|
Errors throw `YirloError` with `status` and `body`.
|
|
18
18
|
|
|
19
|
+
## Dashboard in your terminal
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
YIRLO_API_KEY=yk_live_... npx yirlo dash
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
One screen per project: replies that need you, hot leads, emails sent in the last 7 days, the running campaigns and the latest replies. `--watch` redraws it every minute, `--project acme.com` shows one project, `--plain` drops the colors.
|
|
26
|
+
|
|
27
|
+
Several accounts, or only some projects: put them in `~/.yirlo/dash.json`
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{ "accounts": [ { "name": "Main", "key": "yk_live_...", "projects": ["acme.com"] } ] }
|
|
31
|
+
```
|
|
32
|
+
|
|
19
33
|
## MCP server
|
|
20
34
|
|
|
21
35
|
Remote (recommended): add `https://yirlo.com/mcp` with the header `Authorization: Bearer <YIRLO_API_KEY>`.
|
package/dash.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// yirlo dash: your outreach at a glance, in the terminal. Read-only: it only reads your account through the Yirlo API.
|
|
3
|
+
// npx yirlo dash (YIRLO_API_KEY=yk_live_... in the environment, or a config file, below)
|
|
4
|
+
// npx yirlo dash --watch (redraws every 60 s; --watch 30 for 30 s)
|
|
5
|
+
// npx yirlo dash --project scrapercity.com --plain
|
|
6
|
+
// Config, for several accounts or only some projects: ~/.yirlo/dash.json (or YIRLO_DASH_CONFIG=<file>)
|
|
7
|
+
// { "accounts": [ { "name": "Main", "key": "yk_live_...", "projects": ["scrapercity.com", "yirlo.com"] } ] }
|
|
8
|
+
// "projects" is optional (all of them when left out). Times are your computer's time zone (TZ=America/Chicago for another).
|
|
9
|
+
import fs from "node:fs";
|
|
10
|
+
import os from "node:os";
|
|
11
|
+
import path from "node:path";
|
|
12
|
+
import { Yirlo } from "./yirlo.js";
|
|
13
|
+
|
|
14
|
+
const argv = process.argv.slice(2).filter(a => a !== "dash");
|
|
15
|
+
const flag = n => argv.includes(`--${n}`);
|
|
16
|
+
const opt = n => { const i = argv.indexOf(`--${n}`); return i >= 0 && argv[i + 1] && !argv[i + 1].startsWith("--") ? argv[i + 1] : null; };
|
|
17
|
+
if (flag("help") || flag("h")) {
|
|
18
|
+
console.log(`yirlo dash: your Yirlo outreach at a glance.
|
|
19
|
+
|
|
20
|
+
npx yirlo dash one screen, then exit
|
|
21
|
+
npx yirlo dash --watch [sec] redraw every 60 s (or every sec)
|
|
22
|
+
npx yirlo dash --project <domain> only that project
|
|
23
|
+
npx yirlo dash --plain no colors
|
|
24
|
+
|
|
25
|
+
Key: YIRLO_API_KEY=yk_live_... (https://yirlo.com/app/api-keys), or ~/.yirlo/dash.json:
|
|
26
|
+
{ "accounts": [ { "name": "Main", "key": "yk_live_...", "projects": ["acme.com"] } ] }`);
|
|
27
|
+
process.exit(0);
|
|
28
|
+
}
|
|
29
|
+
const PLAIN = flag("plain") || !!process.env.NO_COLOR || !process.stdout.isTTY && !flag("color");
|
|
30
|
+
const BASE = process.env.YIRLO_BASE_URL || "https://yirlo.com";
|
|
31
|
+
const HOME = path.join(os.homedir(), ".yirlo");
|
|
32
|
+
const CONF = process.env.YIRLO_DASH_CONFIG || path.join(HOME, "dash.json");
|
|
33
|
+
const SEEN = path.join(HOME, "dash-seen.json");
|
|
34
|
+
|
|
35
|
+
function accounts() {
|
|
36
|
+
let c = null;
|
|
37
|
+
try { c = JSON.parse(fs.readFileSync(CONF, "utf8")); } catch (e) { if (fs.existsSync(CONF)) { console.error(`Could not read ${CONF}: ${e.message}`); process.exit(1); } }
|
|
38
|
+
let list = (c && c.accounts) || [];
|
|
39
|
+
if (!list.length && process.env.YIRLO_API_KEY) list = [{ name: "", key: process.env.YIRLO_API_KEY }];
|
|
40
|
+
if (!list.length) { console.error("No API key. Get one at https://yirlo.com/app/api-keys, then: YIRLO_API_KEY=yk_live_... npx yirlo dash"); process.exit(1); }
|
|
41
|
+
const only = opt("project");
|
|
42
|
+
return list.map(a => ({ ...a, projects: only ? [only] : a.projects }));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ---------- drawing (color for state only; one narrow column that fits a phone)
|
|
46
|
+
const C = (code, x) => PLAIN ? String(x) : `\x1b[${code}m${x}\x1b[0m`;
|
|
47
|
+
const green = x => C("32", x), red = x => C("31", x), yellow = x => C("33", x), blue = x => C("34", x), purple = x => C("35", x), dim = x => C("2", x), orange = x => C("38;5;208", x), bold = x => C("1", x);
|
|
48
|
+
const vis = x => String(x).replace(/\x1b\[[0-9;]*m/g, "");
|
|
49
|
+
const fit = (x, n) => { const v = vis(x); if (v.length <= n) return x + " ".repeat(n - v.length); return v.slice(0, n - 1) + "."; };
|
|
50
|
+
const now = () => Date.now();
|
|
51
|
+
const DAY = 864e5;
|
|
52
|
+
const time = t => new Date(t).toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit" });
|
|
53
|
+
const date = t => new Date(t).toLocaleDateString("en-US", { weekday: "short", month: "short", day: "numeric" }).replace(",", "");
|
|
54
|
+
const short = t => Math.abs((t - now()) / DAY) < 6 ? new Date(t).toLocaleDateString("en-US", { weekday: "short" }) : new Date(t).toLocaleDateString("en-US", { month: "short", day: "numeric" });
|
|
55
|
+
const stamp = t => `${fit(short(t), 6)}${time(t).padStart(8)}`;
|
|
56
|
+
const nm = n => { n = String(n || "?").trim(); if (n.length <= 14) return n; const w = n.split(/\s+/); return w.length > 1 ? `${w[0]} ${w[w.length - 1][0]}.` : n; };
|
|
57
|
+
const money = v => `$${Number(v || 0).toFixed(2)}`;
|
|
58
|
+
const INTENT = (c) => {
|
|
59
|
+
const i = c.latest_user_intent || c.latest_intent || "";
|
|
60
|
+
if (i === "hot_lead" || c.lead_temperature === "hot") return orange("hot lead");
|
|
61
|
+
if (c.needs_reply) return red("needs reply");
|
|
62
|
+
if (i === "out_of_office") return purple("out of office");
|
|
63
|
+
if (i === "not_interested") return dim("not interested");
|
|
64
|
+
if (i === "unsubscribe") return dim("unsubscribed");
|
|
65
|
+
if (/auto/i.test(i)) return dim("auto-reply");
|
|
66
|
+
return blue("reply");
|
|
67
|
+
};
|
|
68
|
+
const STATUS = c => {
|
|
69
|
+
const d = c.status_display || {};
|
|
70
|
+
if (c.status === "running" && d.sending_paused_by_budget) return yellow("●");
|
|
71
|
+
if (c.status === "running") return green("●");
|
|
72
|
+
if (d.tone === "danger" || d.tone === "error") return red("●");
|
|
73
|
+
return dim("○");
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
async function load(acct) {
|
|
77
|
+
const y = new Yirlo(acct.key, { baseUrl: BASE });
|
|
78
|
+
const [me, list] = await Promise.all([y.getAccount(), y.listProjects()]);
|
|
79
|
+
const want = acct.projects && acct.projects.length ? new Set(acct.projects.map(d => String(d).toLowerCase())) : null;
|
|
80
|
+
const projects = (list.projects || []).filter(p => !p.archived && (!want || want.has(String(p.domain).toLowerCase()) || want.has(String(p.id))));
|
|
81
|
+
const rows = await Promise.all(projects.map(async p => {
|
|
82
|
+
const [an, inbox, hot] = await Promise.all([
|
|
83
|
+
y.projectAnalytics({ project_id: p.id }).catch(() => null),
|
|
84
|
+
y.listInbox({ project_id: p.id, tab: "all" }).catch(() => ({ contacts: [] })),
|
|
85
|
+
y.listInbox({ project_id: p.id, tab: "need_reply" }).catch(() => ({ contacts: [], total_count: 0 })),
|
|
86
|
+
]);
|
|
87
|
+
return { p, an, inbox: inbox.contacts || [], needReply: hot.total_count ?? (hot.contacts || []).length };
|
|
88
|
+
}));
|
|
89
|
+
return { acct, me, rows };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function draw(all, seen) {
|
|
93
|
+
const L = [];
|
|
94
|
+
const last = seen && seen.at ? Date.parse(seen.at) : null;
|
|
95
|
+
let fresh = 0;
|
|
96
|
+
L.push("");
|
|
97
|
+
L.push(` ${bold("Yirlo")} ${dim(`${date(now())} ${time(now())}`)}`);
|
|
98
|
+
for (const a of all) {
|
|
99
|
+
if (a.error) { L.push(""); L.push(red(` ${a.acct.name || "Account"}: ${a.error}`)); continue; }
|
|
100
|
+
const bal = a.me.balance_usd ?? 0;
|
|
101
|
+
L.push("");
|
|
102
|
+
L.push(` ${a.acct.name ? bold(a.acct.name) + " " : ""}${dim(a.me.email || "")}`);
|
|
103
|
+
L.push(` credit ${bal < 2 ? yellow(money(bal)) : green(money(bal))}`);
|
|
104
|
+
const replies = [];
|
|
105
|
+
for (const r of a.rows) {
|
|
106
|
+
const an = r.an || {};
|
|
107
|
+
const cs = an.campaign_rollup || [];
|
|
108
|
+
const daily = c => parseInt(String((c.status_display || {}).detail || "").match(/(\d+) emails a day/)?.[1] || "0", 10);
|
|
109
|
+
// sending = running with emails going out; the rest of the running ones wait their turn for sending room
|
|
110
|
+
const running = cs.filter(c => c.status === "running" && (daily(c) > 0 || (c.emails_sent_7d || 0) > 0));
|
|
111
|
+
const waiting = cs.filter(c => c.status === "running").length - running.length;
|
|
112
|
+
const perDay = running.reduce((s, c) => s + daily(c), 0);
|
|
113
|
+
const health = !running.length ? dim("● paused") : running.some(c => (c.status_display || {}).sending_paused_by_budget) ? yellow("● budget reached") : green("● sending");
|
|
114
|
+
L.push("");
|
|
115
|
+
L.push(` ${bold(r.p.company_name || r.p.domain)} ${health}`);
|
|
116
|
+
const big = (n, label, extra, color) => ` ${color(String(n).padStart(4))} ${fit(label, 13)}${extra}`;
|
|
117
|
+
L.push(big(r.needReply, "need a reply", r.needReply ? red("see below") : "", r.needReply ? red : green));
|
|
118
|
+
L.push(big(an.total_hot_leads ?? 0, "hot leads", an.total_hot_leads_today ? orange(`${an.total_hot_leads_today} today`) : "", (an.total_hot_leads ?? 0) ? orange : dim));
|
|
119
|
+
L.push(big(an.total_emails_sent ?? 0, "sent 7 days", dim(perDay ? `${perDay} a day now` : ""), blue));
|
|
120
|
+
L.push(big(an.total_replies ?? 0, "replies", dim(`${an.overall_reply_rate_pct ?? 0}%${an.total_bounced ? `, ${an.total_bounced} bounced` : ""}`), blue));
|
|
121
|
+
L.push(big(running.length, "sending", dim(`${waiting ? `${waiting} waiting, ` : ""}${cs.length} campaigns`), running.length ? green : dim));
|
|
122
|
+
for (const c of [...running].sort((x, z) => (z.emails_sent || 0) - (x.emails_sent || 0)).slice(0, 4))
|
|
123
|
+
L.push(` ${STATUS(c)} ${fit(c.campaign_name, 24)} ${dim(String(c.emails_sent || 0).padStart(4) + " sent")}${c.hot_leads ? orange(` ${c.hot_leads} hot`) : c.total_replies ? blue(` ${c.total_replies} rep`) : ""}`);
|
|
124
|
+
if (running.length > 4) L.push(dim(` +${running.length - 4} more sending`));
|
|
125
|
+
for (const c of r.inbox) if (c.latest_reply_at) replies.push({ ...c, t: Date.parse(c.latest_reply_at), project: r.p.company_name || r.p.domain });
|
|
126
|
+
}
|
|
127
|
+
replies.sort((x, z) => z.t - x.t);
|
|
128
|
+
const many = a.rows.length > 1;
|
|
129
|
+
L.push("");
|
|
130
|
+
L.push(" Latest replies");
|
|
131
|
+
if (!replies.length) L.push(dim(" none yet"));
|
|
132
|
+
for (const c of replies.slice(0, 8)) {
|
|
133
|
+
const isNew = last && c.t > last;
|
|
134
|
+
if (isNew) fresh++;
|
|
135
|
+
L.push(`${isNew ? orange("●") : " "} ${dim(stamp(c.t))} ${fit(nm(c.lead_name || c.reply_from_name || c.to_email), 14)} ${INTENT(c)}${many ? dim(" " + String(c.project).slice(0, 12)) : ""}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (last) L.splice(2, 0, ` ${fresh ? orange(`● ${fresh} new since ${time(last)}`) : dim("nothing new")}`);
|
|
139
|
+
L.push("");
|
|
140
|
+
return L.join("\n") + "\n";
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
let seen = null; try { seen = JSON.parse(fs.readFileSync(SEEN, "utf8")); } catch {}
|
|
144
|
+
let marked = false; // "new" = since the last time you opened it (a --watch redraw keeps that mark)
|
|
145
|
+
async function once() {
|
|
146
|
+
const all = await Promise.all(accounts().map(a => load(a).catch(e => ({ acct: a, error: e.status === 401 ? "that API key is not valid" : e.message }))));
|
|
147
|
+
process.stdout.write((PLAIN ? "" : "\x1b[H\x1b[2J") + draw(all, seen));
|
|
148
|
+
if (!marked) { marked = true; try { fs.mkdirSync(HOME, { recursive: true }); fs.writeFileSync(SEEN, JSON.stringify({ at: new Date().toISOString() })); } catch {} }
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const w = flag("watch") ? Math.max(15, parseInt(opt("watch") || "60", 10) || 60) : 0;
|
|
152
|
+
await once();
|
|
153
|
+
if (w) setInterval(() => once().catch(e => console.error(e.message)), w * 1000);
|
package/package.json
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yirlo",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Yirlo SDK and
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Yirlo SDK, MCP server and terminal dashboard: run your AI cold email outreach (projects, campaigns, inbox, hot leads, budgets) from code, an AI agent or your terminal.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "yirlo.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./yirlo.js"
|
|
9
9
|
},
|
|
10
10
|
"bin": {
|
|
11
|
+
"yirlo": "dash.js",
|
|
11
12
|
"yirlo-mcp": "mcp.js"
|
|
12
13
|
},
|
|
13
14
|
"files": [
|
|
14
15
|
"yirlo.js",
|
|
15
16
|
"mcp.js",
|
|
17
|
+
"dash.js",
|
|
16
18
|
"README.md"
|
|
17
19
|
],
|
|
18
20
|
"engines": {
|