dsh-tg-bridge 1.25.1 → 1.25.3
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 +24 -13
- package/control/cmd-fallback.mjs +20 -5
- package/control/cmd-views.mjs +13 -9
- package/control/tasks.mjs +10 -6
- package/handle-message.mjs +10 -3
- package/i18n/en/core.mjs +11 -4
- package/i18n/en/ctrl.mjs +2 -2
- package/i18n/ru/core.mjs +11 -4
- package/i18n/ru/ctrl.mjs +2 -2
- package/i18n/zh/core.mjs +11 -4
- package/i18n/zh/ctrl.mjs +2 -2
- package/model-probe.mjs +15 -3
- package/notes.mjs +40 -8
- package/package.json +1 -1
- package/progress.mjs +40 -2
- package/settings-card.mjs +14 -4
package/README.md
CHANGED
|
@@ -271,7 +271,7 @@ Updates: /update · /update confirm · /update on|off|check|auto · /subscr
|
|
|
271
271
|
Diagnostics: /doctor · /logs [errors|N|text] · /report
|
|
272
272
|
Service: /app · /restart · /help
|
|
273
273
|
Settings: /settings — the same switches as buttons, grouped in four tabs
|
|
274
|
-
Display: /lang · /reasoning
|
|
274
|
+
Display: /lang · /reasoning off|card|chat · /thoughts
|
|
275
275
|
```
|
|
276
276
|
|
|
277
277
|
### Settings as a card
|
|
@@ -280,7 +280,7 @@ Display: /lang · /reasoning on|off · /thoughts
|
|
|
280
280
|
four tabs: what the bot says, who answers and how hard it works, new releases,
|
|
281
281
|
and the health checks. Each row shows what the setting is now and what a tap
|
|
282
282
|
would change it to. A tap runs the command a person would have typed
|
|
283
|
-
(`/reasoning
|
|
283
|
+
(`/reasoning chat`, `/update on`), so the card cannot disagree with the command:
|
|
284
284
|
it is a view of them. After the change the card collapses into one plain line —
|
|
285
285
|
delete it and the chat is back to what it was.
|
|
286
286
|
|
|
@@ -425,7 +425,7 @@ node ~/.dsh/tg-bridge/say.mjs --thought "checking why the watchdog fired twice"
|
|
|
425
425
|
The note is appended to `~/.dsh/tg-bridge/thoughts/<chat>_<thread>.jsonl`; the progress
|
|
426
426
|
message shows the last two as `💭` lines. The command needs no ids: it falls back to the
|
|
427
427
|
newest turn's thought file, because tool shells do not inherit the bridge environment.
|
|
428
|
-
`--thought`
|
|
428
|
+
`--thought` sends a Telegram message of its own only in `/reasoning chat` mode.
|
|
429
429
|
|
|
430
430
|
A decision the person must know before the turn ends — a release shipped, a cause found,
|
|
431
431
|
a blocker — goes to the chat as one plain line instead:
|
|
@@ -435,16 +435,27 @@ node ~/.dsh/tg-bridge/say.mjs --note "1.10.1 is on npm; restart to load it"
|
|
|
435
435
|
```
|
|
436
436
|
|
|
437
437
|
`--note` sends a real message and takes the same no-ids fallback as `--thought`. The split
|
|
438
|
-
is deliberate: `--thought` is the working trail inside the progress message,
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
438
|
+
is deliberate: `--thought` is the working trail (inside the progress message, and in `chat`
|
|
439
|
+
mode also as its own messages), `--note` is the short line that changes what the reader
|
|
440
|
+
expects to happen next — useful in `card` and `off` mode, redundant in `chat`. The progress
|
|
441
|
+
message itself opens with the request echoed back (`⏳ Принял: «…» · 3 с`), so the first
|
|
442
|
+
thing the person sees after sending names their task rather than a generic spinner.
|
|
443
|
+
|
|
444
|
+
`/reasoning` is the switch for the 💭 mechanism, and it has three ends:
|
|
445
|
+
|
|
446
|
+
- `/reasoning card` (the default) — every turn carries a short instruction to leave one line
|
|
447
|
+
at each decision point (task clear, cause found, risky change, result checked), and the
|
|
448
|
+
progress message shows the last two;
|
|
449
|
+
- `/reasoning chat` — the same lines, each also posted as its own message, so a turn that
|
|
450
|
+
runs for twenty minutes is read as it happens instead of scrolled back to afterwards.
|
|
451
|
+
The prompt says so explicitly, so a line is written to stand alone;
|
|
452
|
+
- `/reasoning off` — drops the instruction and the `💭` lines for that topic, for when the
|
|
453
|
+
step list is all you want.
|
|
454
|
+
|
|
455
|
+
A topic switched to `chat` mid-turn does not dump the steps already in the card: forwarding
|
|
456
|
+
starts with the next line written. The setting lives in `state.json` per topic, so a chatty
|
|
457
|
+
research topic and a terse deploy topic can differ; a `true`/`false` written by an older
|
|
458
|
+
release still reads as `card`/`off`. The settings card offers the same three ends as buttons.
|
|
448
459
|
|
|
449
460
|
The reasoning block itself is model output; `/thoughts` is what reads it back:
|
|
450
461
|
|
package/control/cmd-fallback.mjs
CHANGED
|
@@ -22,7 +22,7 @@ function providerIds(profile) {
|
|
|
22
22
|
return providerRows(read(patchPath(profile))).map((row) => row.id).filter(Boolean);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
/** `
|
|
25
|
+
/** `router-a/kimi-k3:free` → `{provider, model}`; a bare id keeps the given provider. */
|
|
26
26
|
export function splitRoute(wanted, fallbackProvider = '') {
|
|
27
27
|
const text = String(wanted || '').trim();
|
|
28
28
|
const at = text.indexOf('/');
|
|
@@ -192,6 +192,12 @@ export async function handleFallbackCommands(ctx) {
|
|
|
192
192
|
|
|
193
193
|
// A probe proves the key works, not that this conversation is acceptable: the
|
|
194
194
|
// hint says so, because "route is fine" beside a 400 would be a lie.
|
|
195
|
+
//
|
|
196
|
+
// Providers are asked in parallel, routes of ONE provider one after another:
|
|
197
|
+
// seven routes at a 15-second timeout each is nearly two minutes of a command
|
|
198
|
+
// that looks frozen, but five of those routes may sit on one key, and a burst
|
|
199
|
+
// of seven requests is itself a rate limit. The probe would then report the
|
|
200
|
+
// chain as busy and be right about the probe, wrong about the chain.
|
|
195
201
|
case 'test':
|
|
196
202
|
case 'x': {
|
|
197
203
|
const targets = entry ? [entry] : chain;
|
|
@@ -199,12 +205,21 @@ export async function handleFallbackCommands(ctx) {
|
|
|
199
205
|
say(t(lang, 'ctrl.fallback.empty'));
|
|
200
206
|
return true;
|
|
201
207
|
}
|
|
202
|
-
const
|
|
208
|
+
const byProvider = new Map();
|
|
203
209
|
for (const item of targets) {
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
210
|
+
const id = item.provider || '';
|
|
211
|
+
if (!byProvider.has(id)) byProvider.set(id, []);
|
|
212
|
+
byProvider.get(id).push(item);
|
|
207
213
|
}
|
|
214
|
+
const verdicts = new Map();
|
|
215
|
+
await Promise.all([...byProvider.values()].map(async (group) => {
|
|
216
|
+
for (const item of group) verdicts.set(item, await probeModel(item.model, { provider: item.provider }));
|
|
217
|
+
}));
|
|
218
|
+
const rows = targets.map((item) => {
|
|
219
|
+
const verdict = verdicts.get(item) || { kind: 'other' };
|
|
220
|
+
log(`fallback probe ${labelOf(item)}: ${verdict.kind}${verdict.detail ? ` (${String(verdict.detail).slice(0, 80)})` : ''}`);
|
|
221
|
+
return { n: chain.indexOf(item) + 1, route: labelOf(item), kind: VERDICT[verdict.kind] || 'other' };
|
|
222
|
+
});
|
|
208
223
|
// One way back to the card: the probe answer is long, and the person who
|
|
209
224
|
// just learned route 4 is dead wants the list, not a typed command.
|
|
210
225
|
say(renderProbe({ t: tr, rows }), { keyboard: [[{ text: t(lang, 'ctrl.fallback.back'), data: 'fb:s' }]] });
|
package/control/cmd-views.mjs
CHANGED
|
@@ -31,6 +31,7 @@ import { cwdSlug, bareId, stamp, recentSessions, sessionTitle } from './sessions
|
|
|
31
31
|
import { agentsOf, fleetOf, patchRows, skillsOf, AGENTS, PERSONA_HEADING, soulOf, setSoul } from './agents.mjs';
|
|
32
32
|
import { fmt, AGENTSETS, agentset, agentsetOf, profileRowOf, bindAgentset, agentsetCard, agentsetKeyboard } from './agentsets.mjs';
|
|
33
33
|
import { taskKeyboard, goalView, taskView, reasoningOf, filterLogLines } from './tasks.mjs';
|
|
34
|
+
import { reasoningMode } from '../notes.mjs';
|
|
34
35
|
import { updatePolicy, bridgeRoot, copyRelease, installRelease, bridgeVersion, newestModuleMtime, npmLatest, npmLatestAsync } from './release.mjs';
|
|
35
36
|
import { presetOf } from '../profile-view.mjs';
|
|
36
37
|
|
|
@@ -81,7 +82,7 @@ export async function handleViewCommands(ctx) {
|
|
|
81
82
|
state: active > 0 ? t(lang, 'ctrl.status.running') : t(lang, 'ctrl.status.idle'),
|
|
82
83
|
}));
|
|
83
84
|
lines.push(t(lang, 'ctrl.status.notes', {
|
|
84
|
-
state:
|
|
85
|
+
state: t(lang, `msg.reasoningMode.${reasoningMode(state, config, key)}`),
|
|
85
86
|
}));
|
|
86
87
|
lines.push(t(lang, 'ctrl.status.skills', { n: skillsOf().length }));
|
|
87
88
|
// The desktop profile only matters when this install actually has one.
|
|
@@ -269,19 +270,22 @@ export async function handleViewCommands(ctx) {
|
|
|
269
270
|
return true;
|
|
270
271
|
}
|
|
271
272
|
case '/reasoning': {
|
|
272
|
-
// One switch for "
|
|
273
|
-
// the
|
|
273
|
+
// One switch for "how much of the decision trail reaches me": off, the
|
|
274
|
+
// progress card, or the chat itself. Anything else prints the current
|
|
275
|
+
// state, so a bare /reasoning never guesses.
|
|
274
276
|
const wanted = String(arg || '').trim().toLowerCase();
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
say(t(lang, 'msg.reasoningState', { state:
|
|
277
|
+
const mode = reasoningMode(state, config, key);
|
|
278
|
+
const next = { on: 'card', card: 'card', chat: 'chat', off: 'off' }[wanted];
|
|
279
|
+
if (!next) {
|
|
280
|
+
say(t(lang, 'msg.reasoningState', { state: t(lang, `msg.reasoningMode.${mode}`) }));
|
|
279
281
|
return true;
|
|
280
282
|
}
|
|
281
283
|
state.reasoning = state.reasoning || {};
|
|
282
|
-
|
|
284
|
+
// `on` is the old spelling of the card and stays accepted: it is the word
|
|
285
|
+
// the previous release printed, and a chat is full of those instructions.
|
|
286
|
+
state.reasoning[key] = next;
|
|
283
287
|
ctx.saveState();
|
|
284
|
-
say(t(lang,
|
|
288
|
+
say(t(lang, next === 'off' ? 'msg.reasoningOff' : next === 'chat' ? 'msg.reasoningChat' : 'msg.reasoningOn'));
|
|
285
289
|
return true;
|
|
286
290
|
}
|
|
287
291
|
case '/thoughts': {
|
package/control/tasks.mjs
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { t } from '../i18n.mjs';
|
|
6
6
|
import { progressOf } from '../goals.mjs';
|
|
7
7
|
import { COMMAND_ALIASES, CONTROL_COMMANDS, DOCUMENTED_COMMANDS } from '../commands-registry.mjs';
|
|
8
|
+
import { reasoningMode } from '../notes.mjs';
|
|
8
9
|
|
|
9
10
|
import { read } from './models.mjs';
|
|
10
11
|
/**
|
|
@@ -60,14 +61,17 @@ export function taskView(goal, lang) {
|
|
|
60
61
|
export { CONTROL_COMMANDS, COMMAND_ALIASES, DOCUMENTED_COMMANDS };
|
|
61
62
|
|
|
62
63
|
/**
|
|
63
|
-
* Working notes ("💭" lines
|
|
64
|
-
*
|
|
65
|
-
*
|
|
64
|
+
* Working notes ("💭" lines) are on unless the topic or the config says
|
|
65
|
+
* otherwise. Per-topic wins over the install default, so one topic can keep the
|
|
66
|
+
* trail while another stays terse.
|
|
67
|
+
*
|
|
68
|
+
* Three ends, one job: `off`, `card` (the last two lines inside the progress
|
|
69
|
+
* message) and `chat` (every line as its own message). `reasoningOf` stays the
|
|
70
|
+
* boolean question the prompt asks — "does this turn write notes at all" — and
|
|
71
|
+
* `reasoningMode` answers the one the panel asks.
|
|
66
72
|
*/
|
|
67
73
|
export function reasoningOf(state, config, key) {
|
|
68
|
-
|
|
69
|
-
if (typeof perTopic === 'boolean') return perTopic;
|
|
70
|
-
return config?.reasoning !== false;
|
|
74
|
+
return reasoningMode(state, config, key) !== 'off';
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
/**
|
package/handle-message.mjs
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
// it calls lives in a module of its own.
|
|
7
7
|
|
|
8
8
|
import { GENERAL_SAFE, commandOf } from './commands.mjs';
|
|
9
|
-
import { CONTROL_COMMANDS, handleControl, modelOf
|
|
9
|
+
import { CONTROL_COMMANDS, handleControl, modelOf } from './control.mjs';
|
|
10
|
+
import { reasoningMode } from './notes.mjs';
|
|
10
11
|
import { explainFailure } from './failures.mjs';
|
|
11
12
|
import { runFallbackChain } from './fallback.mjs';
|
|
12
13
|
import { goalOf, renderPromptBlock } from './goals.mjs';
|
|
@@ -336,8 +337,14 @@ ${t(lang, 'help.body')}`,
|
|
|
336
337
|
// The alias is the plain topic name too; it is written as the turn's file so
|
|
337
338
|
// a reader that never heard of DSH_TG_THOUGHT still finds this turn's notes.
|
|
338
339
|
const thoughtEnv = { DSH_TG_THOUGHT: thoughtFile };
|
|
339
|
-
|
|
340
|
-
|
|
340
|
+
// In `chat` mode every 💭 line is also posted as its own message, so the
|
|
341
|
+
// prompt has to say that out loud: a line written for a small grey card reads
|
|
342
|
+
// differently when it lands in the chat as a message of its own.
|
|
343
|
+
const notesMode = reasoningMode(state, config, key);
|
|
344
|
+
if (notesMode !== 'off') {
|
|
345
|
+
const prompt = t(lang, 'prompt.reasoning', { say: join(DIR, 'say.mjs') });
|
|
346
|
+
const note = notesMode === 'chat' ? `\n\n${t(lang, 'prompt.reasoningChat')}` : '';
|
|
347
|
+
text = `${prompt}${note}\n\n---\n\n${text}`;
|
|
341
348
|
}
|
|
342
349
|
|
|
343
350
|
// Live progress: one status message per turn, rewritten as the agent works.
|
package/i18n/en/core.mjs
CHANGED
|
@@ -20,7 +20,9 @@ export default {
|
|
|
20
20
|
'settings.updates.title': 'New releases (this install, not this topic)',
|
|
21
21
|
'settings.health.title': 'If something is off',
|
|
22
22
|
'settings.reasoning.label': 'Working notes',
|
|
23
|
-
'settings.reasoning.hint': 'The 💭 lines in the progress
|
|
23
|
+
'settings.reasoning.hint': 'The 💭 lines: in the progress card, also as messages in the chat, or off.',
|
|
24
|
+
'settings.reasoning.chat': 'chat',
|
|
25
|
+
'settings.reasoning.card': 'card',
|
|
24
26
|
'settings.lang.label': 'Reply language',
|
|
25
27
|
'settings.lang.hint': 'auto answers in the language of your message; en, ru, zh pin it.',
|
|
26
28
|
'settings.thoughts.label': '💭 Working notes: last turn, all, or off',
|
|
@@ -98,6 +100,10 @@ export default {
|
|
|
98
100
|
'msg.langSet': 'Language set to English.',
|
|
99
101
|
'msg.reasoningOn': 'Working notes on: 💭 lines will appear in the progress message.\nOff: /reasoning off',
|
|
100
102
|
'msg.reasoningOff': 'Working notes off. The progress message keeps the step list only.\nOn: /reasoning on',
|
|
103
|
+
'msg.reasoningChat': 'Working notes go to the chat: every 💭 line arrives as its own message, so a long turn can be read while it runs.\nBack into the card: /reasoning card',
|
|
104
|
+
'msg.reasoningMode.off': 'off',
|
|
105
|
+
'msg.reasoningMode.card': 'in the progress message',
|
|
106
|
+
'msg.reasoningMode.chat': 'in the chat and in the progress message',
|
|
101
107
|
'msg.stateOn': 'on',
|
|
102
108
|
'msg.stateOff': 'off',
|
|
103
109
|
'msg.turnHardCap': 'The turn hit the {minutes}-minute ceiling and was stopped. Nothing is lost: the session is kept — press Continue and I will check the state and go on from where I stopped.',
|
|
@@ -114,8 +120,9 @@ export default {
|
|
|
114
120
|
'profile.createFailed': 'Could not create profile {name} — the template was not written. Try again or create it in the app.',
|
|
115
121
|
'profile.badName': 'Name it with lowercase letters, digits and dashes: /profile new my-space from web',
|
|
116
122
|
'profile.set': 'Topic profile → {name} ({route}). Applies from the next turn.',
|
|
117
|
-
'msg.reasoningState': 'Working notes: {state}. Switch with /reasoning
|
|
118
|
-
'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.',
|
|
123
|
+
'msg.reasoningState': 'Working notes: {state}. Switch with /reasoning off, /reasoning card or /reasoning chat.',
|
|
124
|
+
'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. Keep the line plain — no markup, no secrets, no paths to credentials — because in chat mode it is also posted as a message of its own. 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.',
|
|
125
|
+
'prompt.reasoningChat': 'This topic is in chat mode: every 💭 line is also posted to the chat as its own message, so a person reading only the chat sees the steps as they happen. Write each line to stand alone — what changed and why it matters — and never put a secret, a token or a private path in it.',
|
|
119
126
|
'cmd.help.title': 'Commands',
|
|
120
127
|
'cmd.help.hint': 'Send any text to start a task. In a forum topic: /cd <project> binds the topic to that project.',
|
|
121
128
|
'cmd.cd.bound': 'Topic bound to project:\n{path}\n\nAll turns run from this directory.',
|
|
@@ -204,7 +211,7 @@ export default {
|
|
|
204
211
|
'bridge.fail.sandbox': 'DSH denied access to a file or directory. Check the project path and its permissions.',
|
|
205
212
|
'bridge.fail.unknownModel': 'the model from the config is unavailable. Working ones: /model.',
|
|
206
213
|
'bridge.fail.reject': 'the provider refused the request itself, not the answer. Every other route was tried first. If the session is long, /new starts a fresh one; /report sends the tail to the maintainer.',
|
|
207
|
-
'bridge.fail.rate': 'the provider is rate-limiting this key. Wait a minute — or /fallback walks the chain to another route.',
|
|
214
|
+
'bridge.fail.rate': 'the provider is rate-limiting this key. Wait a minute — or /fallback walks the chain to another route.',
|
|
208
215
|
'bridge.fail.empty': 'the model returned nothing. Retry or switch the model: /model.',
|
|
209
216
|
'bridge.fail.generic': 'retry the request; if the error is the same — /doctor and /logs errors.',
|
|
210
217
|
'bridge.fail.timeCap': "The turn hit its {minutes}-minute ceiling and was stopped — not a failure, and nothing is lost: the session is saved. Press Continue, or send the next message, and I go on from where I stopped.",
|
package/i18n/en/ctrl.mjs
CHANGED
|
@@ -27,7 +27,7 @@ export default {
|
|
|
27
27
|
'ctrl.help.about.subscribe': "Whether this install is announced as a user of the plugin, /subscribe on|off.",
|
|
28
28
|
'ctrl.help.about.settings': "Every switch on one card with pages: /settings, /settings agent, /settings updates.",
|
|
29
29
|
'ctrl.help.about.lang': "The language of the bot in this topic: /lang en|ru|zh.",
|
|
30
|
-
'ctrl.help.about.reasoning': "Working notes in the chat
|
|
30
|
+
'ctrl.help.about.reasoning': "Working notes: off, in the progress card, or as messages in the chat — /reasoning off|card|chat.",
|
|
31
31
|
'ctrl.help.about.doctor': "Checks the install: bridge, network, disk, plugins, session. Run it first when something breaks.",
|
|
32
32
|
'ctrl.help.about.logs': "The bridge log: /logs, /logs 100, /logs errors, /logs file.",
|
|
33
33
|
'ctrl.help.about.app': "The DSH desktop app, not the bridge: /app restart confirm.",
|
|
@@ -157,7 +157,7 @@ export default {
|
|
|
157
157
|
'ctrl.status.turns': 'Agent running: {state} ({n} turn(s))',
|
|
158
158
|
'ctrl.status.running': 'yes',
|
|
159
159
|
'ctrl.status.idle': 'no',
|
|
160
|
-
'ctrl.status.notes': 'Working notes (💭
|
|
160
|
+
'ctrl.status.notes': 'Working notes (💭): {state}',
|
|
161
161
|
'ctrl.status.on': 'on',
|
|
162
162
|
'ctrl.status.off': 'off',
|
|
163
163
|
'ctrl.status.skills': 'Skills: {n}',
|
package/i18n/ru/core.mjs
CHANGED
|
@@ -20,7 +20,9 @@ export default {
|
|
|
20
20
|
'settings.updates.title': 'Новые версии (эта установка, не тема)',
|
|
21
21
|
'settings.health.title': 'Если что-то не так',
|
|
22
22
|
'settings.reasoning.label': 'Заметки по ходу',
|
|
23
|
-
'settings.reasoning.hint': 'Строки
|
|
23
|
+
'settings.reasoning.hint': 'Строки 💭: в карточке прогресса, ещё и сообщениями в чат, или выкл.',
|
|
24
|
+
'settings.reasoning.chat': 'в чат',
|
|
25
|
+
'settings.reasoning.card': 'в карточке',
|
|
24
26
|
'settings.lang.label': 'Язык ответов',
|
|
25
27
|
'settings.lang.hint': 'auto — отвечать на языке сообщения; en, ru, zh — закрепить.',
|
|
26
28
|
'settings.thoughts.label': '💭 Заметки по ходу: последний ход, все или выкл',
|
|
@@ -98,6 +100,10 @@ export default {
|
|
|
98
100
|
'msg.langSet': 'Язык переключён на русский.',
|
|
99
101
|
'msg.reasoningOn': 'Заметки по ходу включены: 💭 будут появляться в сообщении прогресса.\nВыключить: /reasoning off',
|
|
100
102
|
'msg.reasoningOff': 'Заметки по ходу выключены. В прогрессе остаётся только список шагов.\nВключить: /reasoning on',
|
|
103
|
+
'msg.reasoningChat': 'Заметки по ходу идут в чат: каждая строка 💭 приходит отдельным сообщением, длинный ход читается по мере работы.\nОбратно в карточку: /reasoning card',
|
|
104
|
+
'msg.reasoningMode.off': 'выключены',
|
|
105
|
+
'msg.reasoningMode.card': 'в сообщении прогресса',
|
|
106
|
+
'msg.reasoningMode.chat': 'в чате и в сообщении прогресса',
|
|
101
107
|
'msg.stateOn': 'включены',
|
|
102
108
|
'msg.stateOff': 'выключены',
|
|
103
109
|
'msg.turnHardCap': 'Ход упёрся в потолок {minutes} минут и был остановлен. Ничего не потеряно: сессия сохранена — нажми «Продолжить», я проверю состояние и продолжу с того места, где остановился.',
|
|
@@ -114,8 +120,9 @@ export default {
|
|
|
114
120
|
'profile.createFailed': 'Не смог создать профиль {name} — шаблон не записался. Повтори или создай его в приложении.',
|
|
115
121
|
'profile.badName': 'Имя — строчные буквы, цифры и дефис: /profile new my-space from web',
|
|
116
122
|
'profile.set': 'Профиль темы → {name} ({route}). Действует со следующего хода.',
|
|
117
|
-
'msg.reasoningState': 'Заметки по ходу: {state}. Переключить: /reasoning
|
|
118
|
-
'prompt.reasoning': 'Заметки по ходу: в каждом ходе, на каждом значимом шаге — задача ясна, причина найдена, сейчас изменю рискованное, результат проверен — дописывай одну строку до 90 символов через `node {say} --thought "..."`. Она видна как 💭 в сообщении прогресса: пиши решение, а не пересказ. Пропускать можно только если весь ход — один вызов инструмента. Когда решение меняет то, что человек должен знать сразу — выпущена версия, найдена причина, упёрся в блокер, ход идёт долго — отправь это в чат одной строкой без разметки: `node {say} --note "..."`. В чат — только то, что важно сейчас, не каждый шаг.',
|
|
123
|
+
'msg.reasoningState': 'Заметки по ходу: {state}. Переключить: /reasoning off, /reasoning card или /reasoning chat.',
|
|
124
|
+
'prompt.reasoning': 'Заметки по ходу: в каждом ходе, на каждом значимом шаге — задача ясна, причина найдена, сейчас изменю рискованное, результат проверен — дописывай одну строку до 90 символов через `node {say} --thought "..."`. Она видна как 💭 в сообщении прогресса: пиши решение, а не пересказ. Строка — простым текстом, без разметки, секретов и путей к ключам: в режиме чата она уходит отдельным сообщением. Пропускать можно только если весь ход — один вызов инструмента. Когда решение меняет то, что человек должен знать сразу — выпущена версия, найдена причина, упёрся в блокер, ход идёт долго — отправь это в чат одной строкой без разметки: `node {say} --note "..."`. В чат — только то, что важно сейчас, не каждый шаг.',
|
|
125
|
+
'prompt.reasoningChat': 'Эта тема в режиме чата: каждая строка 💭 дополнительно уходит в чат отдельным сообщением, поэтому человек, читающий только чат, видит шаги по мере работы. Пиши строку так, чтобы она читалась сама по себе — что изменилось и почему это важно — и никогда не вставляй в неё секрет, токен или приватный путь.',
|
|
119
126
|
'cmd.help.title': 'Команды',
|
|
120
127
|
'cmd.help.hint': 'Любой текст — задача агенту. В теме форума: /cd <проект> привяжет тему к проекту.',
|
|
121
128
|
'cmd.cd.bound': 'Тема привязана к проекту:\n{path}\n\nДальше все команды идут отсюда.',
|
|
@@ -204,7 +211,7 @@ export default {
|
|
|
204
211
|
'bridge.fail.sandbox': 'DSH запретил доступ к файлу или каталогу. Проверь путь проекта и права на него.',
|
|
205
212
|
'bridge.fail.unknownModel': 'модель из конфига недоступна. Список рабочих: /model.',
|
|
206
213
|
'bridge.fail.reject': 'провайдер отказал самому запросу, а не ответу. Остальные маршруты уже перепробованы. Если сессия длинная, /new начнёт свежую; /report пришлёт хвост сопровождающему.',
|
|
207
|
-
'bridge.fail.rate': 'провайдер ограничивает частоту запросов по этому ключу. Подождите минуту — или /fallback переведёт ход на другой маршрут.',
|
|
214
|
+
'bridge.fail.rate': 'провайдер ограничивает частоту запросов по этому ключу. Подождите минуту — или /fallback переведёт ход на другой маршрут.',
|
|
208
215
|
'bridge.fail.empty': 'модель ничего не вернула. Повтори или смени модель: /model.',
|
|
209
216
|
'bridge.fail.generic': 'повтори запрос; если ошибка та же — /doctor и /logs errors.',
|
|
210
217
|
'bridge.fail.timeCap': "Ход упёрся в потолок {minutes} минут и был остановлен — это не ошибка, и ничего не потеряно: сессия сохранена. Нажми «Продолжить» или напиши следующее сообщение, и я продолжу с того места, где остановился.",
|
package/i18n/ru/ctrl.mjs
CHANGED
|
@@ -27,7 +27,7 @@ export default {
|
|
|
27
27
|
'ctrl.help.about.subscribe': "Сообщается ли о нас как о пользователе плагина: /subscribe on|off.",
|
|
28
28
|
'ctrl.help.about.settings': "Все переключатели одной карточкой по страницам: /settings, /settings agent, /settings updates.",
|
|
29
29
|
'ctrl.help.about.lang': "Язык бота в теме: /lang en|ru|zh.",
|
|
30
|
-
'ctrl.help.about.reasoning': "Заметки о ходе
|
|
30
|
+
'ctrl.help.about.reasoning': "Заметки о ходе работы: выкл, в карточке прогресса или отдельными сообщениями в чат — /reasoning off|card|chat.",
|
|
31
31
|
'ctrl.help.about.doctor': "Проверяет установку: мост, сеть, диск, плагины, сессию. С него начинают, когда что-то сломалось.",
|
|
32
32
|
'ctrl.help.about.logs': "Лог моста: /logs, /logs 100, /logs errors, /logs file.",
|
|
33
33
|
'ctrl.help.about.app': "Приложение DSH, не мост: /app restart confirm.",
|
|
@@ -157,7 +157,7 @@ export default {
|
|
|
157
157
|
'ctrl.status.turns': 'Агент работает: {state} ({n} ход(ов))',
|
|
158
158
|
'ctrl.status.running': 'да',
|
|
159
159
|
'ctrl.status.idle': 'нет',
|
|
160
|
-
'ctrl.status.notes': 'Заметки по ходу (💭
|
|
160
|
+
'ctrl.status.notes': 'Заметки по ходу (💭): {state}',
|
|
161
161
|
'ctrl.status.on': 'включены',
|
|
162
162
|
'ctrl.status.off': 'выключены',
|
|
163
163
|
'ctrl.status.skills': 'Скиллы: {n}',
|
package/i18n/zh/core.mjs
CHANGED
|
@@ -20,7 +20,9 @@ export default {
|
|
|
20
20
|
'settings.updates.title': '新版本(针对本次安装,而非话题)',
|
|
21
21
|
'settings.health.title': '如果哪里不对',
|
|
22
22
|
'settings.reasoning.label': '过程记录',
|
|
23
|
-
'settings.reasoning.hint': '
|
|
23
|
+
'settings.reasoning.hint': '💭 行:放在进度卡片里、同时发到聊天,或关闭。',
|
|
24
|
+
'settings.reasoning.chat': '发到聊天',
|
|
25
|
+
'settings.reasoning.card': '放在卡片里',
|
|
24
26
|
'settings.lang.label': '回复语言',
|
|
25
27
|
'settings.lang.hint': 'auto 按消息语言回复;en、ru、zh 则固定。',
|
|
26
28
|
'settings.thoughts.label': '💭 过程记录:上一轮、全部或关闭',
|
|
@@ -98,6 +100,10 @@ export default {
|
|
|
98
100
|
'msg.langSet': '界面语言已切换为中文。',
|
|
99
101
|
'msg.reasoningOn': '工作记录已开启:💭 会显示在进度消息里。\n关闭:/reasoning off',
|
|
100
102
|
'msg.reasoningOff': '工作记录已关闭,进度消息只保留步骤列表。\n开启:/reasoning on',
|
|
103
|
+
'msg.reasoningChat': '工作记录会发到聊天:每条 💭 单独成一条消息,长回合可以边跑边看。\n回到进度卡片:/reasoning card',
|
|
104
|
+
'msg.reasoningMode.off': '关闭',
|
|
105
|
+
'msg.reasoningMode.card': '在进度消息里',
|
|
106
|
+
'msg.reasoningMode.chat': '在聊天和进度消息里',
|
|
101
107
|
'msg.stateOn': '开启',
|
|
102
108
|
'msg.stateOff': '关闭',
|
|
103
109
|
'msg.turnHardCap': '本轮达到 {minutes} 分钟上限并被停止。进度没有丢失:会话已保留——点击“继续”,我会检查状态并从停下的地方接着做。',
|
|
@@ -114,8 +120,9 @@ export default {
|
|
|
114
120
|
'profile.createFailed': '无法创建配置档 {name}——模板未写入。请重试或在应用中创建。',
|
|
115
121
|
'profile.badName': '名称只能用小写字母、数字和连字符:/profile new my-space from web',
|
|
116
122
|
'profile.set': '话题配置档 → {name}({route})。下一轮生效。',
|
|
117
|
-
'msg.reasoningState': '工作记录:{state}。切换:/reasoning
|
|
118
|
-
'prompt.reasoning': '工作记录:每一轮在每个有意义的节点——任务已清楚、原因已找到、即将改动有风险的地方、结果已验证——用 `node {say} --thought "..."` 追加一行,不超过 90 个字符。它会以 💭
|
|
123
|
+
'msg.reasoningState': '工作记录:{state}。切换:/reasoning off、/reasoning card 或 /reasoning chat。',
|
|
124
|
+
'prompt.reasoning': '工作记录:每一轮在每个有意义的节点——任务已清楚、原因已找到、即将改动有风险的地方、结果已验证——用 `node {say} --thought "..."` 追加一行,不超过 90 个字符。它会以 💭 出现在进度消息里:写结论,不要复述。这一行要用纯文本,不带标记、不含密钥和凭据路径:在聊天模式下它会单独成一条消息。只有整轮只是一次工具调用时才可以跳过。当某个决定改变对方需要预期的事——版本已发布、找到原因、遇到阻塞、这一轮跑得很久——用一行纯文本发到聊天:`node {say} --note "..."`。聊天里只发此刻重要的内容,不是每一步。',
|
|
125
|
+
'prompt.reasoningChat': '这个会话处于聊天模式:每条 💭 还会单独作为一条消息发到聊天,只看聊天的人也能边跑边看到步骤。每一行都要能独立读懂——改了什么、为什么重要——绝不写入密钥、令牌或私有路径。',
|
|
119
126
|
'cmd.help.title': '命令',
|
|
120
127
|
'cmd.help.hint': '发送任意文本即可开始任务。在论坛话题中:/cd <项目> 将该话题绑定到项目目录。',
|
|
121
128
|
'cmd.cd.bound': '话题已绑定到项目:\n{path}\n\n之后所有操作都在此目录执行。',
|
|
@@ -204,7 +211,7 @@ export default {
|
|
|
204
211
|
'bridge.fail.sandbox': 'DSH 拒绝访问文件或目录。请检查项目路径及其权限。',
|
|
205
212
|
'bridge.fail.unknownModel': '配置中的模型不可用。可用的列表:/model。',
|
|
206
213
|
'bridge.fail.reject': '服务商拒绝的是请求本身,而不是回答。其他线路已全部试过。若会话过长,用 /new 开一个;用 /report 把日志尾部发给维护者。',
|
|
207
|
-
'bridge.fail.rate': '服务商正在限制此密钥的请求频率。请等一分钟,或用 /fallback 让本轮换到其他线路。',
|
|
214
|
+
'bridge.fail.rate': '服务商正在限制此密钥的请求频率。请等一分钟,或用 /fallback 让本轮换到其他线路。',
|
|
208
215
|
'bridge.fail.empty': '模型没有返回任何内容。请重试或切换模型:/model。',
|
|
209
216
|
'bridge.fail.generic': '请重试请求;如果错误相同 —— /doctor 和 /logs errors。',
|
|
210
217
|
'bridge.fail.timeCap': "本轮达到 {minutes} 分钟上限并被停止——这不是错误,也没有丢失任何东西:会话已保存。点击“继续”或写下一条消息,我会从停下的地方接着做。",
|
package/i18n/zh/ctrl.mjs
CHANGED
|
@@ -27,7 +27,7 @@ export default {
|
|
|
27
27
|
'ctrl.help.about.subscribe': "是否公开本安装为该插件的使用者:/subscribe on|off。",
|
|
28
28
|
'ctrl.help.about.settings': "所有开关在一张卡片上,分页显示:/settings、/settings agent、/settings updates。",
|
|
29
29
|
'ctrl.help.about.lang': "本话题中机器人的语言:/lang en|ru|zh。",
|
|
30
|
-
'ctrl.help.about.reasoning': "
|
|
30
|
+
'ctrl.help.about.reasoning': "工作记录:关闭、放在进度卡片里,或作为消息发到聊天——/reasoning off|card|chat。",
|
|
31
31
|
'ctrl.help.about.doctor': "检查安装:桥接、网络、磁盘、插件、会话。出问题先跑它。",
|
|
32
32
|
'ctrl.help.about.logs': "桥接日志:/logs、/logs 100、/logs errors、/logs file。",
|
|
33
33
|
'ctrl.help.about.app': "DSH 桌面应用,不是桥接:/app restart confirm。",
|
|
@@ -157,7 +157,7 @@ export default {
|
|
|
157
157
|
'ctrl.status.turns': '代理运行中:{state}({n} 个任务)',
|
|
158
158
|
'ctrl.status.running': '是',
|
|
159
159
|
'ctrl.status.idle': '否',
|
|
160
|
-
'ctrl.status.notes': '
|
|
160
|
+
'ctrl.status.notes': '工作记录(💭):{state}',
|
|
161
161
|
'ctrl.status.on': '开',
|
|
162
162
|
'ctrl.status.off': '关',
|
|
163
163
|
'ctrl.status.skills': '技能:{n}',
|
package/model-probe.mjs
CHANGED
|
@@ -120,14 +120,26 @@ export function firstProvider() {
|
|
|
120
120
|
return providerFor('');
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
/**
|
|
124
|
-
|
|
123
|
+
/**
|
|
124
|
+
* Classify a provider answer into something the chat can act on.
|
|
125
|
+
*
|
|
126
|
+
* The order is the whole point, and it was wrong in a way a live probe caught:
|
|
127
|
+
* one router answers a per-minute limit with **403** and the sentence "This
|
|
128
|
+
* model is at its provider's per minute limit right now". The status was read
|
|
129
|
+
* first, so the card called it "key refused" — the one verdict that sends a
|
|
130
|
+
* person to re-enter a key that works, while the route was merely throttled.
|
|
131
|
+
* Words about a limit therefore win over the status, and a bare 403 stays auth.
|
|
132
|
+
*/
|
|
133
|
+
export function classify(status, body) {
|
|
125
134
|
const text = String(body || '');
|
|
126
135
|
if (status === 200) return 'ok';
|
|
127
136
|
if (/insufficient_user_quota|balance|billing|payment/i.test(text)) return 'balance';
|
|
128
|
-
|
|
137
|
+
// "per minute limit", "rate limit", "too many requests", "busy" — one family,
|
|
138
|
+
// whatever status the router chose to attach to it.
|
|
139
|
+
if (/\b429\b|rate.?limit|per.?minute limit|requests? per minute|too many requests|get_channel_failed|all providers|busy|overloaded/i.test(text)) return 'busy';
|
|
129
140
|
if (status === 401 || status === 403) return 'auth';
|
|
130
141
|
if (status === 404) return 'missing';
|
|
142
|
+
if (status >= 500) return 'busy';
|
|
131
143
|
return 'other';
|
|
132
144
|
}
|
|
133
145
|
|
package/notes.mjs
CHANGED
|
@@ -34,13 +34,13 @@ export function readNotes(file) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* Every note of this turn across `files`, oldest first, de-duplicated.
|
|
38
38
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
39
|
+
* The chat forwarder needs the whole list, not the last two the card shows: a
|
|
40
|
+
* step that only ever reached a card the person was not looking at is a step
|
|
41
|
+
* they never learned about.
|
|
42
42
|
*/
|
|
43
|
-
export function
|
|
43
|
+
export function thoughtRows(files, since = 0) {
|
|
44
44
|
const seen = new Set();
|
|
45
45
|
return files
|
|
46
46
|
.filter(Boolean)
|
|
@@ -49,7 +49,39 @@ export function recentThoughts(files, since = 0, limit = 2) {
|
|
|
49
49
|
// The same note can sit in both files when `say.mjs` wrote to each; a
|
|
50
50
|
// duplicated 💭 line reads as two decisions instead of one.
|
|
51
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
|
-
|
|
54
|
-
|
|
52
|
+
.sort((a, b) => a.at - b.at);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* How much of the decision trail this topic wants: `off`, `card` or `chat`.
|
|
57
|
+
*
|
|
58
|
+
* Three ends, one switch — the trail is one job, and a second command for "send
|
|
59
|
+
* them to the chat" would be the lookalike name this surface spent a release
|
|
60
|
+
* removing. `card` is the default: the last two lines inside the progress
|
|
61
|
+
* message. `chat` also sends each line as its own message, for a turn a person
|
|
62
|
+
* wants to read while it runs instead of afterwards.
|
|
63
|
+
*
|
|
64
|
+
* An old `true`/`false` in `state.json` is still a mode: `card`/`off`. It is
|
|
65
|
+
* what the previous release stored, and a settings file must not need editing
|
|
66
|
+
* by hand after an update.
|
|
67
|
+
*/
|
|
68
|
+
export function reasoningMode(state, config, key = '') {
|
|
69
|
+
const raw = state?.reasoning?.[key];
|
|
70
|
+
const fromTopic = raw === 'chat' || raw === 'card' || raw === 'off' ? raw : raw === true ? 'card' : raw === false ? 'off' : '';
|
|
71
|
+
if (fromTopic) return fromTopic;
|
|
72
|
+
const fallback = config?.reasoning;
|
|
73
|
+
if (fallback === 'chat' || fallback === 'card' || fallback === 'off') return fallback;
|
|
74
|
+
if (fallback === false) return 'off';
|
|
75
|
+
return 'card';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The last `limit` note texts across `files`, written at or after `since`.
|
|
80
|
+
*
|
|
81
|
+
* `since` is the turn's start time: it is what separates "this turn said X" from
|
|
82
|
+
* "a previous turn in this topic said X". Notes without a timestamp are dropped
|
|
83
|
+
* rather than shown at the wrong moment.
|
|
84
|
+
*/
|
|
85
|
+
export function recentThoughts(files, since = 0, limit = 2) {
|
|
86
|
+
return thoughtRows(files, since).slice(-limit).map((row) => row.text);
|
|
55
87
|
}
|
package/package.json
CHANGED
package/progress.mjs
CHANGED
|
@@ -14,7 +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 {
|
|
17
|
+
import { reasoningMode, thoughtRows } from './notes.mjs';
|
|
18
18
|
import { continueKeyboard, errorKeyboard } from './keyboards.mjs';
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -71,6 +71,17 @@ export async function startProgress(chatId, threadId, lang = config.lang || 'en'
|
|
|
71
71
|
const notes = thoughtFile || join(THOUGHT_DIR, `${chatId}_${threadId || 0}.jsonl`);
|
|
72
72
|
const topicNotes = join(THOUGHT_DIR, `${chatId}_${threadId || 0}.jsonl`);
|
|
73
73
|
let thoughts = [];
|
|
74
|
+
// In `chat` mode every note also leaves the card as its own message: a turn
|
|
75
|
+
// that runs for twenty minutes is read as it happens, not scrolled back to.
|
|
76
|
+
// The set holds what already went out, so a rewrite of the card never repeats
|
|
77
|
+
// a step, and a note that arrives while the person is reading is not lost.
|
|
78
|
+
const forwarded = new Set();
|
|
79
|
+
// Switching to chat mid-turn must not dump the steps already shown in the card
|
|
80
|
+
// into the chat as a burst: the mode takes effect from the next step written
|
|
81
|
+
// after the switch. A turn that starts in chat mode forwards from its first
|
|
82
|
+
// line, so `chatFrom` is the turn's own start in that case.
|
|
83
|
+
let chatFrom = reasoningMode(state, config, panelKey) === 'chat' ? started : Infinity;
|
|
84
|
+
let wasChat = Number.isFinite(chatFrom);
|
|
74
85
|
try {
|
|
75
86
|
mkdirSync(THOUGHT_DIR, { recursive: true });
|
|
76
87
|
// Start this turn's file empty — but never truncate the stable per-topic
|
|
@@ -79,7 +90,34 @@ export async function startProgress(chatId, threadId, lang = config.lang || 'en'
|
|
|
79
90
|
if (thoughtFile) writeFileSync(notes, '');
|
|
80
91
|
} catch {}
|
|
81
92
|
const thoughtTimer = setInterval(() => {
|
|
82
|
-
const
|
|
93
|
+
const mode = reasoningMode(state, config, panelKey);
|
|
94
|
+
if (mode === 'chat' && !wasChat) chatFrom = Date.now();
|
|
95
|
+
wasChat = mode === 'chat';
|
|
96
|
+
if (mode === 'off') {
|
|
97
|
+
if (thoughts.length) {
|
|
98
|
+
thoughts = [];
|
|
99
|
+
schedule();
|
|
100
|
+
}
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const rows = thoughtRows([notes, topicNotes], started);
|
|
104
|
+
if (mode === 'chat') {
|
|
105
|
+
for (const row of rows) {
|
|
106
|
+
if (row.at < chatFrom) continue;
|
|
107
|
+
const id = `${row.at}:${row.text}`;
|
|
108
|
+
if (forwarded.has(id)) continue;
|
|
109
|
+
forwarded.add(id);
|
|
110
|
+
// One message per decision, and a failed send must not kill the turn:
|
|
111
|
+
// the note is still in the card, which is where it always lived.
|
|
112
|
+
tg('sendMessage', {
|
|
113
|
+
chat_id: chatId,
|
|
114
|
+
text: `💭 ${row.text}`,
|
|
115
|
+
disable_web_page_preview: true,
|
|
116
|
+
...(threadId > 0 ? { message_thread_id: threadId } : {}),
|
|
117
|
+
}).catch((error) => log(`note forward failed: ${String(error.message).slice(0, 100)}`));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const merged = rows.slice(-2).map((row) => row.text);
|
|
83
121
|
if (merged.join('\n') !== thoughts.join('\n')) {
|
|
84
122
|
thoughts = merged;
|
|
85
123
|
schedule();
|
package/settings-card.mjs
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* translate or store a value differently from the command, and a new command
|
|
15
15
|
* turns into a button by adding a row here — nothing else.
|
|
16
16
|
*/
|
|
17
|
+
import { reasoningMode } from './notes.mjs';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* A row is one setting. `values` are the ends a card offers (only where a pair is
|
|
@@ -26,7 +27,16 @@
|
|
|
26
27
|
const PAGES = {
|
|
27
28
|
// What the bot says, and in which language.
|
|
28
29
|
reply: [
|
|
29
|
-
|
|
30
|
+
// Three ends, one row: the trail is off, in the card, or in the chat. The
|
|
31
|
+
// card marks whichever end is the current mode, so a tap on ● does nothing
|
|
32
|
+
// surprising and a tap on a ○ is the only thing that changes anything.
|
|
33
|
+
{
|
|
34
|
+
id: 'reasoning',
|
|
35
|
+
field: 'reasoning',
|
|
36
|
+
values: ['card', 'chat', 'off'],
|
|
37
|
+
command: '/reasoning {v}',
|
|
38
|
+
labels: { card: 'settings.reasoning.card', chat: 'settings.reasoning.chat', off: 'settings.state.off' },
|
|
39
|
+
},
|
|
30
40
|
{ id: 'lang', field: 'lang', values: ['en', 'ru', 'zh'], on: 'auto', command: '/lang {v}', labels: {} },
|
|
31
41
|
{ id: 'thoughts', command: '/thoughts' },
|
|
32
42
|
],
|
|
@@ -89,7 +99,7 @@ export function settingsButtons({ t, current = {}, updateMode = 'check' }) {
|
|
|
89
99
|
const data = value ? `${SET_PREFIX}${row.id}:${value}` : `${SET_PREFIX}${row.id}`;
|
|
90
100
|
if (data.length > MAX_PAYLOAD) throw new Error(`payload too long: ${data}`);
|
|
91
101
|
let active = false;
|
|
92
|
-
if (row.field === 'reasoning') active =
|
|
102
|
+
if (row.field === 'reasoning') active = current.reasoning === value;
|
|
93
103
|
else if (row.field === 'lang') active = current.lang === value;
|
|
94
104
|
else if (row.id === 'u-late') active = value === 'on' ? updateMode !== 'off' : updateMode === 'off';
|
|
95
105
|
else if (row.id === 'u-auto') active = updateMode === value;
|
|
@@ -114,9 +124,9 @@ export function settingsButtons({ t, current = {}, updateMode = 'check' }) {
|
|
|
114
124
|
* What the card reads as the current values. Every field comes from the same
|
|
115
125
|
* place the matching command reads it, so a `●` cannot lie.
|
|
116
126
|
*/
|
|
117
|
-
export function settingsCurrent({ config = {}, state = {}, key = ''
|
|
127
|
+
export function settingsCurrent({ config = {}, state = {}, key = '' }) {
|
|
118
128
|
return {
|
|
119
|
-
reasoning:
|
|
129
|
+
reasoning: reasoningMode(state, config, key),
|
|
120
130
|
lang: state.lang?.[key] || 'auto',
|
|
121
131
|
};
|
|
122
132
|
}
|