dsh-tg-bridge 1.21.0 → 1.22.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/config.example.json +2 -2
- package/goals.mjs +19 -3
- package/i18n/en/core.mjs +2 -1
- package/i18n/ru/core.mjs +2 -1
- package/i18n/zh/core.mjs +2 -1
- package/notes.mjs +55 -0
- package/package.json +2 -1
- package/progress.mjs +16 -14
- package/queue.mjs +33 -4
- package/say.mjs +10 -1
package/config.example.json
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
"profile": "headless",
|
|
5
5
|
"cwd": "",
|
|
6
6
|
"providerKeys": [],
|
|
7
|
-
"pricesUrl": "",
|
|
8
7
|
"turnIdleMs": 120000,
|
|
9
8
|
"turnTimeoutMs": 0,
|
|
10
9
|
"busyNoticeMs": 45000,
|
|
10
|
+
"maxParallel": 3,
|
|
11
11
|
"approvalTimeoutMs": 600000,
|
|
12
12
|
"generalLobby": true,
|
|
13
13
|
"topicLog": true,
|
|
@@ -30,4 +30,4 @@
|
|
|
30
30
|
"patch": "",
|
|
31
31
|
"model": ""
|
|
32
32
|
}
|
|
33
|
-
}
|
|
33
|
+
}
|
package/goals.mjs
CHANGED
|
@@ -68,8 +68,24 @@ export function addTask(state, key, text) {
|
|
|
68
68
|
if (!clean) return null;
|
|
69
69
|
const goal = goalOf(state, key);
|
|
70
70
|
if (!goal) return null;
|
|
71
|
-
|
|
71
|
+
// The cap is on WORK, not on history: a ticked task is a record of what was
|
|
72
|
+
// done, and counting it against the limit froze the list the moment a goal ran
|
|
73
|
+
// long — every new task was rejected in silence, so the checklist stopped
|
|
74
|
+
// matching the work. Ticked entries stay (their numbers stay valid); only the
|
|
75
|
+
// open ones are capped.
|
|
76
|
+
if (goal.tasks.filter((task) => !task.done).length >= MAX_TASKS) return null;
|
|
72
77
|
goal.tasks.push({ text: clean, done: false });
|
|
78
|
+
// Bound the history without touching the work: past 60 lines the oldest ticked
|
|
79
|
+
// entries go, so a goal that runs for months does not carry every closed task
|
|
80
|
+
// in every prompt. A trim renumbers the rest — the block is re-read each turn,
|
|
81
|
+
// so the numbers in front of the agent are always the current ones.
|
|
82
|
+
if (goal.tasks.length > MAX_TASKS * 2) {
|
|
83
|
+
let excess = goal.tasks.length - MAX_TASKS * 2;
|
|
84
|
+
goal.tasks = goal.tasks.filter((task) => {
|
|
85
|
+
if (excess > 0 && task.done) { excess -= 1; return false; }
|
|
86
|
+
return true;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
73
89
|
goal.updatedAt = new Date().toISOString();
|
|
74
90
|
return goal.tasks.length;
|
|
75
91
|
}
|
|
@@ -162,7 +178,7 @@ export function applyGoalJob(state, job) {
|
|
|
162
178
|
}
|
|
163
179
|
case 'add':
|
|
164
180
|
if (!goalOf(state, job.key)) setGoal(state, job.key, 'Tasks');
|
|
165
|
-
return addTask(state, job.key, job.text) ? 'task added' :
|
|
181
|
+
return addTask(state, job.key, job.text) ? 'task added' : `task rejected: ${MAX_TASKS} open`;
|
|
166
182
|
case 'done':
|
|
167
183
|
return doneTask(state, job.key, job.index) ? 'task done' : 'bad task number';
|
|
168
184
|
case 'remove':
|
|
@@ -199,7 +215,7 @@ export function drainGoalJobs(state, dir, doneDir) {
|
|
|
199
215
|
continue;
|
|
200
216
|
}
|
|
201
217
|
const status = applyGoalJob(state, job);
|
|
202
|
-
const ok = !status.startsWith('bad') && status !== 'no goal' && status !== 'empty goal' && status
|
|
218
|
+
const ok = !status.startsWith('bad') && status !== 'no goal' && status !== 'empty goal' && !status.startsWith('task rejected');
|
|
203
219
|
if (ok) applied += 1;
|
|
204
220
|
try {
|
|
205
221
|
renameSync(full, join(doneDir, `${ok ? '' : 'failed-'}${file}`));
|
package/i18n/en/core.mjs
CHANGED
|
@@ -84,6 +84,7 @@ export default {
|
|
|
84
84
|
'err.generic': 'something went wrong',
|
|
85
85
|
'msg.busy.since': '⏳ The previous turn has been running for {min} min — your message is queued.\nIf it stalls, /stop interrupts it and I take yours right away.',
|
|
86
86
|
'msg.busy.now': '⏳ The previous turn is still running — your message is queued.\nIf it stalls, /stop interrupts it and I take yours right away.',
|
|
87
|
+
'msg.slotWait': '⏳ {max} turns are already running in other topics — your message is waiting for a free slot.\nI take it the moment one frees up; /stop in another topic speeds that up.',
|
|
87
88
|
'steer.queued': '↪ Addition received — I will fold it in at the next step of this turn.',
|
|
88
89
|
'steer.ackFallback': '↪ Got the addition — folding it into this turn.',
|
|
89
90
|
'msg.started': 'Telegram bridge for DSH is running (headless). Send a task; /help for commands.',
|
|
@@ -112,7 +113,7 @@ export default {
|
|
|
112
113
|
'profile.badName': 'Name it with lowercase letters, digits and dashes: /profile new my-space from web',
|
|
113
114
|
'profile.set': 'Topic profile → {name} ({route}). Applies from the next turn.',
|
|
114
115
|
'msg.reasoningState': 'Working notes: {state}. Switch with /reasoning on or /reasoning off.',
|
|
115
|
-
'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.
|
|
116
|
+
'prompt.reasoning': 'Working notes: in every turn, 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. Only a turn that is a single tool call may skip it. When a decision changes what the person should expect — a release shipped, a cause found, a blocker, a turn running long — 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.',
|
|
116
117
|
'cmd.help.title': 'Commands',
|
|
117
118
|
'cmd.help.hint': 'Send any text to start a task. In a forum topic: /cd <project> binds the topic to that project.',
|
|
118
119
|
'cmd.cd.bound': 'Topic bound to project:\n{path}\n\nAll turns run from this directory.',
|
package/i18n/ru/core.mjs
CHANGED
|
@@ -84,6 +84,7 @@ export default {
|
|
|
84
84
|
'err.generic': 'что-то пошло не так',
|
|
85
85
|
'msg.busy.since': '⏳ Предыдущий ход идёт уже {min} мин — твоё сообщение в очереди.\nЕсли это затянулось, /stop прервёт ход, и я сразу возьмусь за твоим.',
|
|
86
86
|
'msg.busy.now': '⏳ Предыдущий ход ещё идёт — твоё сообщение в очереди.\nЕсли это затянулось, /stop прервёт ход, и я сразу возьмусь за твоим.',
|
|
87
|
+
'msg.slotWait': '⏳ Сейчас идут {max} хода в других темах — твоё сообщение ждёт свободный слот.\nВозьмусь за него сразу, как освободится; /stop в другой теме ускорит.',
|
|
87
88
|
'steer.queued': '↪ Дополнение принято — передам его на следующем шаге этого хода.',
|
|
88
89
|
'steer.ackFallback': '↪ Принял дополнение — учту его в этом же ходе.',
|
|
89
90
|
'msg.started': 'Telegram-мост DSH запущен (headless). Пиши задачу; /help — команды.',
|
|
@@ -112,7 +113,7 @@ export default {
|
|
|
112
113
|
'profile.badName': 'Имя — строчные буквы, цифры и дефис: /profile new my-space from web',
|
|
113
114
|
'profile.set': 'Профиль темы → {name} ({route}). Действует со следующего хода.',
|
|
114
115
|
'msg.reasoningState': 'Заметки по ходу: {state}. Переключить: /reasoning on или /reasoning off.',
|
|
115
|
-
'prompt.reasoning': 'Заметки по ходу: на каждом значимом шаге — задача ясна, причина найдена, сейчас изменю рискованное, результат проверен — дописывай одну строку до 90 символов через `node {say} --thought "..."`. Она видна как 💭 в сообщении прогресса: пиши решение, а не пересказ.
|
|
116
|
+
'prompt.reasoning': 'Заметки по ходу: в каждом ходе, на каждом значимом шаге — задача ясна, причина найдена, сейчас изменю рискованное, результат проверен — дописывай одну строку до 90 символов через `node {say} --thought "..."`. Она видна как 💭 в сообщении прогресса: пиши решение, а не пересказ. Пропускать можно только если весь ход — один вызов инструмента. Когда решение меняет то, что человек должен знать сразу — выпущена версия, найдена причина, упёрся в блокер, ход идёт долго — отправь это в чат одной строкой без разметки: `node {say} --note "..."`. В чат — только то, что важно сейчас, не каждый шаг.',
|
|
116
117
|
'cmd.help.title': 'Команды',
|
|
117
118
|
'cmd.help.hint': 'Любой текст — задача агенту. В теме форума: /cd <проект> привяжет тему к проекту.',
|
|
118
119
|
'cmd.cd.bound': 'Тема привязана к проекту:\n{path}\n\nДальше все команды идут отсюда.',
|
package/i18n/zh/core.mjs
CHANGED
|
@@ -84,6 +84,7 @@ export default {
|
|
|
84
84
|
'err.generic': '出现错误',
|
|
85
85
|
'msg.busy.since': '⏳ 上一轮已运行 {min} 分钟 —— 你的消息在队列中。\n如果太久,/stop 会中断它,我马上处理你的消息。',
|
|
86
86
|
'msg.busy.now': '⏳ 上一轮还在运行 —— 你的消息在队列中。\n如果太久,/stop 会中断它,我马上处理你的消息。',
|
|
87
|
+
'msg.slotWait': '⏳ 其他话题已有 {max} 轮在运行 —— 你的消息在等待空位。\n一旦有空位我就接手;在别的话题里 /stop 可以加快。',
|
|
87
88
|
'steer.queued': '↪ 已收到补充 — 会在这一轮的下一步并入。',
|
|
88
89
|
'steer.ackFallback': '↪ 收到补充,会在本轮里一并处理。',
|
|
89
90
|
'msg.started': 'DSH 的 Telegram 桥已启动(headless)。直接发送任务;/help 查看命令。',
|
|
@@ -112,7 +113,7 @@ export default {
|
|
|
112
113
|
'profile.badName': '名称只能用小写字母、数字和连字符:/profile new my-space from web',
|
|
113
114
|
'profile.set': '话题配置档 → {name}({route})。下一轮生效。',
|
|
114
115
|
'msg.reasoningState': '工作记录:{state}。切换:/reasoning on 或 /reasoning off。',
|
|
115
|
-
'prompt.reasoning': '
|
|
116
|
+
'prompt.reasoning': '工作记录:每一轮在每个有意义的节点——任务已清楚、原因已找到、即将改动有风险的地方、结果已验证——用 `node {say} --thought "..."` 追加一行,不超过 90 个字符。它会以 💭 出现在进度消息里:写结论,不要复述。只有整轮只是一次工具调用时才可以跳过。当某个决定改变对方需要预期的事——版本已发布、找到原因、遇到阻塞、这一轮跑得很久——用一行纯文本发到聊天:`node {say} --note "..."`。聊天里只发此刻重要的内容,不是每一步。',
|
|
116
117
|
'cmd.help.title': '命令',
|
|
117
118
|
'cmd.help.hint': '发送任意文本即可开始任务。在论坛话题中:/cd <项目> 将该话题绑定到项目目录。',
|
|
118
119
|
'cmd.cd.bound': '话题已绑定到项目:\n{path}\n\n之后所有操作都在此目录执行。',
|
package/notes.mjs
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Reading the 💭 notes a turn writes with `say.mjs --thought`.
|
|
2
|
+
//
|
|
3
|
+
// Two files exist for one topic and both are written in practice:
|
|
4
|
+
//
|
|
5
|
+
// <chat>_<thread>_<turn>.jsonl the turn's own file, named by the bridge and
|
|
6
|
+
// exported as DSH_TG_THOUGHT — unique per turn,
|
|
7
|
+
// so two turns in one topic never mix;
|
|
8
|
+
// <chat>_<thread>.jsonl the stable per-topic file, used whenever the
|
|
9
|
+
// tool shell lost the environment (it usually
|
|
10
|
+
// does) or the agent passed explicit ids.
|
|
11
|
+
//
|
|
12
|
+
// The progress card used to read only the first, so a note written through the
|
|
13
|
+
// second was invisible: the 💭 block stayed empty while the file on disk kept
|
|
14
|
+
// growing. This module reads both and keeps only the lines that belong to the
|
|
15
|
+
// turn being displayed — an older line from the previous turn in the same topic
|
|
16
|
+
// is not this turn's progress.
|
|
17
|
+
import { readFileSync } from 'node:fs';
|
|
18
|
+
|
|
19
|
+
/** Every note in one file, as `{ at, text }`, oldest first. Missing file = []. */
|
|
20
|
+
export function readNotes(file) {
|
|
21
|
+
try {
|
|
22
|
+
return readFileSync(file, 'utf8')
|
|
23
|
+
.split('\n')
|
|
24
|
+
.filter(Boolean)
|
|
25
|
+
.map((line) => {
|
|
26
|
+
try {
|
|
27
|
+
const row = JSON.parse(line);
|
|
28
|
+
const text = String(row.text || '').trim();
|
|
29
|
+
return text ? { at: Number(row.at) || 0, text: text.slice(0, 140) } : null;
|
|
30
|
+
} catch { return null; }
|
|
31
|
+
})
|
|
32
|
+
.filter(Boolean);
|
|
33
|
+
} catch { return []; }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The last `limit` note texts across `files`, written at or after `since`.
|
|
38
|
+
*
|
|
39
|
+
* `since` is the turn's start time: it is what separates "this turn said X" from
|
|
40
|
+
* "a previous turn in this topic said X". Notes without a timestamp are dropped
|
|
41
|
+
* rather than shown at the wrong moment.
|
|
42
|
+
*/
|
|
43
|
+
export function recentThoughts(files, since = 0, limit = 2) {
|
|
44
|
+
const seen = new Set();
|
|
45
|
+
return files
|
|
46
|
+
.filter(Boolean)
|
|
47
|
+
.flatMap(readNotes)
|
|
48
|
+
.filter((row) => row.at > 0 && row.at >= since && row.text)
|
|
49
|
+
// The same note can sit in both files when `say.mjs` wrote to each; a
|
|
50
|
+
// duplicated 💭 line reads as two decisions instead of one.
|
|
51
|
+
.filter((row) => (seen.has(`${row.at}:${row.text}`) ? false : seen.add(`${row.at}:${row.text}`)))
|
|
52
|
+
.sort((a, b) => a.at - b.at)
|
|
53
|
+
.slice(-limit)
|
|
54
|
+
.map((row) => row.text);
|
|
55
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-tg-bridge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.0",
|
|
4
4
|
"description": "Telegram bridge for DeepSeek Harness: text, voice, photos and project-per-topic sessions without opening the desktop app",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "plugin-bridge.mjs",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"keys.mjs",
|
|
55
55
|
"keyboards.mjs",
|
|
56
56
|
"progress.mjs",
|
|
57
|
+
"notes.mjs",
|
|
57
58
|
"turn.mjs",
|
|
58
59
|
"control.mjs",
|
|
59
60
|
"control/release.mjs",
|
package/progress.mjs
CHANGED
|
@@ -14,6 +14,7 @@ import { tg } from './telegram.mjs';
|
|
|
14
14
|
import { topicName } from './topics.mjs';
|
|
15
15
|
import { t } from './i18n.mjs';
|
|
16
16
|
import { addStep, progressPanel, stepLine } from './panel.mjs';
|
|
17
|
+
import { recentThoughts } from './notes.mjs';
|
|
17
18
|
import { continueKeyboard, errorKeyboard } from './keyboards.mjs';
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -60,26 +61,27 @@ export async function startProgress(chatId, threadId, lang = config.lang || 'en'
|
|
|
60
61
|
// message shows the last two, so the person sees the decision trail without
|
|
61
62
|
// a second stream of chat messages. The path is unique per turn (see
|
|
62
63
|
// startTurn) so two turns never share one file.
|
|
64
|
+
//
|
|
65
|
+
// Two writers exist and they do not agree on the path. The turn's own file
|
|
66
|
+
// (`DSH_TG_THOUGHT`) is only reachable when the tool shell inherits the
|
|
67
|
+
// bridge's environment, and tool shells usually do not — so `say.mjs` falls
|
|
68
|
+
// back to the stable per-topic file. Reading only the first path silently
|
|
69
|
+
// dropped every note: the 💭 block stayed empty for a whole session while the
|
|
70
|
+
// topic file on disk kept growing. Read both, keep this turn's lines only.
|
|
63
71
|
const notes = thoughtFile || join(THOUGHT_DIR, `${chatId}_${threadId || 0}.jsonl`);
|
|
72
|
+
const topicNotes = join(THOUGHT_DIR, `${chatId}_${threadId || 0}.jsonl`);
|
|
64
73
|
let thoughts = [];
|
|
65
74
|
try {
|
|
66
75
|
mkdirSync(THOUGHT_DIR, { recursive: true });
|
|
67
|
-
|
|
76
|
+
// Start this turn's file empty — but never truncate the stable per-topic
|
|
77
|
+
// file, which is shared history and the only record when a turn wrote
|
|
78
|
+
// through the fallback path.
|
|
79
|
+
if (thoughtFile) writeFileSync(notes, '');
|
|
68
80
|
} catch {}
|
|
69
81
|
const thoughtTimer = setInterval(() => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
.split('\n')
|
|
74
|
-
.filter(Boolean)
|
|
75
|
-
.slice(-2)
|
|
76
|
-
.map((line) => {
|
|
77
|
-
try { return String(JSON.parse(line).text || '').slice(0, 140); } catch { return ''; }
|
|
78
|
-
})
|
|
79
|
-
.filter(Boolean);
|
|
80
|
-
} catch {}
|
|
81
|
-
if (next.join('\n') !== thoughts.join('\n')) {
|
|
82
|
-
thoughts = next;
|
|
82
|
+
const merged = recentThoughts([notes, topicNotes], started);
|
|
83
|
+
if (merged.join('\n') !== thoughts.join('\n')) {
|
|
84
|
+
thoughts = merged;
|
|
83
85
|
schedule();
|
|
84
86
|
}
|
|
85
87
|
}, 3000);
|
package/queue.mjs
CHANGED
|
@@ -12,8 +12,8 @@ import { resolveLang, t } from './i18n.mjs';
|
|
|
12
12
|
import { sessionKey, threadOf } from './keys.mjs';
|
|
13
13
|
import { RESTART_MARKER } from './paths.mjs';
|
|
14
14
|
import { config, log, state } from './state.mjs';
|
|
15
|
-
import { clearBusyNotice, steerAvailable, steerMediaMessage } from './steer.mjs';
|
|
16
|
-
import { tg } from './telegram.mjs';
|
|
15
|
+
import { busyNotices, clearBusyNotice, steerAvailable, steerMediaMessage } from './steer.mjs';
|
|
16
|
+
import { send, tg } from './telegram.mjs';
|
|
17
17
|
import { liveSessions, profileOf, turnStartedAt } from './turn.mjs';
|
|
18
18
|
|
|
19
19
|
/** The message handler is wired in by the entry module: it owns the turn. */
|
|
@@ -27,10 +27,25 @@ const redeliver = (key, message) => enqueue(key, () => handle(message));
|
|
|
27
27
|
export const queues = new Map();
|
|
28
28
|
export const waiting = [];
|
|
29
29
|
export let running = 0;
|
|
30
|
+
/** Default cap; `config.maxParallel` overrides it for one install. */
|
|
30
31
|
export const MAX_PARALLEL = 3;
|
|
31
32
|
|
|
33
|
+
/**
|
|
34
|
+
* How many turns may run at once.
|
|
35
|
+
*
|
|
36
|
+
* Three was a guess that fit a small machine, and it is a real ceiling: with
|
|
37
|
+
* three long turns in flight a fourth topic waited with no message at all, so a
|
|
38
|
+
* prompt in a fresh topic looked exactly like a dead bot. The number is a
|
|
39
|
+
* setting now, and waiting for a slot is announced (see `enqueue`).
|
|
40
|
+
*/
|
|
41
|
+
export function maxParallel() {
|
|
42
|
+
const raw = Number(config?.maxParallel);
|
|
43
|
+
if (!Number.isFinite(raw)) return MAX_PARALLEL;
|
|
44
|
+
return Math.min(8, Math.max(1, Math.round(raw)));
|
|
45
|
+
}
|
|
46
|
+
|
|
32
47
|
export function acquire() {
|
|
33
|
-
if (running <
|
|
48
|
+
if (running < maxParallel()) {
|
|
34
49
|
running += 1;
|
|
35
50
|
return Promise.resolve();
|
|
36
51
|
}
|
|
@@ -112,7 +127,21 @@ export function enqueue(key, task, onBusy) {
|
|
|
112
127
|
const prev = queues.get(key) || Promise.resolve();
|
|
113
128
|
const queued = queues.has(key);
|
|
114
129
|
const run = prev
|
|
115
|
-
.then(() =>
|
|
130
|
+
.then(() => {
|
|
131
|
+
// A turn waiting for a free slot used to wait in total silence: with three
|
|
132
|
+
// long turns running, a prompt in a fourth topic showed nothing at all —
|
|
133
|
+
// not even "queued" — so the bot looked dead in that topic. Say it once,
|
|
134
|
+
// in the topic that is waiting; `clearBusyNotice` removes it when the turn
|
|
135
|
+
// actually starts.
|
|
136
|
+
if (!queued && running >= maxParallel()) {
|
|
137
|
+
const [chatId, threadId] = String(key).split(':');
|
|
138
|
+
const lang = resolveLang(state, key, null, config);
|
|
139
|
+
Promise.resolve(send(chatId, t(lang, 'msg.slotWait', { max: maxParallel() }), Number(threadId) || 0))
|
|
140
|
+
.then((messageId) => { if (messageId) busyNotices.set(key, { chatId, messageId }); })
|
|
141
|
+
.catch(() => {});
|
|
142
|
+
}
|
|
143
|
+
return acquire();
|
|
144
|
+
})
|
|
116
145
|
.then(async () => {
|
|
117
146
|
// The person was told "your message is queued"; that notice has done its
|
|
118
147
|
// job the moment the turn starts and must not linger in the chat.
|
package/say.mjs
CHANGED
|
@@ -123,7 +123,16 @@ async function main() {
|
|
|
123
123
|
if (args.thought) {
|
|
124
124
|
try {
|
|
125
125
|
mkdirSync(THOUGHTS, { recursive: true });
|
|
126
|
-
|
|
126
|
+
// The turn's own file when the bridge exported one: two turns in the same
|
|
127
|
+
// topic then never mix, and the panel reads that file directly. The stable
|
|
128
|
+
// per-topic name stays the fallback for a shell that lost the env, and the
|
|
129
|
+
// panel reads both — so a note never lands in a file nobody reads, which
|
|
130
|
+
// is exactly what made 💭 stay empty while the file on disk kept growing.
|
|
131
|
+
const explicit = (process.env.DSH_TG_THOUGHT || '').trim();
|
|
132
|
+
const own = explicit && explicit.split(/[\\/]/).pop()?.startsWith(`${chatId}_${threadId || 0}_`)
|
|
133
|
+
? explicit
|
|
134
|
+
: '';
|
|
135
|
+
const file = own || join(THOUGHTS, `${chatId}_${threadId || 0}.jsonl`);
|
|
127
136
|
appendFileSync(file, `${JSON.stringify({ at: Date.now(), text: args.text })}\n`, 'utf8');
|
|
128
137
|
console.log(file);
|
|
129
138
|
} catch (error) {
|