dsh-tg-bridge 1.25.2 → 1.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -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 on|off · /thoughts
274
+ Display: /lang · /reasoning off|card|chat · /pin on|off · /thoughts
275
275
  ```
276
276
 
277
277
  ### Settings as a card
@@ -280,9 +280,19 @@ 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 off`, `/update on`), so the card cannot disagree with the command:
284
- it is a view of them. After the change the card collapses into one plain line —
285
- delete it and the chat is back to what it was.
283
+ (`/reasoning chat`, `/update on`), so the card cannot disagree with the command:
284
+ it is a view of them.
285
+
286
+ The card stays after a tap. It is edited in place — same message, same buttons,
287
+ the value in force marked with `●` and one `✓ row: value` line saying what just
288
+ changed — so a second setting is one more tap instead of a second `/settings`.
289
+ `✓ Done` removes the card when you are finished with it; nothing else deletes it.
290
+
291
+ `📌 Pin the progress card` (`/pin on`) keeps the running card pinned, so the
292
+ clock, the speed and the step list are one tap away instead of a scroll. Telegram
293
+ gives a chat one pinned message, so each turn's card replaces the last one. Off by
294
+ default: a bot that pins without being asked takes that slot in someone else's
295
+ chat, and a group needs the right to pin at all.
286
296
 
287
297
  Nothing on the card is only available on the card. `/settings` is for people who
288
298
  would rather press a labelled button than remember which of `/effort`,
@@ -425,7 +435,7 @@ node ~/.dsh/tg-bridge/say.mjs --thought "checking why the watchdog fired twice"
425
435
  The note is appended to `~/.dsh/tg-bridge/thoughts/<chat>_<thread>.jsonl`; the progress
426
436
  message shows the last two as `💭` lines. The command needs no ids: it falls back to the
427
437
  newest turn's thought file, because tool shells do not inherit the bridge environment.
428
- `--thought` never sends a Telegram message on its own.
438
+ `--thought` sends a Telegram message of its own only in `/reasoning chat` mode.
429
439
 
430
440
  A decision the person must know before the turn ends — a release shipped, a cause found,
431
441
  a blocker — goes to the chat as one plain line instead:
@@ -435,16 +445,27 @@ node ~/.dsh/tg-bridge/say.mjs --note "1.10.1 is on npm; restart to load it"
435
445
  ```
436
446
 
437
447
  `--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, `--note` is the
439
- short line that changes what the reader expects to happen next. The progress message itself
440
- opens with the request echoed back (`⏳ Принял: «…» · 3 с`), so the first thing the person
441
- sees after sending names their task rather than a generic spinner.
442
-
443
- `/reasoning` is the switch for the 💭 mechanism. It is on by default: every turn carries a
444
- short instruction to leave one line at each decision point (task clear, cause found, risky
445
- change, result checked). `/reasoning off` drops the instruction and the `💭` lines for that
446
- topic — useful when the step list is all you want. The setting lives in `state.json` per topic,
447
- so a chatty research topic and a terse deploy topic can differ.
448
+ is deliberate: `--thought` is the working trail (inside the progress message, and in `chat`
449
+ mode also as its own messages), `--note` is the short line that changes what the reader
450
+ expects to happen next — useful in `card` and `off` mode, redundant in `chat`. The progress
451
+ message itself opens with the request echoed back (`⏳ Принял: «…» · 3 с`), so the first
452
+ thing the person sees after sending names their task rather than a generic spinner.
453
+
454
+ `/reasoning` is the switch for the 💭 mechanism, and it has three ends:
455
+
456
+ - `/reasoning card` (the default) — every turn carries a short instruction to leave one line
457
+ at each decision point (task clear, cause found, risky change, result checked), and the
458
+ progress message shows the last two;
459
+ - `/reasoning chat` — the same lines, each also posted as its own message, so a turn that
460
+ runs for twenty minutes is read as it happens instead of scrolled back to afterwards.
461
+ The prompt says so explicitly, so a line is written to stand alone;
462
+ - `/reasoning off` — drops the instruction and the `💭` lines for that topic, for when the
463
+ step list is all you want.
464
+
465
+ A topic switched to `chat` mid-turn does not dump the steps already in the card: forwarding
466
+ starts with the next line written. The setting lives in `state.json` per topic, so a chatty
467
+ research topic and a terse deploy topic can differ; a `true`/`false` written by an older
468
+ release still reads as `card`/`off`. The settings card offers the same three ends as buttons.
448
469
 
