@gorlitzer-labs/seldon 0.15.0 โ†’ 0.17.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 CHANGED
@@ -175,11 +175,24 @@ watcher sends its news there too (needs you, failed, finished), so the phone hea
175
175
  with the app closed.
176
176
 
177
177
  ```bash
178
- seldon tell "the build is green" # text (long text is split)
179
- pnpm test 2>&1 | tail -20 | seldon tell # or from stdin
180
- seldon tell --file out/pitch.mp4 "first cut" # a file, with a caption
178
+ seldon tell --done "PR #19 merged" # ๐ŸŸข a card: kind ยท project ยท branch ยท machine
179
+ seldon tell --need "which domain should staging use?" # ๐ŸŸ  (--fail ๐Ÿ”ด ยท --wip ๐ŸŸก ยท --info ๐Ÿ”ต, the default)
180
+ pnpm test 2>&1 | seldon tell --fail "tests broke" # a piped log shows its tail as code
181
+ seldon tell --file out/pitch.mp4 --info "first cut" # a file, the card as its caption
182
+ seldon tell --plain "just text" # no card
181
183
  ```
182
184
 
185
+ **Write Markdown โ€” it renders.** `**bold**` `*italic*` `~~strike~~` `||spoiler||` `` `code` ``,
186
+ fenced blocks with a language, `[links](https://โ€ฆ)`, `#` headings, `-` lists, `>` quotes, `---`.
187
+ Anything else is shown exactly as written (`snake_case`, `2*3`, `<tags>` stay literal), and if
188
+ Telegram ever rejects the formatting the card is resent as plain text, so nothing is lost. A
189
+ piped log over a few lines folds away โ€” tap it to open.
190
+
191
+ Every message is a card that reads at a glance: a coloured dot for what kind of news it is,
192
+ then where it comes from (the repo, branch and machine it was sent from), then what happened.
193
+ The watcher's cards also name the agent, what it is waiting for, how long it has run, and link
194
+ to the phone app when `seldon serve --tailnet` is on.
195
+
183
196
  Images show inline, videos play, GIFs animate, audio plays, anything else is a document; a
184
197
  bot can send up to 50 MB per file.
185
198
 
package/bin/seldon.js CHANGED
@@ -5,6 +5,7 @@ import { execSync, spawnSync, spawn } from "node:child_process";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import path from "node:path";
7
7
  import fs from "node:fs";
8
+ import os from "node:os";
8
9
  import readline from "node:readline";
9
10
  import { MODULES, byId, DEPS, RAW, MONOREPO, withRequires, platformOk } from "../modules.mjs";
10
11
  import { ensureSiblingPath, loadState, resolveProject, adopt as fAdopt, staff as fStaff, attach as fAttach, hiveOf, sameDir } from "../lib/projects.mjs";
@@ -14,7 +15,7 @@ import { startLane, stopLane, resumeLane, removeLane, findLane } from "../lib/ac
14
15
  import { listMachines, addMachine, fetchLanes, remoteGroups, sshArgs, lastJsonLine } from "../lib/machines.mjs";
15
16
  import { notify } from "../lib/notify.mjs";
16
17
  import { serve, serveToken, ownerFromStatus } from "../lib/serve.mjs";
17
- import { tokenName, readChat, writeChat, chatFromUpdates, getUpdates, sendText, sendFile, pollUpdates, fileFromMessage, inboxName, noteLine, downloadFile, react, MAX_DOWNLOAD } from "../lib/telegram.mjs";
18
+ import { sendCard, watchCard, KINDS, tokenName, readChat, writeChat, chatFromUpdates, getUpdates, sendText, sendFile, pollUpdates, fileFromMessage, inboxName, noteLine, downloadFile, react, MAX_DOWNLOAD } from "../lib/telegram.mjs";
18
19
  import { reportFromEvent, mergeCodexHooks, removeCodexHooks, opencodePlugin } from "../lib/reports.mjs";
19
20
  import { buildRows, headline, ago, laneDetail, unlistedAgents, GLYPH } from "../lib/home.mjs";
20
21
  import { parseDuration, describe as describeHold, NAME_RE, DEFAULT_FOR_MS } from "../lib/holds.mjs";
