dsh-tg-bridge 1.9.1 → 1.9.2
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/bridge.mjs +3 -19
- package/control.mjs +11 -2
- package/package.json +1 -1
- package/panel.mjs +46 -1
package/bridge.mjs
CHANGED
|
@@ -33,7 +33,7 @@ import { handleControl, CONTROL_COMMANDS, modelOf, reasoningOf } from './control
|
|
|
33
33
|
import { drainGoalJobs, goalOf, renderPromptBlock } from './goals.mjs';
|
|
34
34
|
import { renderPrices } from './prices.mjs';
|
|
35
35
|
import { t, resolveLang } from './i18n.mjs';
|
|
36
|
-
import { progressPanel } from './panel.mjs';
|
|
36
|
+
import { progressPanel, stepLine, addStep } from './panel.mjs';
|
|
37
37
|
|
|
38
38
|
const HOME = homedir();
|
|
39
39
|
const DSH_HOME = process.env.DSH_HOME || join(HOME, '.dsh');
|
|
@@ -925,22 +925,6 @@ function killTurn(key) {
|
|
|
925
925
|
}
|
|
926
926
|
}
|
|
927
927
|
|
|
928
|
-
/** Short, human one-liner for a tool call, mirroring what Hermes shows. */
|
|
929
|
-
function toolLine(event) {
|
|
930
|
-
const tool = event.tool || 'tool';
|
|
931
|
-
const input = event.input ?? {};
|
|
932
|
-
const pick = input.command ?? input.description ?? input.file_path ?? input.path ?? input.pattern ?? input.query ?? input.url ?? '';
|
|
933
|
-
let text = String(pick).replace(/\s+/g, ' ').trim();
|
|
934
|
-
if (input.command) {
|
|
935
|
-
// A shell command is a wall of text; keep the first statement and its
|
|
936
|
-
// verb, so the line reads "pwsh: git status" instead of the whole script.
|
|
937
|
-
text = text.split(';')[0].trim();
|
|
938
|
-
text = text.replace(/^(pwsh|powershell|cmd|bash)(\.exe)?\s+(-\S+\s+)*/i, '');
|
|
939
|
-
const verb = text.match(/^([A-Za-z0-9_.\-]+(?:\s+[a-z][a-z0-9-]*)?)/);
|
|
940
|
-
if (verb) text = verb[1];
|
|
941
|
-
}
|
|
942
|
-
return text ? `${tool}: ${text.slice(0, 48)}` : tool;
|
|
943
|
-
}
|
|
944
928
|
|
|
945
929
|
/**
|
|
946
930
|
* One editable status message per turn.
|
|
@@ -1086,7 +1070,7 @@ async function startProgress(chatId, threadId, lang = 'ru') {
|
|
|
1086
1070
|
},
|
|
1087
1071
|
handle(event) {
|
|
1088
1072
|
if (event.type === 'tool_call') {
|
|
1089
|
-
steps
|
|
1073
|
+
addStep(steps, stepLine(event));
|
|
1090
1074
|
schedule();
|
|
1091
1075
|
return;
|
|
1092
1076
|
}
|
|
@@ -1531,7 +1515,7 @@ ${t(lang, 'help.body')}`,
|
|
|
1531
1515
|
if (event.type === 'tool_call') {
|
|
1532
1516
|
telemetry.tools += 1;
|
|
1533
1517
|
telemetry.steps += 1;
|
|
1534
|
-
log(` tool[${telemetry.steps}] ${
|
|
1518
|
+
log(` tool[${telemetry.steps}] ${(stepLine(event) || event.tool || 'tool').slice(0, 140)}`);
|
|
1535
1519
|
} else if (event.type === 'tool_result') {
|
|
1536
1520
|
const failed = event.status && event.status !== 'completed';
|
|
1537
1521
|
log(` tool[${telemetry.steps}] ${failed ? 'ОШИБКА' : 'ok'} ${String(event.tool || '').slice(0, 40)}`);
|
package/control.mjs
CHANGED
|
@@ -1692,7 +1692,7 @@ export async function handleControl(ctx) {
|
|
|
1692
1692
|
return true;
|
|
1693
1693
|
}
|
|
1694
1694
|
const file = sessionFile(join(DSH_HOME, 'sessions'), sessionId);
|
|
1695
|
-
const text = file ? lastTurnReasoning(file, { maxChars:
|
|
1695
|
+
const text = file ? lastTurnReasoning(file, { maxChars: 20000 }) : '';
|
|
1696
1696
|
if (!text) {
|
|
1697
1697
|
// Not every turn plans: a one-word answer has no reasoning part at all.
|
|
1698
1698
|
// Saying "here is what the last turn answered" beats a dead end that
|
|
@@ -1703,7 +1703,16 @@ export async function handleControl(ctx) {
|
|
|
1703
1703
|
: t(lang, 'ctrl.thoughts.none'));
|
|
1704
1704
|
return true;
|
|
1705
1705
|
}
|
|
1706
|
-
|
|
1706
|
+
// A message caps at 4096 characters; a long plan goes out in parts instead
|
|
1707
|
+
// of being cut at the first one with a "…" that hides the rest.
|
|
1708
|
+
const title = t(lang, 'ctrl.thoughts.title', { chars: text.length });
|
|
1709
|
+
const parts = [];
|
|
1710
|
+
for (let at = 0; at < text.length; at += 3600) parts.push(text.slice(at, at + 3600));
|
|
1711
|
+
parts.forEach((part, index) => {
|
|
1712
|
+
say(parts.length > 1
|
|
1713
|
+
? `${title} (${index + 1}/${parts.length})\n\n${part}`
|
|
1714
|
+
: `${title}\n\n${part}`);
|
|
1715
|
+
});
|
|
1707
1716
|
return true;
|
|
1708
1717
|
}
|
|
1709
1718
|
|
package/package.json
CHANGED
package/panel.mjs
CHANGED
|
@@ -31,6 +31,48 @@ function tailOf(text, room) {
|
|
|
31
31
|
return { text: text.slice(-room), cut: true };
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* One line for a tool call in the panel.
|
|
36
|
+
*
|
|
37
|
+
* The harness runs every call in a fresh shell, so most commands start with
|
|
38
|
+
* `cd <dir>`; that prefix says nothing about the work. Strip it (and the shell
|
|
39
|
+
* wrapper) and keep the statement that does something, with its arguments — a
|
|
40
|
+
* list of bare verbs (`pwsh: cd`, `pwsh: node`) is what made the panel read as
|
|
41
|
+
* noise. A call that only changed directory returns '' and is not shown.
|
|
42
|
+
*/
|
|
43
|
+
export function stepLine(event) {
|
|
44
|
+
const tool = event.tool || 'tool';
|
|
45
|
+
const input = event.input ?? {};
|
|
46
|
+
const pick = input.command ?? input.description ?? input.file_path ?? input.path
|
|
47
|
+
?? input.pattern ?? input.query ?? input.url ?? '';
|
|
48
|
+
let text = String(pick).replace(/\r?\n/g, ' ; ').replace(/\s+/g, ' ').trim();
|
|
49
|
+
if (input.command) {
|
|
50
|
+
text = text.replace(/^(pwsh|powershell|cmd|bash)(\.exe)?\s+(-\S+\s+)*/i, '');
|
|
51
|
+
text = text.replace(/^(cd\s+("[^"]*"|'[^']*'|\S+)\s*(?:&&|;)\s*)+/i, '');
|
|
52
|
+
text = text.replace(/^cd\s+("[^"]*"|'[^']*'|\S+)\s*$/i, '').trim();
|
|
53
|
+
text = text.replace(/\s*(?:&&|;|\|\|)\s*[\s\S]*$/, '').trim();
|
|
54
|
+
if (!text) return '';
|
|
55
|
+
}
|
|
56
|
+
return `${tool}: ${text.slice(0, 64)}`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Push a step, folding a repeat into the line above it: `×3`, not three rows. */
|
|
60
|
+
export function addStep(steps, line) {
|
|
61
|
+
if (!line) return steps;
|
|
62
|
+
const at = steps.length - 1;
|
|
63
|
+
const prev = at >= 0 ? /^(.*) ×(\d+)$/.exec(steps[at]) : null;
|
|
64
|
+
if (at >= 0 && steps[at] === line) {
|
|
65
|
+
steps[at] = `${line} ×2`;
|
|
66
|
+
return steps;
|
|
67
|
+
}
|
|
68
|
+
if (prev && prev[1] === line) {
|
|
69
|
+
steps[at] = `${line} ×${Number(prev[2]) + 1}`;
|
|
70
|
+
return steps;
|
|
71
|
+
}
|
|
72
|
+
steps.push(line);
|
|
73
|
+
return steps;
|
|
74
|
+
}
|
|
75
|
+
|
|
34
76
|
/**
|
|
35
77
|
* One status message per turn, rewritten in place.
|
|
36
78
|
*
|
|
@@ -64,7 +106,10 @@ export function progressPanel({
|
|
|
64
106
|
const fixed = base + inline.join('\n').length + all.text.length + 120;
|
|
65
107
|
const room = Math.max(400, Math.min(THINKING_MAX, PANEL_MAX - fixed));
|
|
66
108
|
const body = tailOf(String(thinking || '').trim(), room);
|
|
67
|
-
|
|
109
|
+
// A cut block starts mid-sentence; say so and point at the one command that
|
|
110
|
+
// still has the whole text, otherwise the reasoning reads as broken.
|
|
111
|
+
const thinkLabel = `🧠 ${t(lang, 'status.thinkTitle')}`
|
|
112
|
+
+ `${body.cut ? ` · ${t(lang, 'status.thinkCut')} · /thoughts` : ''}`;
|
|
68
113
|
|
|
69
114
|
const html = [
|
|
70
115
|
head,
|