449
470
  The reasoning block itself is model output; `/thoughts` is what reads it back:
450
471
 
package/bridge.mjs CHANGED
@@ -41,7 +41,7 @@ import { startJobLoops } from './job-loops.mjs';
41
41
  import { ensureProfile } from './profiles.mjs';
42
42
  import { firstLiveModel, describeVerdicts, probeHint, probeModel } from './model-probe.mjs';
43
43
  import { explainFailure } from './failures.mjs';
44
- import { handleControl, CONTROL_COMMANDS, modelOf, modelsOf, reasoningOf } from './control.mjs';
44
+ import { handleControl, CONTROL_COMMANDS, modelOf, modelsOf } from './control.mjs';
45
45
  import { bridgeVersion, installRelease, npmLatestAsync } from './control.mjs';
46
46
  import { dueForCheck, updateState } from './update-policy.mjs';
47
47
  import { drainGoalJobs, goalOf, progressOf, renderPromptBlock, toggleTask } from './goals.mjs';
package/callbacks.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  // task card. One place, because a press may mean a control command, a card
3
3
  // update or an approval, and only one handler may claim it.
4
4
  import { AgentsetStore } from './agentsets.mjs';
5
- import { CONTROL_COMMANDS, handleControl, reasoningOf } from './control.mjs';
5
+ import { CONTROL_COMMANDS, handleControl } from './control.mjs';
6
6
  import { isFallbackPress, pressTarget } from './fallback-card.mjs';
7
7
  import { progressOf, toggleTask } from './goals.mjs';
8
8
  import { handleMessage } from './handle-message.mjs';
