dsh-tg-bridge 1.10.0 → 1.11.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 +13 -0
- package/bridge.mjs +22 -139
- package/i18n.mjs +6 -3
- package/package.json +1 -1
- package/panel.mjs +8 -1
- package/say.mjs +10 -4
package/README.md
CHANGED
|
@@ -288,6 +288,19 @@ message shows the last two as `💭` lines. The command needs no ids: it falls b
|
|
|
288
288
|
newest turn's thought file, because tool shells do not inherit the bridge environment.
|
|
289
289
|
`--thought` never sends a Telegram message on its own.
|
|
290
290
|
|
|
291
|
+
A decision the person must know before the turn ends — a release shipped, a cause found,
|
|
292
|
+
a blocker — goes to the chat as one plain line instead:
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
node ~/.dsh/tg-bridge/say.mjs --note "1.10.1 is on npm; restart to load it"
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
`--note` sends a real message and takes the same no-ids fallback as `--thought`. The split
|
|
299
|
+
is deliberate: `--thought` is the working trail inside the progress message, `--note` is the
|
|
300
|
+
short line that changes what the reader expects to happen next. The progress message itself
|
|
301
|
+
opens with the request echoed back (`⏳ Принял: «…» · 3 с`), so the first thing the person
|
|
302
|
+
sees after sending names their task rather than a generic spinner.
|
|
303
|
+
|
|
291
304
|
`/reasoning` is the switch for the 💭 mechanism. It is on by default: every turn carries a
|
|
292
305
|
short instruction to leave one line at each decision point (task clear, cause found, risky
|
|
293
306
|
change, result checked). `/reasoning off` drops the instruction and the `💭` lines for that
|
package/bridge.mjs
CHANGED
|
@@ -28,6 +28,7 @@ import { writeSteerJob } from './steer-queue.mjs';
|
|
|
28
28
|
import { inlineText } from './media-text.mjs';
|
|
29
29
|
import { createAlbumBuffer } from './albums.mjs';
|
|
30
30
|
import { turnArgs } from './cli-args.mjs';
|
|
31
|
+
import { chunk, markdownParts, toPlainText, toTelegramHtml } from './format.mjs';
|
|
31
32
|
import { ensureProfile } from './profiles.mjs';
|
|
32
33
|
import { handleControl, CONTROL_COMMANDS, modelOf, reasoningOf } from './control.mjs';
|
|
33
34
|
import { drainGoalJobs, goalOf, renderPromptBlock } from './goals.mjs';
|
|
@@ -379,24 +380,6 @@ async function tg(method, body, timeoutMs = 60000, attempts = 3) {
|
|
|
379
380
|
throw lastError;
|
|
380
381
|
}
|
|
381
382
|
|
|
382
|
-
function chunk(text, size = 4000) {
|
|
383
|
-
const out = [];
|
|
384
|
-
let rest = text;
|
|
385
|
-
while (rest.length > size) {
|
|
386
|
-
let cut = rest.lastIndexOf('\n', size);
|
|
387
|
-
if (cut < size * 0.5) cut = size;
|
|
388
|
-
out.push(rest.slice(0, cut));
|
|
389
|
-
rest = rest.slice(cut).replace(/^\n+/, '');
|
|
390
|
-
}
|
|
391
|
-
if (rest.length) out.push(rest);
|
|
392
|
-
return out;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* Forum topic id of a message, or 0 for the General topic and for private chats.
|
|
397
|
-
* Telegram omits `message_thread_id` for the General topic of a forum, so 0 is
|
|
398
|
-
* the "no topic" marker and must never be sent back as a thread id.
|
|
399
|
-
*/
|
|
400
383
|
function threadOf(msg) {
|
|
401
384
|
const id = msg.message_thread_id ?? msg.reply_to_message?.message_thread_id;
|
|
402
385
|
return Number.isInteger(id) && id > 0 ? id : 0;
|
|
@@ -591,126 +574,18 @@ function immediateCommandOf(text) {
|
|
|
591
574
|
return immediateKind(collapsed, rest);
|
|
592
575
|
}
|
|
593
576
|
|
|
594
|
-
/**
|
|
595
|
-
* Turn model markdown into plain readable text.
|
|
596
|
-
*
|
|
597
|
-
* The bridge sends without `parse_mode`, so every `**bold**`, `### heading` and
|
|
598
|
-
* `` `code` `` reached the person as literal punctuation — the chat looked
|
|
599
|
-
* "filled with junk". Telegram formatting is opt-in per message and a bad
|
|
600
|
-
* entity rejects the whole send, so the safe direction is to strip the markers
|
|
601
|
-
* and keep the words.
|
|
602
|
-
*/
|
|
603
|
-
export function toPlainText(input) {
|
|
604
|
-
let text = String(input ?? '');
|
|
605
|
-
// Fenced code blocks: keep the body, drop the fence and language tag.
|
|
606
|
-
text = text.replace(/```[a-zA-Z0-9]*\n?/g, '').replace(/```/g, '');
|
|
607
|
-
// Inline code and bold/italic/strike markers.
|
|
608
|
-
text = text.replace(/`([^`]*)`/g, '$1');
|
|
609
|
-
text = text.replace(/\*\*\*([^*]+)\*\*\*/g, '$1');
|
|
610
|
-
text = text.replace(/\*\*([^*]+)\*\*/g, '$1');
|
|
611
|
-
text = text.replace(/(^|[\s(])\*([^*\n]+)\*(?=[\s).,!?:;]|$)/g, '$1$2');
|
|
612
|
-
text = text.replace(/__([^_]+)__/g, '$1');
|
|
613
|
-
text = text.replace(/(^|[\s(])_([^_\n]+)_(?=[\s).,!?:;]|$)/g, '$1$2');
|
|
614
|
-
text = text.replace(/~~([^~]+)~~/g, '$1');
|
|
615
|
-
// Headings: "### Title" -> "Title".
|
|
616
|
-
text = text.replace(/^\s{0,3}#{1,6}\s+/gm, '');
|
|
617
|
-
// Links: [label](url) -> label (url); bare <url> stays as is.
|
|
618
|
-
text = text.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, '$1 ($2)');
|
|
619
|
-
// Blockquote markers at line start.
|
|
620
|
-
text = text.replace(/^\s{0,3}>\s?/gm, '');
|
|
621
|
-
// Bullets keep a dash, but " - x" indentation is dropped to one level.
|
|
622
|
-
text = text.replace(/^\s*[-*+]\s+/gm, '— ');
|
|
623
|
-
// Tables: drop the separator row first (it is pure punctuation), then turn
|
|
624
|
-
// the remaining rows into one line each with " · " between cells. The
|
|
625
|
-
// separator pattern uses [ \t] rather than \s so it cannot eat the newline
|
|
626
|
-
// and glue neighbouring rows together.
|
|
627
|
-
text = text.replace(/^[ \t]*\|?[ \t:|-]*-[ \t:|-]*\|?[ \t]*$/gm, '');
|
|
628
|
-
text = text.replace(/^[ \t]*\|(.+)\|[ \t]*$/gm, (_match, row) => row.split('|').map((cell) => cell.trim()).filter((cell) => cell !== '').join(' · '));
|
|
629
|
-
// Collapse the blank runs the removals leave behind.
|
|
630
|
-
text = text.replace(/\n{3,}/g, '\n\n').trim();
|
|
631
|
-
return text;
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
/** Escape the four characters Telegram's HTML parser treats as markup. */
|
|
635
|
-
function escapeHtml(value) {
|
|
636
|
-
return String(value ?? '')
|
|
637
|
-
.replace(/&/g, '&')
|
|
638
|
-
.replace(/</g, '<')
|
|
639
|
-
.replace(/>/g, '>');
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
/** Inline markdown inside one non-code segment -> Telegram HTML. */
|
|
643
|
-
function inlineHtml(segment) {
|
|
644
|
-
let text = escapeHtml(segment);
|
|
645
|
-
// Inline code first: its body must not be touched by the emphasis rules.
|
|
646
|
-
text = text.replace(/`([^`\n]+)`/g, '<code>$1</code>');
|
|
647
|
-
text = text.replace(/\*\*\*([^*]+)\*\*\*/g, '<b><i>$1</i></b>');
|
|
648
|
-
text = text.replace(/\*\*([^*\n]+)\*\*/g, '<b>$1</b>');
|
|
649
|
-
text = text.replace(/(^|[\s(])\*([^*\n]+)\*(?=[\s).,!?:;]|$)/g, '$1<i>$2</i>');
|
|
650
|
-
text = text.replace(/__([^_\n]+)__/g, '<b>$1</b>');
|
|
651
|
-
text = text.replace(/(^|[\s(])_([^_\n]+)_(?=[\s).,!?:;]|$)/g, '$1<i>$2</i>');
|
|
652
|
-
text = text.replace(/~~([^~\n]+)~~/g, '<s>$1</s>');
|
|
653
|
-
// Headings become bold lines.
|
|
654
|
-
text = text.replace(/^[ \t]{0,3}#{1,6}[ \t]+(.+)$/gm, '<b>$1</b>');
|
|
655
|
-
// Links: [label](url) -> label (url), both already escaped.
|
|
656
|
-
text = text.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, '$1 ($2)');
|
|
657
|
-
// Blockquote markers.
|
|
658
|
-
text = text.replace(/^[ \t]{0,3}>[ \t]?/gm, '');
|
|
659
|
-
// Bullets.
|
|
660
|
-
text = text.replace(/^[ \t]*[-*+][ \t]+/gm, '— ');
|
|
661
|
-
// Tables: drop the separator row, then join cells with a middle dot.
|
|
662
|
-
text = text.replace(/^[ \t]*\|?[ \t:|-]*-[ \t:|-]*\|?[ \t]*$/gm, '');
|
|
663
|
-
text = text.replace(/^[ \t]*\|(.+)\|[ \t]*$/gm, (_m, row) => row.split('|').map((cell) => cell.trim()).filter(Boolean).join(' · '));
|
|
664
|
-
return text;
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
/**
|
|
668
|
-
* Markdown -> Telegram HTML with real <pre><code> blocks.
|
|
669
|
-
*
|
|
670
|
-
* A fenced block is what gives the person a tap-to-copy button in Telegram,
|
|
671
|
-
* which is the whole point for shell commands. Everything else stays plain so
|
|
672
|
-
* a malformed entity cannot reject the message: `send` falls back to stripped
|
|
673
|
-
* text when Telegram refuses to parse.
|
|
674
|
-
*/
|
|
675
|
-
export function toTelegramHtml(input) {
|
|
676
|
-
const source = String(input ?? '');
|
|
677
|
-
const parts = source.split(/```/);
|
|
678
|
-
let out = '';
|
|
679
|
-
parts.forEach((segment, index) => {
|
|
680
|
-
if (index % 2 === 1) {
|
|
681
|
-
// Odd indexes are fenced code. The first line may be a language tag.
|
|
682
|
-
const newline = segment.indexOf('\n');
|
|
683
|
-
const firstLine = newline === -1 ? '' : segment.slice(0, newline).trim();
|
|
684
|
-
const isLanguage = /^[a-zA-Z0-9+#.-]{1,20}$/.test(firstLine);
|
|
685
|
-
const body = isLanguage ? segment.slice(newline + 1) : segment;
|
|
686
|
-
const language = isLanguage ? firstLine.toLowerCase() : '';
|
|
687
|
-
const cls = language ? ` class="language-${language}"` : '';
|
|
688
|
-
out += `<pre><code${cls}>${escapeHtml(body.replace(/\n+$/, ''))}</code></pre>`;
|
|
689
|
-
} else {
|
|
690
|
-
out += inlineHtml(segment);
|
|
691
|
-
}
|
|
692
|
-
});
|
|
693
|
-
return out.replace(/\n{3,}/g, '\n\n').trim();
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
/**
|
|
697
|
-
* Language of a (chat, topic) pair, for the few helpers that have no message to
|
|
698
|
-
* read it from: `send` falls back to this for its empty-text placeholder, and
|
|
699
|
-
* the callback handler uses it for button answers.
|
|
700
|
-
*/
|
|
701
|
-
function langFor(chatId, threadId = 0) {
|
|
702
|
-
return resolveLang(state, sessionKey(chatId, threadId), null, config);
|
|
703
|
-
}
|
|
704
|
-
|
|
705
577
|
async function send(chatId, text, threadId = 0, replyTo = 0) {
|
|
706
578
|
// Who is reading: the topic's language decides even the fallback line, so an
|
|
707
579
|
// English or Chinese topic never sees a Russian placeholder.
|
|
708
580
|
const lang = langFor(chatId, threadId);
|
|
709
|
-
const
|
|
710
|
-
const parts =
|
|
581
|
+
const plain = config.plainText === true;
|
|
582
|
+
const parts = plain
|
|
583
|
+
? chunk(toPlainText(text) || t(lang, 'bridge.progress.empty'), 3800)
|
|
584
|
+
: markdownParts(text);
|
|
711
585
|
let lastId = 0;
|
|
712
586
|
for (const part of parts) {
|
|
713
|
-
const
|
|
587
|
+
const html = plain ? '' : toTelegramHtml(part);
|
|
588
|
+
const body = { chat_id: chatId, text: html || part, disable_web_page_preview: true };
|
|
714
589
|
if (html) body.parse_mode = 'HTML';
|
|
715
590
|
// Without message_thread_id every reply lands in the General topic, which is
|
|
716
591
|
// the whole point of carrying the thread through.
|
|
@@ -720,15 +595,18 @@ async function send(chatId, text, threadId = 0, replyTo = 0) {
|
|
|
720
595
|
try {
|
|
721
596
|
res = await tg('sendMessage', body);
|
|
722
597
|
} catch (error) {
|
|
723
|
-
//
|
|
724
|
-
//
|
|
598
|
+
// The fallback must start from the markdown, not from the HTML: resending
|
|
599
|
+
// the markup as plain text is exactly how the person ends up reading
|
|
600
|
+
// `<b>` and `<code>` instead of a sentence.
|
|
725
601
|
if (!html) throw error;
|
|
726
602
|
log(`html send failed (${String(error.message).slice(0, 120)}); resending as plain text`);
|
|
727
603
|
delete body.parse_mode;
|
|
728
|
-
|
|
729
|
-
|
|
604
|
+
for (const piece of chunk(toPlainText(part) || t(lang, 'bridge.progress.empty'), 3800)) {
|
|
605
|
+
body.text = piece;
|
|
606
|
+
res = await tg('sendMessage', body);
|
|
607
|
+
}
|
|
730
608
|
}
|
|
731
|
-
log(`sent chat=${chatId}${threadId ? ` topic=${threadId}` : ''} msg=${res.message_id} len=${
|
|
609
|
+
log(`sent chat=${chatId}${threadId ? ` topic=${threadId}` : ''} msg=${res.message_id} len=${body.text.length}${html ? ' html' : ''}`);
|
|
732
610
|
lastId = res.message_id;
|
|
733
611
|
}
|
|
734
612
|
return lastId;
|
|
@@ -939,7 +817,7 @@ function killTurn(key) {
|
|
|
939
817
|
* thinks for ten minutes still leaves one line in the chat — and the whole trail
|
|
940
818
|
* one tap away.
|
|
941
819
|
*/
|
|
942
|
-
async function startProgress(chatId, threadId, lang = 'ru') {
|
|
820
|
+
async function startProgress(chatId, threadId, lang = 'ru', task = '') {
|
|
943
821
|
const started = Date.now();
|
|
944
822
|
const panelKey = sessionKey(chatId, threadId);
|
|
945
823
|
const steps = [];
|
|
@@ -997,6 +875,7 @@ async function startProgress(chatId, threadId, lang = 'ru') {
|
|
|
997
875
|
// `/thoughts off` keeps the block out of the chat and leaves the counter;
|
|
998
876
|
// the log itself is a file the command sends on demand.
|
|
999
877
|
reasoning: state.thinkBlock?.[panelKey] === 'counter' ? 'counter' : 'block',
|
|
878
|
+
task,
|
|
1000
879
|
cache,
|
|
1001
880
|
});
|
|
1002
881
|
};
|
|
@@ -1498,6 +1377,10 @@ ${t(lang, 'help.body')}`,
|
|
|
1498
1377
|
const sessionAtStart = state.sessions[key];
|
|
1499
1378
|
// Project directory bound to this topic (set with /cd); config.cwd otherwise.
|
|
1500
1379
|
const cwd = (state.cwd && state.cwd[key]) || config.cwd;
|
|
1380
|
+
// What the person actually wrote, before any injected block: the progress
|
|
1381
|
+
// message echoes it back so the first thing they see names their task, not a
|
|
1382
|
+
// generic spinner.
|
|
1383
|
+
const request = text;
|
|
1501
1384
|
|
|
1502
1385
|
// Desktop-style goal: the topic's goal and task list travel with every turn,
|
|
1503
1386
|
// so a fresh session after /new still knows what the project is aiming at.
|
|
@@ -1513,7 +1396,7 @@ ${t(lang, 'help.body')}`,
|
|
|
1513
1396
|
|
|
1514
1397
|
// Live progress: one status message per turn, rewritten as the agent works.
|
|
1515
1398
|
// Without it a long turn and a hung turn looked exactly alike in the chat.
|
|
1516
|
-
const progress = await startProgress(chatId, threadId, lang);
|
|
1399
|
+
const progress = await startProgress(chatId, threadId, lang, request);
|
|
1517
1400
|
// Turn telemetry for the log: what the agent did, how much it cost, on which
|
|
1518
1401
|
// model. Without it /logs shows only "in" and "sent" — useless when asking
|
|
1519
1402
|
// "why did this take 9 minutes".
|
package/i18n.mjs
CHANGED
|
@@ -15,6 +15,7 @@ export const LANGS = ['en', 'ru', 'zh'];
|
|
|
15
15
|
const DICT = {
|
|
16
16
|
en: {
|
|
17
17
|
'status.working': 'Working',
|
|
18
|
+
'status.accepted': 'On it',
|
|
18
19
|
'status.done': 'Done',
|
|
19
20
|
'status.failed': 'Turn failed',
|
|
20
21
|
'status.queued': 'queued',
|
|
@@ -70,7 +71,7 @@ const DICT = {
|
|
|
70
71
|
'profile.badName': 'Name it with lowercase letters, digits and dashes: /profile new my-space from web',
|
|
71
72
|
'profile.set': 'Topic profile → {name} ({route}). Applies from the next turn.',
|
|
72
73
|
'msg.reasoningState': 'Working notes: {state}. Switch with /reasoning on or /reasoning off.',
|
|
73
|
-
'prompt.reasoning': 'Working notes: at each meaningful step — the task is clear, the cause is found, something risky is about to change, the result is checked — append one line of at most 90 characters with `node {say} --thought "..."`. It shows up as 💭 in the progress message: write the decision, not a retelling. Skip it for one-step work.',
|
|
74
|
+
'prompt.reasoning': 'Working notes: at each meaningful step — the task is clear, the cause is found, something risky is about to change, the result is checked — append one line of at most 90 characters with `node {say} --thought "..."`. It shows up as 💭 in the progress message: write the decision, not a retelling. Skip it for one-step work. When a decision changes what the person should expect — a release shipped, a cause found, a blocker — send it to the chat as one plain line: `node {say} --note "..."`. The chat line is for what they must know now, not for every step.',
|
|
74
75
|
'cmd.help.title': 'Commands',
|
|
75
76
|
'cmd.help.hint': 'Send any text to start a task. In a forum topic: /cd <project> binds the topic to that project.',
|
|
76
77
|
'cmd.cd.bound': 'Topic bound to project:\n{path}\n\nAll turns run from this directory.',
|
|
@@ -389,6 +390,7 @@ const DICT = {
|
|
|
389
390
|
},
|
|
390
391
|
ru: {
|
|
391
392
|
'status.working': 'Работаю',
|
|
393
|
+
'status.accepted': 'Принял',
|
|
392
394
|
'status.done': 'Готово',
|
|
393
395
|
'status.failed': 'Ход не удался',
|
|
394
396
|
'status.queued': 'в очереди',
|
|
@@ -444,7 +446,7 @@ const DICT = {
|
|
|
444
446
|
'profile.badName': 'Имя — строчные буквы, цифры и дефис: /profile new my-space from web',
|
|
445
447
|
'profile.set': 'Профиль темы → {name} ({route}). Действует со следующего хода.',
|
|
446
448
|
'msg.reasoningState': 'Заметки по ходу: {state}. Переключить: /reasoning on или /reasoning off.',
|
|
447
|
-
'prompt.reasoning': 'Заметки по ходу: на каждом значимом шаге — задача ясна, причина найдена, сейчас изменю рискованное, результат проверен — дописывай одну строку до 90 символов через `node {say} --thought "..."`. Она видна как 💭 в сообщении прогресса: пиши решение, а не пересказ. Для работы в один шаг не зови.',
|
|
449
|
+
'prompt.reasoning': 'Заметки по ходу: на каждом значимом шаге — задача ясна, причина найдена, сейчас изменю рискованное, результат проверен — дописывай одну строку до 90 символов через `node {say} --thought "..."`. Она видна как 💭 в сообщении прогресса: пиши решение, а не пересказ. Для работы в один шаг не зови. Когда решение меняет то, что человек должен знать сразу — выпущена версия, найдена причина, упёрся в блокер — отправь это в чат одной строкой без разметки: `node {say} --note "..."`. В чат — только то, что важно сейчас, не каждый шаг.',
|
|
448
450
|
'cmd.help.title': 'Команды',
|
|
449
451
|
'cmd.help.hint': 'Любой текст — задача агенту. В теме форума: /cd <проект> привяжет тему к проекту.',
|
|
450
452
|
'cmd.cd.bound': 'Тема привязана к проекту:\n{path}\n\nДальше все команды идут отсюда.',
|
|
@@ -763,6 +765,7 @@ const DICT = {
|
|
|
763
765
|
},
|
|
764
766
|
zh: {
|
|
765
767
|
'status.working': '处理中',
|
|
768
|
+
'status.accepted': '收到',
|
|
766
769
|
'status.done': '完成',
|
|
767
770
|
'status.failed': '运行失败',
|
|
768
771
|
'status.queued': '排队中',
|
|
@@ -818,7 +821,7 @@ const DICT = {
|
|
|
818
821
|
'profile.badName': '名称只能用小写字母、数字和连字符:/profile new my-space from web',
|
|
819
822
|
'profile.set': '话题配置档 → {name}({route})。下一轮生效。',
|
|
820
823
|
'msg.reasoningState': '工作记录:{state}。切换:/reasoning on 或 /reasoning off。',
|
|
821
|
-
'prompt.reasoning': '工作记录:在每个有意义的节点——任务已清楚、原因已找到、即将改动有风险的地方、结果已验证——用 `node {say} --thought "..."` 追加一行,不超过 90 个字符。它会以 💭
|
|
824
|
+
'prompt.reasoning': '工作记录:在每个有意义的节点——任务已清楚、原因已找到、即将改动有风险的地方、结果已验证——用 `node {say} --thought "..."` 追加一行,不超过 90 个字符。它会以 💭 出现在进度消息里:写结论,不要复述。一步就能完成的工作不必调用。当某个决定改变对方需要预期的事——版本已发布、找到原因、遇到阻塞——用一行纯文本发到聊天:`node {say} --note "..."`。聊天里只发此刻重要的内容,不是每一步。',
|
|
822
825
|
'cmd.help.title': '命令',
|
|
823
826
|
'cmd.help.hint': '发送任意文本即可开始任务。在论坛话题中:/cd <项目> 将该话题绑定到项目目录。',
|
|
824
827
|
'cmd.cd.bound': '话题已绑定到项目:\n{path}\n\n之后所有操作都在此目录执行。',
|
package/package.json
CHANGED
package/panel.mjs
CHANGED
|
@@ -90,10 +90,17 @@ export function progressPanel({
|
|
|
90
90
|
// `counter` keeps the reasoning out of the chat: a number in the panel, the
|
|
91
91
|
// log itself in the file that `/thoughts file` sends.
|
|
92
92
|
reasoning = 'block',
|
|
93
|
+
// The person's own request, echoed back in the head. The panel is the first
|
|
94
|
+
// thing sent after a message arrives, so this is what makes that first
|
|
95
|
+
// message say "принял: …" instead of a generic spinner.
|
|
96
|
+
task = '',
|
|
93
97
|
} = {}) {
|
|
98
|
+
const snippet = String(task).replace(/\s+/g, ' ').trim().slice(0, 48);
|
|
94
99
|
const head = final
|
|
95
100
|
? `✅ ${t(lang, 'status.done')} · ${seconds} ${secondsUnit(lang)}`
|
|
96
|
-
:
|
|
101
|
+
: snippet
|
|
102
|
+
? `⏳ ${t(lang, 'status.accepted')}: «${snippet}${String(task).trim().length > 48 ? '…' : ''}» · ${seconds} ${secondsUnit(lang)}`
|
|
103
|
+
: `⏳ ${t(lang, 'status.working')}… ${seconds} ${secondsUnit(lang)}`;
|
|
97
104
|
const mind = thoughts.map((line) => `💭 ${line}`);
|
|
98
105
|
const base = [head, ...mind, cache].filter(Boolean).join('\n').length;
|
|
99
106
|
|
package/say.mjs
CHANGED
|
@@ -7,8 +7,13 @@
|
|
|
7
7
|
//
|
|
8
8
|
// node say.mjs --steer <job-id> "text"
|
|
9
9
|
// node say.mjs --chat <chat-id> [--thread <id>] "text"
|
|
10
|
-
// node say.mjs --thought "short note" (no ids needed)
|
|
10
|
+
// node say.mjs --thought "short note" (no ids needed)
|
|
11
|
+
// node say.mjs --note "short sentence" (a real chat message, no ids needed)
|
|
11
12
|
//
|
|
13
|
+
// `--thought` is a note inside the progress message. `--note` is a real chat
|
|
14
|
+
// message: use it for what the person must know now (a release shipped, a cause
|
|
15
|
+
// found, a blocker), not for every step.
|
|
16
|
+
//
|
|
12
17
|
// `--thought` does not send a message: it appends to the turn's thought file,
|
|
13
18
|
// and the live progress message shows the last two notes as 💭 lines.
|
|
14
19
|
//
|
|
@@ -44,7 +49,7 @@ function jobOf(id) {
|
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
function usage() {
|
|
47
|
-
console.error('usage: node say.mjs --steer <id> "text" | --chat <id> [--thread <id>] "text" | --thought "text"');
|
|
52
|
+
console.error('usage: node say.mjs --steer <id> "text" | --chat <id> [--thread <id>] "text" | --thought "text" | --note "text"');
|
|
48
53
|
process.exit(2);
|
|
49
54
|
}
|
|
50
55
|
|
|
@@ -56,7 +61,8 @@ function parse(argv) {
|
|
|
56
61
|
if (arg === '--steer') out.steer = argv[++i] || '';
|
|
57
62
|
else if (arg === '--chat') out.chatId = Number(argv[++i] || 0);
|
|
58
63
|
else if (arg === '--thread') out.threadId = Number(argv[++i] || 0);
|
|
59
|
-
else if (arg === '--thought') out.thought = true;
|
|
64
|
+
else if (arg === '--thought') out.thought = true;
|
|
65
|
+
else if (arg === '--note') out.note = true;
|
|
60
66
|
else rest.push(arg);
|
|
61
67
|
}
|
|
62
68
|
out.text = rest.join(' ').trim();
|
|
@@ -87,7 +93,7 @@ async function main() {
|
|
|
87
93
|
let jobPath = '';
|
|
88
94
|
// Tool shells do not inherit the bridge's env, so fall back to the thought
|
|
89
95
|
// file the bridge touched at the start of the newest turn.
|
|
90
|
-
if (!chatId && args.thought) {
|
|
96
|
+
if (!chatId && (args.thought || args.note)) {
|
|
91
97
|
const active = activeThoughtFile();
|
|
92
98
|
if (active) {
|
|
93
99
|
chatId = active.chatId;
|