@@ -1469,18 +1470,28 @@ const startWatch = () => startDaemon("seldon-watch", process.execPath, [SELF, "w
1469
1470
 
1470
1471
  // The watcher's news on the phone too, once `seldon tell --setup` has been run. A child
1471
1472
  // `seldon tell` per event, so the token goes through comb exactly as it does for an agent.
1472
- function tellInBackground(text) {
1473
+ function tellInBackground(fields) {
1473
1474
  if (process.env.SELDON_NO_NOTIFY || !readChat()) return;
1474
- const child = spawn(process.execPath, [process.argv[1], "tell", text], { stdio: "ignore", detached: true });
1475
+ const child = spawn(process.execPath, [process.argv[1], "tell", "--card", JSON.stringify(fields)], { stdio: "ignore", detached: true });
1475
1476
  child.on("error", () => {}); child.unref();
1476
1477
  }
1477
1478
 
1479
+ function phoneAppUrl() {
1480
+ const ts = tailscaleBin(); if (!ts) return null;
1481
+ try {
1482
+ const out = execSync(`${ts} serve status`, { stdio: ["ignore", "pipe", "ignore"], timeout: 10000 }).toString();
1483
+ const m = out.match(new RegExp(`https://\\S+:${SERVE_TAILNET_PORT}`));
1484
+ return m ? m[0] + "/" : null;
1485
+ } catch { return null; }
1486
+ }
1487
+
1478
1488
  async function watchCmd(flags) {
1479
1489
  ensureSiblingPath();
1480
1490
  const every = parseDuration(flags.interval, 5000) || 5000;
1481
1491
  let prev = new Map();
1482
1492
  const stamp = () => new Date().toTimeString().slice(0, 8);
1483
1493
  console.log(`${stamp()} seldon watch โ€” every ${every / 1000}s`);
1494
+ const phone = phoneAppUrl(); // once: the link the phone cards carry
1484
1495
  for (;;) {
1485
1496
  let lanes = [];
1486
1497
  try { lanes = readLanes().flatMap((g) => g.lanes); } catch (e) { console.log(`${stamp()} read failed: ${e.message}`); }
@@ -1488,7 +1499,7 @@ async function watchCmd(flags) {
1488
1499
  console.log(`${stamp()} ${e.text}`);
1489
1500
  const where = path.basename(e.lane.project || e.lane.cwd || "");
1490
1501
  notify(e.to === "needs-you" ? "Seldon ยท needs you" : "Seldon", `${e.text} โ€” ${where}`);
1491
- tellInBackground(`${e.to === "needs-you" ? "โš‘" : e.to === "failed" ? "โœ—" : "โœ“"} ${e.text} โ€” ${where}`);
1502
+ tellInBackground(watchCard(e, { machine: os.hostname().split(".")[0], link: phone }));
1492
1503
  }
1493
1504
  prev = new Map(lanes.map((l) => [l.key, l.state]));
1494
1505
  if (flags.once) return;
@@ -1585,6 +1596,22 @@ function telegramToken(flags) {
1585
1596
  return null;
1586
1597
  }
1587
1598
 
1599
+ // Where a message comes from: the project (a worktree counts as its main repo), the branch,
1600
+ // and this machine's short name.
1601
+ function tellContext(cwd = process.cwd()) {
1602
+ const git = (...a) => { try { return execSync(`git ${a.join(" ")}`, { cwd, stdio: ["ignore", "pipe", "ignore"] }).toString().trim(); } catch { return null; } };
1603
+ const root = projectRoot(cwd);
1604
+ const branch = root ? git("rev-parse", "--abbrev-ref", "HEAD") : null;
1605
+ return { project: root ? path.basename(root) : null, branch: branch && branch !== "HEAD" ? branch : null, machine: os.hostname().split(".")[0] };
1606
+ }
1607
+
1608
+ // Something was piped or redirected in (`cmd | seldon tell`, `< file`). Not "stdin is not a
1609
+ // terminal": an agent's shell hands its commands an open socket that never sends or closes,
1610
+ // and reading that would hang the agent forever.
1611
+ function pipedIn() {
1612
+ try { const s = fs.fstatSync(0); return s.isFIFO() || s.isFile(); } catch { return false; }
1613
+ }
1614
+
1588
1615
  async function tellCmd(words, flags) {
1589
1616
  const fail = (msg) => { console.error(C.red(msg)); process.exitCode = 1; };
1590
1617
  const t = telegramToken(flags);
@@ -1592,19 +1619,33 @@ async function tellCmd(words, flags) {
1592
1619
  const { token, name } = t;
1593
1620
  try {
1594
1621
  if (flags.setup) {
1595
- const chat = chatFromUpdates(await getUpdates(token));
1622
+ const updates = await getUpdates(token).catch((e) => {
1623
+ if (/conflict|terminated by other getUpdates/i.test(e.message)) throw new Error("something else is reading this bot (seldon inbox?) โ€” stop it, run --setup, then start it again");
1624
+ throw e;
1625
+ });
1626
+ const chat = chatFromUpdates(updates);
1596
1627
  if (!chat) return fail("no message to the bot yet โ€” open your bot in Telegram, send it /start, then run this again");
1597
1628
  writeChat({ ...chat, ...(name !== "TELEGRAM_BOT_TOKEN" ? { tokenName: name } : {}) });
1598
- await sendText(token, chat.id, "โœ“ seldon is connected. Agents can reach you here with: seldon tell \"โ€ฆ\"");
1629
+ await sendCard(token, chat.id, { kind: "done", text: "**seldon is connected.**\nAgents reach you here with `seldon tell --done \"โ€ฆ\"`; send this chat a photo, file or note and `seldon inbox` saves it on your machine.", machine: os.hostname().split(".")[0] });
1599
1630
  return console.log(C.green(`โœ“ connected to ${chat.name || "your chat"}`) + C.dim(" โ€” try: seldon tell \"hello\""));
1600
1631
  }
1601
1632
  const chat = readChat();
1602
1633
  if (!chat) return fail("not set up yet โ€” send your bot /start in Telegram, then: seldon tell --setup");
1603
- let text = words.join(" ");
1604
- if (!text && !process.stdin.isTTY) { for await (const c of process.stdin) text += c; text = text.trim(); }
1605
- if (typeof flags.file === "string") await sendFile(token, chat.id, flags.file, text);
1606
- else if (text) await sendText(token, chat.id, text);
1607
- else return fail('usage: seldon tell "message" ยท โ€ฆ | seldon tell ยท seldon tell --file shot.png "caption" ยท seldon tell --setup');
1634
+ const text = words.join(" ");
1635
+ let log = "";
1636
+ if (pipedIn() && !flags.card) { for await (const c of process.stdin) log += c; log = log.trim(); }
1637
+ const file = typeof flags.file === "string" ? flags.file : null;
1638
+ if (!text && !log && !file && !flags.card) return fail('usage: seldon tell [--done|--need|--fail|--wip|--info] "what happened" ยท โ€ฆ | seldon tell ยท --file shot.png ยท --plain ยท --setup');
1639
+ if (flags.plain) {
1640
+ const body = [text, log].filter(Boolean).join("\n");
1641
+ if (file) await sendFile(token, chat.id, file, body); else await sendText(token, chat.id, body);
1642
+ } else {
1643
+ // A card: the kind, then where it comes from โ€” this repo, branch and machine โ€” so the
1644
+ // phone says what is going on without the agent having to spell it out.
1645
+ const kind = Object.keys(KINDS).find((k) => flags[k]) || "info";
1646
+ const fields = typeof flags.card === "string" ? JSON.parse(flags.card) : { kind, text, log, ...tellContext() };
1647
+ await sendCard(token, chat.id, fields, file);
1648
+ }
1608
1649
  console.log(C.green("โœ“ sent"));
1609
1650
  } catch (e) { fail(e.message); }
1610
1651
  }
@@ -1650,7 +1691,7 @@ async function inboxCmd(flags) {
1650
1691
  await react(t.token, chat.id, m.message_id, "๐Ÿ‘");
1651
1692
  } catch (e) {
1652
1693
  console.log(`${stamp()} ${e.message}`);
1653
- await sendText(t.token, chat.id, `โœ— not saved: ${e.message}`).catch(() => {});
1694
+ await sendCard(t.token, chat.id, { kind: "fail", text: `**Not saved:** ${e.message}`, machine: os.hostname().split(".")[0] }).catch(() => {});
1654
1695
  }
1655
1696
  }
1656
1697
  }
@@ -1782,7 +1823,7 @@ function holdsCmd() {
1782
1823
  // (`--no-attach`). The value form has to be CONSUMED: filtering out everything starting with
1783
1824
  // `--` and keeping the rest as positionals read `seldon go --agent claude` as the project
1784
1825
  // named "claude".
1785
- const VALUE_FLAGS = new Set(["agent", "model", "effort", "name", "port", "pm", "stall", "dir", "for", "wait", "as", "note", "interval", "task", "owner", "file", "token-name"]);
1826
+ const VALUE_FLAGS = new Set(["agent", "model", "effort", "name", "port", "pm", "stall", "dir", "for", "wait", "as", "note", "interval", "task", "owner", "file", "token-name", "card"]);
1786
1827
  function parseArgv(raw) {
1787
1828
  const flags = {}, positional = [];
1788
1829
  for (let i = 0; i < raw.length; i++) {
package/lib/telegram.mjs CHANGED
@@ -11,6 +11,7 @@
11
11
  import { readFileSync, writeFileSync, mkdirSync, statSync } from "node:fs";
12
12
  import { join, basename } from "node:path";
13
13
  import { SELDON_HOME } from "./agents.mjs";
14
+ import { ago } from "./home.mjs";
14
15
 
15
16
  export const TOKEN_NAME = "TELEGRAM_BOT_TOKEN";
16
17
  // The comb name the token is stored under: TELEGRAM_BOT_TOKEN unless setup was told another.
@@ -65,10 +66,106 @@ export const getUpdates = (token) => call(token, "getUpdates", { allowed_updates
65
66
  export const pollUpdates = (token, offset, timeout = 50) =>
66
67
  call(token, "getUpdates", { offset, timeout, allowed_updates: ["message"] });
67
68
 
68
- export async function sendText(token, chatId, text) {
69
+ // Plain text is split to fit; a card (HTML) is built to fit already, so it goes as one.
70
+ export async function sendText(token, chatId, text, { html = false } = {}) {
71
+ if (html) return void await call(token, "sendMessage", { chat_id: chatId, text, parse_mode: "HTML", disable_web_page_preview: true });
69
72
  for (const part of chunks(text)) await call(token, "sendMessage", { chat_id: chatId, text: part, disable_web_page_preview: true });
70
73
  }
71
74
 
75
+ // ---- cards: what happened, where, and what to do โ€” readable at a glance ---------------
76
+ // Telegram has no colours in text; a coloured dot carries it. One kind per message.
77
+ export const KINDS = {
78
+ done: { dot: "๐ŸŸข", label: "DONE" },
79
+ need: { dot: "๐ŸŸ ", label: "NEEDS YOU" },
80
+ fail: { dot: "๐Ÿ”ด", label: "FAILED" },
81
+ wip: { dot: "๐ŸŸก", label: "WORKING" },
82
+ info: { dot: "๐Ÿ”ต", label: "INFO" },
83
+ };
84
+ export const escHtml = (s) => String(s ?? "").replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" }[c]));
85
+ const clip = (s, n) => (s.length > n ? s.slice(0, n - 1) + "โ€ฆ" : s);
86
+
87
+ // ---- Markdown โ†’ Telegram HTML -----------------------------------------------------
88
+ // Agents write Markdown; Telegram renders a small HTML set. This turns the common subset into
89
+ // it: **bold** *italic* _italic_ ~~strike~~ ||spoiler|| `code`, ```lang fenced blocks```,
90
+ // [text](https://โ€ฆ), # headings, - lists, 1. lists, > quotes, ---. Everything is escaped
91
+ // first, so text can never inject a tag; what isn't Markdown is shown as written.
92
+ // Telegram rejects badly nested tags โ€” sendCard falls back to plain text when it does.
93
+ const SAFE_URL = /^(https?:\/\/|tg:\/\/|mailto:)/i;
94
+
95
+ function inline(line) {
96
+ const keep = [];
97
+ const hold = (html) => `\u0000${keep.push(html) - 1}\u0000`;
98
+ let s = escHtml(line)
99
+ .replace(/`([^`\n]+)`/g, (_, c) => hold(`<code>${c}</code>`))
100
+ .replace(/\[([^\]\n]+)\]\(([^)\s]+)\)/g, (m, label, url) => SAFE_URL.test(url) ? hold(`<a href="${url}">${label}</a>`) : m)
101
+ .replace(/\*\*(?=\S)([^*\n]+?)\*\*/g, "<b>$1</b>")
102
+ .replace(/__(?=\S)([^_\n]+?)__/g, "<b>$1</b>")
103
+ .replace(/~~(?=\S)([^~\n]+?)~~/g, "<s>$1</s>")
104
+ .replace(/\|\|(?=\S)([^|\n]+?)\|\|/g, "<tg-spoiler>$1</tg-spoiler>")
105
+ .replace(/(^|[\s(])\*(?=\S)([^*\n]+?)\*(?=$|[\s).,:;!?])/g, "$1<i>$2</i>")
106
+ .replace(/(^|[\s(])_(?=\S)([^_\n]+?)_(?=$|[\s).,:;!?])/g, "$1<i>$2</i>"); // not snake_case
107
+ return s.replace(/\u0000(\d+)\u0000/g, (_, i) => keep[i]);
108
+ }
109
+
110
+ export function mdToHtml(text) {
111
+ const out = [];
112
+ const lines = String(text ?? "").replace(/\r\n?/g, "\n").split("\n");
113
+ let quote = [];
114
+ const flush = () => { if (quote.length) { out.push(`<blockquote>${quote.join("\n")}</blockquote>`); quote = []; } };
115
+ for (let i = 0; i < lines.length; i++) {
116
+ const line = lines[i];
117
+ const fence = line.match(/^\s*```\s*([\w+#.-]*)\s*$/);
118
+ if (fence) { // a fenced block, to its closing fence (or the end)
119
+ flush();
120
+ const body = [];
121
+ while (++i < lines.length && !/^\s*```\s*$/.test(lines[i])) body.push(lines[i]);
122
+ const lang = fence[1] ? ` class="language-${escHtml(fence[1])}"` : "";
123
+ out.push(`<pre><code${lang}>${escHtml(body.join("\n"))}</code></pre>`);
124
+ continue;
125
+ }
126
+ const q = line.match(/^\s*>\s?(.*)$/);
127
+ if (q) { quote.push(inline(q[1])); continue; }
128
+ flush();
129
+ let m;
130
+ if ((m = line.match(/^\s{0,3}#{1,6}\s+(.+?)\s*#*\s*$/))) out.push(`<b>${inline(m[1])}</b>`);
131
+ else if ((m = line.match(/^(\s*)[-*+]\s+(.*)$/))) out.push(`${m[1].replace(/\t/g, " ")}โ€ข ${inline(m[2])}`);
132
+ else if (/^\s*([-*_])(\s*\1){2,}\s*$/.test(line)) out.push("โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€");
133
+ else out.push(inline(line));
134
+ }
135
+ flush();
136
+ return out.join("\n");
137
+ }
138
+
139
+ // The same card without tags: what is sent when Telegram rejects the HTML.
140
+ export const htmlToPlain = (html) => String(html)
141
+ .replace(/<a href="([^"]*)">([^<]*)<\/a>/g, (_, url, label) => (label === url ? label : `${label} (${url})`))
142
+ .replace(/<[^>]+>/g, "")
143
+ .replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&amp;/g, "&");
144
+
145
+ // Every part is optional but the kind. `log` is shown as code (its tail: the end of a log is
146
+ // what matters). `max` keeps the whole card under Telegram's limit โ€” 1024 for a caption.
147
+ export function card({ kind = "info", text, log, project, branch, lane, harness, detail, age, machine, link, max = MAX } = {}) {
148
+ const k = KINDS[kind] || KINDS.info;
149
+ const e = escHtml;
150
+ const meta = [age && `โฑ ${e(age)}`, machine && `๐Ÿ’ป ${e(machine)}`].filter(Boolean).join(" ยท ");
151
+ const top = [
152
+ `${k.dot} <b>${k.label}</b>` + (project ? ` ยท <b>${e(project)}</b>` : "") + (branch ? ` <i>(${e(branch)})</i>` : ""),
153
+ lane && `โ–ธ <b>${e(lane)}</b>${harness ? ` ยท ${e(harness)}` : ""}`,
154
+ detail && `โณ ${e(detail)}`,
155
+ ].filter(Boolean);
156
+ const bottom = [meta && `<i>${meta}</i>`, link && `๐Ÿ‘‰ <a href="${e(link)}">open the app</a>`].filter(Boolean);
157
+ // The free text gets whatever room the frame leaves (escaping can grow it, hence the margin).
158
+ const room = Math.max(0, max - [...top, ...bottom].join("\n").length - 60);
159
+ const words = text && mdToHtml(clip(String(text).trim(), Math.floor(room * (log ? 0.4 : 1) / 1.2)));
160
+ const tail = log && String(log).trimEnd();
161
+ const logRoom = Math.floor(room * 0.55 / 1.2);
162
+ const shown = tail && (tail.length > logRoom ? "โ€ฆ" + tail.slice(-logRoom) : tail);
163
+ // A short log shows as is; a long one folds away (tap to open), so the card stays readable.
164
+ const folds = shown && (shown.split("\n").length > 8 || shown.length > 500);
165
+ const code = shown && (folds ? `<blockquote expandable><pre>${e(shown)}</pre></blockquote>` : `<pre>${e(shown)}</pre>`);
166
+ return [...top, words, code, ...bottom].filter(Boolean).join("\n");
167
+ }
168
+
72
169
  // How a file shows up in the chat: images inline, videos playable, GIFs animated, audio as a
73
170
  // track, anything else as a document.
74
171
  export function mediaKind(path) {
@@ -80,13 +177,14 @@ export function mediaKind(path) {
80
177
  return { method: "sendDocument", field: "document" };
81
178
  }
82
179
 
83
- export async function sendFile(token, chatId, path, caption = "") {
180
+ export async function sendFile(token, chatId, path, caption = "", { html = false } = {}) {
84
181
  const size = statSync(path).size;
85
182
  if (size > MAX_UPLOAD) throw new Error(`${basename(path)} is ${(size / 1048576).toFixed(0)} MB โ€” Telegram bots can send up to 50 MB`);
86
183
  const { method, field } = mediaKind(path);
87
184
  const form = new FormData();
88
185
  form.set("chat_id", String(chatId));
89
- if (caption) form.set("caption", caption.slice(0, 1024));
186
+ if (caption) form.set("caption", html ? caption : caption.slice(0, 1024));
187
+ if (caption && html) form.set("parse_mode", "HTML");
90
188
  if (method === "sendVideo") form.set("supports_streaming", "true");
91
189
  form.set(field, new Blob([readFileSync(path)]), basename(path));
92
190
  await call(token, method, form);
@@ -129,3 +227,31 @@ export async function downloadFile(token, fileId, dest) {
129
227
  // A reaction on your message says it is saved, without a reply cluttering the chat.
130
228
  export const react = (token, chatId, messageId, emoji) =>
131
229
  call(token, "setMessageReaction", { chat_id: chatId, message_id: messageId, reaction: [{ type: "emoji", emoji }] }).catch(() => {});
230
+
231
+ // The watcher's news as a card: which agent, on what, what it is waiting for, for how long,
232
+ // and โ€” when the phone app is on the tailnet โ€” a link straight to it.
233
+ const WATCH_KIND = { "needs-you": "need", failed: "fail", idle: "done" };
234
+ const WATCH_DETAIL = { failed: "ended with an error", idle: "finished its turn โ€” ready for the next task" };
235
+ export function watchCard(e, { machine = null, link = null, now = Date.now() } = {}) {
236
+ return {
237
+ kind: WATCH_KIND[e.to] || "info",
238
+ project: basename(e.lane.project || e.lane.cwd || "") || null,
239
+ lane: e.lane.name || e.lane.id, harness: e.lane.harness,
240
+ detail: e.to === "needs-you" ? (e.lane.waitingFor || "waiting for you") : WATCH_DETAIL[e.to] || e.to,
241
+ age: e.lane.startedAt ? `running ${ago(e.lane.startedAt, now)}` : null,
242
+ machine, link,
243
+ };
244
+ }
245
+
246
+ // Send a card โ€” as a message, or as a file's caption. If Telegram rejects the formatting (badly
247
+ // nested Markdown), the same card goes out as plain text: a message is never lost to styling.
248
+ export async function sendCard(token, chatId, fields, file = null) {
249
+ const html = card({ ...fields, max: file ? 1024 : MAX });
250
+ try {
251
+ return file ? await sendFile(token, chatId, file, html, { html: true }) : await sendText(token, chatId, html, { html: true });
252
+ } catch (e) {
253
+ if (!/can't parse entities/i.test(e.message)) throw e;
254
+ const plain = htmlToPlain(html);
255
+ return file ? await sendFile(token, chatId, file, plain) : await sendText(token, chatId, plain);
256
+ }
257
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gorlitzer-labs/seldon",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "description": "Install the Seldon stack โ€” pick your tools from a checklist; each installs via its native method.",
5
5
  "type": "module",
6
6
  "bin": {