@@ -326,22 +326,31 @@ export async function handleCallback(query) {
326
326
  export async function handleCardPress(query, ctx) {
327
327
  const { chatId, messageId, threadId, key, lang } = ctx;
328
328
  const data = String(query.data || '');
329
- const current = settingsCurrent({ config, state, key, reasoningOf });
329
+ const tt = (k, vars) => t(lang, k, vars);
330
330
  const updateMode = state.update?.mode || 'check';
331
- const wanted = commandFor({ t: (k, vars) => t(lang, k, vars), current, updateMode }, data);
331
+ const current = settingsCurrent({ config, state, key });
332
+ const wanted = commandFor({ t: tt, current, updateMode }, data);
332
333
 
333
334
  if (!wanted) {
334
335
  await tg('answerCallbackQuery', { callback_query_id: query.id, text: t(lang, 'settings.card.stale') }).catch(() => {});
335
336
  return;
336
337
  }
337
338
 
338
- if (wanted.page) {
339
+ if (wanted.done) {
340
+ await tg('deleteMessage', { chat_id: chatId, message_id: messageId }).catch((error) => log(`settings card delete failed: ${error.message}`));
341
+ await tg('answerCallbackQuery', { callback_query_id: query.id }).catch(() => {});
342
+ return;
343
+ }
344
+
345
+ /** Redraw the card in place: the same message, the new values, the buttons kept. */
346
+ const redraw = async (page, note = '') => {
339
347
  const card = renderSettingsCard({
340
- page: wanted.page,
341
- t: (k, vars) => t(lang, k, vars),
342
- current,
348
+ page,
349
+ t: tt,
350
+ current: settingsCurrent({ config, state, key }),
343
351
  updateMode,
344
352
  bound: boundSetOf(key),
353
+ note,
345
354
  });
346
355
  await tg('editMessageText', {
347
356
  chat_id: chatId,
@@ -351,6 +360,10 @@ export async function handleCardPress(query, ctx) {
351
360
  ...(threadId > 0 ? { message_thread_id: threadId } : {}),
352
361
  }).catch((error) => log(`settings card redraw failed: ${error.message}`));
353
362
  await tg('answerCallbackQuery', { callback_query_id: query.id }).catch(() => {});
363
+ };
364
+
365
+ if (wanted.page) {
366
+ await redraw(wanted.page);
354
367
  return;
355
368
  }
356
369
 
@@ -358,6 +371,10 @@ export async function handleCardPress(query, ctx) {
358
371
  // in the chat: the one line below is the chat's share of this press. Only a
359
372
  // command that failed says more than that.
360
373
  const replies = [];
374
+ // A press that fails has to say so: the card is redrawn either way, and a
375
+ // redraw alone looks exactly like success. The old path hid failures behind a
376
+ // line the person read as a confirmation.
377
+ let failed = '';
361
378
  const [head, ...rest] = wanted.command.split(/\s+/);
362
379
  const handled = await handleControl({
363
380
  command: head,
@@ -390,29 +407,30 @@ export async function handleCardPress(query, ctx) {
390
407
  prices: () => Promise.resolve(''),
391
408
  }).catch((error) => {
392
409
  log(`settings press ${data} failed: ${error.message}`);
410
+ failed = error.message;
393
411
  replies.push(error.message);
394
412
  return true;
395
413
  });
396
414
 
397
415
  const changed = Boolean(wanted.value);
398
- const answerText = changed
399
- ? t(lang, 'settings.card.changed', { label: wanted.label, value: wanted.value })
400
- : t(lang, 'settings.card.door', { command: wanted.command });
401
416
 
402
- // The card becomes the line: the buttons go away with the text they described.
403
- await tg('editMessageText', {
404
- chat_id: chatId,
405
- message_id: messageId,
406
- text: answerText,
407
- ...(threadId > 0 ? { message_thread_id: threadId } : {}),
408
- }).catch(() => {});
409
- await tg('answerCallbackQuery', { callback_query_id: query.id }).catch(() => {});
417
+ // The card stays where it is, redrawn with the new value. A press that turned
418
+ // it into one line took the menu away from the person who wanted the next tap,
419
+ // and the line said less than the card did; keeping it costs no message,
420
+ // because this is an edit of the one already in the chat. The way out is the
421
+ // card's own button, so removing it is a decision, not a side effect.
422
+ await redraw(
423
+ wanted.page,
424
+ failed ? `⚠️ ${failed}` : changed ? t(lang, 'settings.card.changed', { label: wanted.label, value: wanted.value }) : '',
425
+ );
410
426
 
411
427
  // A door that opened to nothing (an unknown set id, a command that is not
412
- // allowed here) still has something to say; it goes under the line, once.
428
+ // allowed here) still has something to say; it goes under the card, once. A
429
+ // switch says nothing here: the card above it already named the new value, and
430
+ // a failure is on the card too, so it is not repeated below it.
413
431
  if (!handled) log(`settings press ${data}: no handler answered`);
414
- const notLine = replies.filter(Boolean).filter((r) => r !== answerText);
415
- if (notLine.length > 0 && !changed) {
432
+ const notLine = replies.filter(Boolean).filter((r) => r !== wanted.command);
433
+ if (notLine.length > 0 && !changed && !failed) {
416
434
  await send(chatId, notLine[0], threadId).catch(() => {});
417
435
  }
418
436
  }
@@ -10,7 +10,7 @@ export const CONTROL_COMMANDS = [
10
10
  'status', 'models', 'model', 'effort', 'profile', 'agents', 'preset', 'permissions', 'plan',
11
11
  'jobs', 'remind', 'sessions', 'resume', 'plugins', 'plugin',
12
12
  'skills', 'soul', 'restart', 'app', 'stop', 'new', 'seed', 'send', 'cd',
13
- 'prices', 'help', 'doctor', 'logs', 'report', 'lang', 'reasoning', 'goal', 'task', 'tasks',
13
+ 'prices', 'help', 'doctor', 'logs', 'report', 'lang', 'reasoning', 'pin', 'goal', 'task', 'tasks',
14
14
  'thoughts', 'version', 'update', 'crew', 'agentset', 'subscribe', 'settings',
15
15
  'rewind', 'fork', 'branches', 'menu', 'fallback',
16
16
  ];
@@ -31,7 +31,7 @@ import { listPids, waitForExit, waitForStart, pluginsOf, bundleRowIds, addBundle
31
31
  import { cwdSlug, bareId, stamp, recentSessions, sessionTitle } from './sessions.mjs';
32
32
  import { agentsOf, fleetOf, patchRows, skillsOf, AGENTS, PERSONA_HEADING, soulOf, setSoul } from './agents.mjs';
33
33
  import { fmt, AGENTSETS, agentset, agentsetOf, profileRowOf, bindAgentset, agentsetCard, agentsetKeyboard } from './agentsets.mjs';
34
- import { taskKeyboard, goalView, taskView, reasoningOf, filterLogLines } from './tasks.mjs';
34
+ import { taskKeyboard, goalView, taskView, filterLogLines } from './tasks.mjs';
35
35
  import { updatePolicy, bridgeRoot, copyRelease, installRelease, bridgeVersion, newestModuleMtime, npmLatest, npmLatestAsync } from './release.mjs';
36
36
 
37
37
  export async function handleAgentCommands(ctx) {
@@ -31,7 +31,7 @@ import { listPids, waitForExit, waitForStart, pluginsOf, bundleRowIds, addBundle
31
31
  import { cwdSlug, bareId, stamp, recentSessions, sessionTitle } from './sessions.mjs';
32
32
  import { agentsOf, fleetOf, patchRows, skillsOf, AGENTS, PERSONA_HEADING, soulOf, setSoul } from './agents.mjs';
33
33
  import { fmt, AGENTSETS, agentset, agentsetOf, profileRowOf, bindAgentset, agentsetCard, agentsetKeyboard } from './agentsets.mjs';
34
- import { taskKeyboard, goalView, taskView, reasoningOf, filterLogLines } from './tasks.mjs';
34
+ import { taskKeyboard, goalView, taskView, filterLogLines } from './tasks.mjs';
35
35
  import { updatePolicy, bridgeRoot, copyRelease, installRelease, bridgeVersion, newestModuleMtime, npmLatest, npmLatestAsync } from './release.mjs';
36
36
  import { buildReport, tailOf, writeReport } from '../report.mjs';
37
37
  import { effectivePreset } from '../permission-rows.mjs';
@@ -193,9 +193,11 @@ export async function handleFallbackCommands(ctx) {
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
195
  //
196
- // The probes run together, not one after another: seven routes at a 15-second
197
- // timeout each is nearly two minutes of a command that looks frozen, and the
198
- // poller waits behind it. One round answers in the time of the slowest route.
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.
199
201
  case 'test':
200
202
  case 'x': {
201
203
  const targets = entry ? [entry] : chain;
@@ -203,9 +205,18 @@ export async function handleFallbackCommands(ctx) {
203
205
  say(t(lang, 'ctrl.fallback.empty'));
204
206
  return true;
205
207
  }
206
- const verdicts = await Promise.all(targets.map((item) => probeModel(item.model, { provider: item.provider })));
207
- const rows = targets.map((item, index) => {
208
- const verdict = verdicts[index];
208
+ const byProvider = new Map();
209
+ for (const item of targets) {
210
+ const id = item.provider || '';
211
+ if (!byProvider.has(id)) byProvider.set(id, []);
212
+ byProvider.get(id).push(item);
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' };
209
220
  log(`fallback probe ${labelOf(item)}: ${verdict.kind}${verdict.detail ? ` (${String(verdict.detail).slice(0, 80)})` : ''}`);
210
221
  return { n: chain.indexOf(item) + 1, route: labelOf(item), kind: VERDICT[verdict.kind] || 'other' };
211
222
  });
@@ -30,7 +30,7 @@ import { listPids, waitForExit, waitForStart, pluginsOf, bundleRowIds, addBundle
30
30
  import { cwdSlug, bareId, stamp, recentSessions, sessionTitle } from './sessions.mjs';
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
- import { taskKeyboard, goalView, taskView, reasoningOf, filterLogLines } from './tasks.mjs';
33
+ import { taskKeyboard, goalView, taskView, filterLogLines } from './tasks.mjs';
34
34
  import { updatePolicy, bridgeRoot, copyRelease, installRelease, bridgeVersion, newestModuleMtime, npmLatest, npmLatestAsync } from './release.mjs';
35
35
 
36
36
  export async function handlePluginCommands(ctx) {
@@ -30,7 +30,7 @@ import { listPids, waitForExit, waitForStart, pluginsOf, bundleRowIds, addBundle
30
30
  import { cwdSlug, bareId, stamp, recentSessions, sessionTitle } from './sessions.mjs';
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
- import { taskKeyboard, goalView, taskView, reasoningOf, filterLogLines } from './tasks.mjs';
33
+ import { taskKeyboard, goalView, taskView, filterLogLines } from './tasks.mjs';
34
34
  import { updatePolicy, bridgeRoot, copyRelease, installRelease, bridgeVersion, newestModuleMtime, npmLatest, npmLatestAsync } from './release.mjs';
35
35
  import { resolveCd } from './cd-path.mjs';
36
36
  import { permissionEnabled } from '../permission-rows.mjs';
@@ -30,7 +30,7 @@ import { listPids, waitForExit, waitForStart, pluginsOf, bundleRowIds, addBundle
30
30
  import { cwdSlug, bareId, stamp, recentSessions, sessionTitle } from './sessions.mjs';
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
- import { taskKeyboard, goalView, taskView, reasoningOf, filterLogLines } from './tasks.mjs';
33
+ import { taskKeyboard, goalView, taskView, filterLogLines } from './tasks.mjs';
34
34
  import { updatePolicy, bridgeRoot, copyRelease, installRelease, bridgeVersion, newestModuleMtime, npmLatest, npmLatestAsync } from './release.mjs';
35
35
 
36
36
  export async function handleSkillCommands(ctx) {
@@ -30,7 +30,7 @@ import { listPids, waitForExit, waitForStart, pluginsOf, bundleRowIds, addBundle
30
30
  import { cwdSlug, bareId, stamp, recentSessions, sessionTitle } from './sessions.mjs';
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
- import { taskKeyboard, goalView, taskView, reasoningOf, filterLogLines } from './tasks.mjs';
33
+ import { taskKeyboard, goalView, taskView, filterLogLines } from './tasks.mjs';
34
34
  import { updatePolicy, bridgeRoot, copyRelease, installRelease, bridgeVersion, newestModuleMtime, npmLatest, npmLatestAsync } from './release.mjs';
35
35
  import { CAP_CHOICES, CAP_MAX, CAP_MIN, setParallel } from '../jobs-cap.mjs';
36
36
 
@@ -14,7 +14,7 @@ import { parseAgentPresets, parseModelSelection, parsePermissionPresets, parseRe
14
14
  import { setRowConfig, unsetRowConfig } from '../profile-edit.mjs';
15
15
  import { parseReminder, stampAt, upcoming } from '../reminders.mjs';
16
16
  import { AgentsetStore, emptySet, slugId } from '../agentsets.mjs';
17
- import { SETTINGS_PAGES, renderSettingsCard, settingsCurrent } from '../settings-card.mjs';
17
+ import { SETTINGS_PAGES, cardPin, renderSettingsCard, settingsCurrent } from '../settings-card.mjs';
18
18
  import { applyFork, planFork, planRewind } from '../rewind.mjs';
19
19
  import { cutSession, isRewindPress } from '../rewind-buttons.mjs';
20
20
  import { renderRewindCard, renderRewindUsage } from '../rewind-card.mjs';
@@ -30,7 +30,8 @@ import { listPids, waitForExit, waitForStart, pluginsOf, bundleRowIds, addBundle
30
30
  import { cwdSlug, bareId, stamp, recentSessions, sessionTitle } from './sessions.mjs';
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
- import { taskKeyboard, goalView, taskView, reasoningOf, filterLogLines } from './tasks.mjs';
33
+ import { taskKeyboard, goalView, taskView, 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: reasoningOf(state, config, key) ? t(lang, 'ctrl.status.on') : t(lang, 'ctrl.status.off'),
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.
@@ -239,7 +240,7 @@ export async function handleViewCommands(ctx) {
239
240
  permission = null;
240
241
  }
241
242
  const current = {
242
- ...settingsCurrent({ config, state, key, reasoningOf }),
243
+ ...settingsCurrent({ config, state, key }),
243
244
  permissions: permission ? { profile: permission.profile, preset: permission.preset?.id || '' } : null,
244
245
  };
245
246
  const bound = agentsetOf(state, key);
@@ -269,19 +270,39 @@ export async function handleViewCommands(ctx) {
269
270
  return true;
270
271
  }
271
272
  case '/reasoning': {
272
- // One switch for "show me the decision trail". Anything but on/off prints
273
- // the current state, so a bare /reasoning never guesses.
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 on = reasoningOf(state, config, key);
276
- if (!['on', 'off'].includes(wanted)) {
277
- const word = t(lang, on ? 'msg.stateOn' : 'msg.stateOff');
278
- say(t(lang, 'msg.reasoningState', { state: word }));
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
- state.reasoning[key] = wanted === 'on';
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, wanted === 'on' ? 'msg.reasoningOn' : 'msg.reasoningOff'));
288
+ say(t(lang, next === 'off' ? 'msg.reasoningOff' : next === 'chat' ? 'msg.reasoningChat' : 'msg.reasoningOn'));
289
+ return true;
290
+ }
291
+ case '/pin': {
292
+ // The progress card is pinned while its turn runs, so getting back to the
293
+ // numbers is one tap instead of a scroll. Off by default: pinning someone's
294
+ // chat uninvited is not a favour, and a group needs the right to pin.
295
+ const wanted = String(arg || '').trim().toLowerCase();
296
+ const mode = cardPin(state, config, key);
297
+ const next = { on: 'on', off: 'off' }[wanted];
298
+ if (!next) {
299
+ say(t(lang, 'msg.pinState', { state: t(lang, `msg.pinMode.${mode}`) }));
300
+ return true;
301
+ }
302
+ state.pin = state.pin || {};
303
+ state.pin[key] = next;
304
+ ctx.saveState();
305
+ say(t(lang, next === 'on' ? 'msg.pinOn' : 'msg.pinOff'));
285
306
  return true;
286
307
  }
287
308
  case '/thoughts': {
package/control/tasks.mjs CHANGED
@@ -1,12 +1,12 @@
1
- // The goal card, the task list and the reasoning switch: the three small views `/goal` and `/tasks` draw.
2
- //
3
- // Split out of `control.mjs` by the 500-line plan: the command handlers that
4
- // follow call these, and none of them needs the dispatcher to do it.
5
- import { t } from '../i18n.mjs';
6
- import { progressOf } from '../goals.mjs';
7
- import { COMMAND_ALIASES, CONTROL_COMMANDS, DOCUMENTED_COMMANDS } from '../commands-registry.mjs';
8
-
9
- import { read } from './models.mjs';
1
+ // The goal card, the task list and the reasoning switch: the three small views `/goal` and `/tasks` draw.
2
+ //
3
+ // Split out of `control.mjs` by the 500-line plan: the command handlers that
4
+ // follow call these, and none of them needs the dispatcher to do it.
5
+ import { t } from '../i18n.mjs';
6
+ import { progressOf } from '../goals.mjs';
7
+ import { COMMAND_ALIASES, CONTROL_COMMANDS, DOCUMENTED_COMMANDS } from '../commands-registry.mjs';
8
+
9
+ import { read } from './models.mjs';
10
10
  /**
11
11
  * The task list as a keyboard: one button per task, labelled with its number and
12
12
  * state. A tap marks the task done and a second tap undoes it, so managing the
@@ -59,17 +59,6 @@ export function taskView(goal, lang) {
59
59
 
60
60
  export { CONTROL_COMMANDS, COMMAND_ALIASES, DOCUMENTED_COMMANDS };
61
61
 
62
- /**
63
- * Working notes ("💭" lines in the progress message) are on unless the topic or
64
- * the config says otherwise. Per-topic wins over the install default, so one
65
- * topic can keep the trail while another stays terse.
66
- */
67
- export function reasoningOf(state, config, key) {
68
- const perTopic = state?.reasoning?.[key];
69
- if (typeof perTopic === 'boolean') return perTopic;
70
- return config?.reasoning !== false;
71
- }
72
-
73
62
  /**
74
63
  * The chat view of `bridge.log`. Delivery chatter ("sent chat=…") answers
75
64
  * nothing when the question is "what did the agent do", so the default view
package/control.mjs CHANGED
@@ -41,7 +41,7 @@ import { listPids, waitForExit, waitForStart, pluginsOf, bundleRowIds, addBundle
41
41
  import { cwdSlug, bareId, stamp, recentSessions, sessionTitle } from './control/sessions.mjs';
42
42
  import { agentsOf, fleetOf, patchRows, skillsOf, AGENTS, PERSONA_HEADING, soulOf, setSoul } from './control/agents.mjs';
43
43
  import { fmt, AGENTSETS, agentset, agentsetOf, profileRowOf, bindAgentset, agentsetCard, agentsetKeyboard } from './control/agentsets.mjs';
44
- import { taskKeyboard, goalView, taskView, reasoningOf, filterLogLines } from './control/tasks.mjs';
44
+ import { taskKeyboard, goalView, taskView, filterLogLines } from './control/tasks.mjs';
45
45
  import { updatePolicy, bridgeRoot, copyRelease, installRelease, bridgeVersion, newestModuleMtime, npmLatest, npmLatestAsync } from './control/release.mjs';
46
46
 
47
47
  export async function handleControl(ctx) {
@@ -118,6 +118,6 @@ export async function handleControl(ctx) {
118
118
  // keeps its promises: same names, same module, different file.
119
119
  export { COMMAND_ALIASES, CONTROL_COMMANDS, DOCUMENTED_COMMANDS, MENU_COMMANDS } from './commands-registry.mjs';
120
120
  export { copyRelease } from './control/release.mjs';
121
- export { filterLogLines, reasoningOf } from './control/tasks.mjs';
121
+ export { filterLogLines } from './control/tasks.mjs';
122
122
  export { DSH_HOME } from './paths.mjs';
123
123
  export { modelOf, modelsOf, pluginsOf, recentSessions, skillsOf, soulOf, bridgeVersion, npmLatest, npmLatestAsync, installRelease };
@@ -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, reasoningOf } from './control.mjs';
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
- if (reasoningOf(state, config, key)) {
340
- text = `${t(lang, 'prompt.reasoning', { say: join(DIR, 'say.mjs') })}\n\n---\n\n${text}`;
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/help-explain.mjs CHANGED
@@ -16,7 +16,7 @@ const SECTION = {
16
16
  effort: 'Tuning', permissions: 'Tuning', preset: 'Tuning', crew: 'Tuning', plan: 'Tuning', jobs: 'Tuning', remind: 'Tuning',
17
17
  skills: 'Extensions', plugins: 'Extensions', soul: 'Extensions',
18
18
  update: 'Versions', subscribe: 'Versions',
19
- settings: 'Other', lang: 'Other', reasoning: 'Other', doctor: 'Other', logs: 'Other', report: 'Other',
19
+ settings: 'Other', lang: 'Other', reasoning: 'Other', pin: 'Other', doctor: 'Other', logs: 'Other', report: 'Other',
20
20
  app: 'Other', restart: 'Other', help: 'Other', menu: 'Panels',
21
21
  };
22
22
 
package/i18n/en/core.mjs CHANGED
@@ -14,13 +14,17 @@ export default {
14
14
  'settings.state.on': 'on',
15
15
  'settings.state.off': 'off',
16
16
  'settings.state.auto': 'auto',
17
- 'help.body': "Write the task as plain text. Each forum topic is its own session:\n\nWork: /cd \u003cproject\u003e · /new · /stop · /send \u003cfile\u003e · /seed \u003ctext\u003e\nGoals: /goal · /tasks [\u003ctext\u003e|done N] · /tasks (tap to tick)\nSessions: /status · /sessions [\u003cid\u003e] · /rewind [n|undo|fork [n]|branches] · /new · /profile \u003cname\u003e\nAgents: /agents · /agents set model|depth|filter … @tool\nModels: /model · /model \u003cid\u003e · /fallback · /prices · /thoughts\nTuning: /effort · /permissions · /preset · /crew [use|show|off|new] · /plan · /jobs [n] · /remind\nExtensions: /skills · /plugins [add|remove] · /soul\nVersions: /update [confirm|on|off|auto] · /subscribe on|off\nOther: /settings · /lang · /reasoning · /doctor · /logs [errors|N] · /report · /app · /restart · /help\nPanels: /menu — the same commands as buttons, page by page. /menu on puts four keys under the message field.",
17
+ 'help.body': "Write the task as plain text. Each forum topic is its own session:\n\nWork: /cd \u003cproject\u003e · /new · /stop · /send \u003cfile\u003e · /seed \u003ctext\u003e\nGoals: /goal · /tasks [\u003ctext\u003e|done N] · /tasks (tap to tick)\nSessions: /status · /sessions [\u003cid\u003e] · /rewind [n|undo|fork [n]|branches] · /new · /profile \u003cname\u003e\nAgents: /agents · /agents set model|depth|filter … @tool\nModels: /model · /model \u003cid\u003e · /fallback · /prices · /thoughts\nTuning: /effort · /permissions · /preset · /crew [use|show|off|new] · /plan · /jobs [n] · /remind\nExtensions: /skills · /plugins [add|remove] · /soul\nVersions: /update [confirm|on|off|auto] · /subscribe on|off\nOther: /settings · /lang · /reasoning · /pin · /doctor · /logs [errors|N] · /report · /app · /restart · /help\nPanels: /menu — the same commands as buttons, page by page. /menu on puts four keys under the message field.",
18
18
  'settings.reply.title': 'What the bot says',
19
19
  'settings.agent.title': 'Who answers, and how hard it works',
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 message. Off keeps the chat quiet.',
23
+ 'settings.reasoning.hint': 'The 💭 lines: in the progress card, also as messages in the chat, or off.',
24
+ 'settings.pin.label': '📌 Pin the progress card',
25
+ 'settings.pin.hint': 'Holds the card at the top of the chat while the turn runs, so the numbers are one tap away.',
26
+ 'settings.reasoning.chat': 'chat',
27
+ 'settings.reasoning.card': 'card',
24
28
  'settings.lang.label': 'Reply language',
25
29
  'settings.lang.hint': 'auto answers in the language of your message; en, ru, zh pin it.',
26
30
  'settings.thoughts.label': '💭 Working notes: last turn, all, or off',
@@ -38,6 +42,11 @@ export default {
38
42
  'settings.set.hint': 'Model, effort, permissions and preset as one named switch.',
39
43
  'settings.agents.label': '🕸 Agents',
40
44
  'settings.agents.hint': 'Who can be spawned, on which model, with which tools.',
45
+ 'settings.cd.label': '📁 Project',
46
+ 'settings.cd.hint': 'Which folder this topic works in.',
47
+ 'settings.fallback.label': '🔁 Fallback chain',
48
+ 'settings.fallback.hint': 'Who answers when a provider refuses, and in what order.',
49
+ 'settings.done': '✓ Done',
41
50
  'settings.u-late.label': 'New version notices',
42
51
  'settings.u-auto.label': 'Auto-install',
43
52
  'settings.u-auto.hint': 'With auto on, a release is downloaded by itself; /restart loads it.',
@@ -60,10 +69,9 @@ export default {
60
69
  'settings.tab.updates': 'Updates',
61
70
  'settings.tab.health': 'Health',
62
71
  'settings.u-late.hint': 'One message per new release; turning it off installs nothing and moves nothing.',
63
- 'settings.card.foot': 'A tap changes the setting and this card turns into one line saying what changed. Delete the line and it is gone from the chat.',
72
+ 'settings.card.foot': 'A tap changes the setting and the card stays, redrawn with the new value. "Done" removes it from the chat.',
64
73
  'settings.reply.setBound': 'This topic uses set {name}: model, effort, permissions and preset come from it.',
65
- 'settings.card.changed': '⌨️ {label} → {value}',
66
- 'settings.card.door': '⌨️ {command} — send it below or press it again',
74
+ 'settings.card.changed': '✓ {label}: {value}',
67
75
  'settings.card.stale': 'That button is from an older version of the card. Open /settings again.',
68
76
  'btn.stop': 'Stop',
69
77
  'btn.logs': 'Logs',
@@ -98,6 +106,10 @@ export default {
98
106
  'msg.langSet': 'Language set to English.',
99
107
  'msg.reasoningOn': 'Working notes on: 💭 lines will appear in the progress message.\nOff: /reasoning off',
100
108
  'msg.reasoningOff': 'Working notes off. The progress message keeps the step list only.\nOn: /reasoning on',
109
+ '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',
110
+ 'msg.reasoningMode.off': 'off',
111
+ 'msg.reasoningMode.card': 'in the progress message',
112
+ 'msg.reasoningMode.chat': 'in the chat and in the progress message',
101
113
  'msg.stateOn': 'on',
102
114
  'msg.stateOff': 'off',
103
115
  '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 +126,14 @@ export default {
114
126
  'profile.createFailed': 'Could not create profile {name} — the template was not written. Try again or create it in the app.',
115
127
  'profile.badName': 'Name it with lowercase letters, digits and dashes: /profile new my-space from web',
116
128
  'profile.set': 'Topic profile → {name} ({route}). Applies from the next turn.',
117
- 'msg.reasoningState': 'Working notes: {state}. Switch with /reasoning on or /reasoning off.',
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.',
129
+ 'msg.reasoningState': 'Working notes: {state}. Switch with /reasoning off, /reasoning card or /reasoning chat.',
130
+ 'msg.pinOn': 'The progress card is pinned while its turn runs, so one tap brings back the clock, the speed and the steps. The next turn replaces it.',
131
+ 'msg.pinOff': 'The progress card stays unpinned.',
132
+ 'msg.pinState': 'Progress card pinned: {state}. Switch with /pin on or /pin off.',
133
+ 'msg.pinMode.on': 'on',
134
+ 'msg.pinMode.off': 'off',
135
+ '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.',
136
+ '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
137
  'cmd.help.title': 'Commands',
120
138
  'cmd.help.hint': 'Send any text to start a task. In a forum topic: /cd <project> binds the topic to that project.',
121
139
  'cmd.cd.bound': 'Topic bound to project:\n{path}\n\nAll turns run from this directory.',
@@ -204,7 +222,7 @@ export default {
204
222
  'bridge.fail.sandbox': 'DSH denied access to a file or directory. Check the project path and its permissions.',
205
223
  'bridge.fail.unknownModel': 'the model from the config is unavailable. Working ones: /model.',
206
224
  '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.',
225
+ 'bridge.fail.rate': 'the provider is rate-limiting this key. Wait a minute — or /fallback walks the chain to another route.',
208
226
  'bridge.fail.empty': 'the model returned nothing. Retry or switch the model: /model.',
209
227
  'bridge.fail.generic': 'retry the request; if the error is the same — /doctor and /logs errors.',
210
228
  '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.",