dsh-tg-bridge 1.33.3 → 1.34.1

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
@@ -30,9 +30,10 @@ that answers, one step at a time.
30
30
  [model,model]` writes the provider without an AI turn, and the key itself is
31
31
  never typed — only the name of the variable that holds it. The new models appear
32
32
  on `/model` as routes.
33
- - **Input: text, voice, photos.** Voice is local faster-whisper and the transcript
34
- is shown before the answer. A photo is read by the turn's own model through
35
- `read_image`, text and UI included; no second model is needed.
33
+ - **Input: text, voice, photos.** Any speech engine plugs in — a local script, any
34
+ command-line tool, or an OpenAI-compatible API (see [`docs/VOICE.md`](docs/VOICE.md))
35
+ — and the transcript is shown before the answer. A photo is read by the turn's own
36
+ model through `read_image`, text and UI included; no second model is needed.
36
37
  - **Goal and checklist per topic.** `/goal`, `/tasks`; both survive restarts and
37
38
  are prepended to every turn.
38
39
  - **Two scopes for every setting.** `/reasoning <mode> all` moves the default,
@@ -423,16 +424,18 @@ What each kind of attachment becomes inside a running turn:
423
424
 
424
425
  | Sent | Inside the turn | Needs |
425
426
  |---|---|---|
426
- | voice note, audio file, audio sent as a document | transcript, echoed as `🎤 …` before the steer | `faster-whisper` on `PATH`, enabled with `init --voice`; **off by default** |
427
+ | voice note, audio file, audio sent as a document | transcript, echoed as `🎤 …` before the steer | any engine you point `voice` at: `script`, `command` or an OpenAI-compatible `openai` endpoint; **off by default** |
427
428
  | small text file (`.md`, `.json`, `.csv`, `.py`, `.log`, … up to 60 KB) | the content itself between `<file>` markers — no tool call needed | nothing |
428
429
  | PDF, archive, binary, anything bigger | its local path under `~/.dsh/tg-bridge/inbox/` | nothing; the agent opens it with its own tools |
429
430
  | video, video note, animation | its path; the agent can pull frames or sound out with ffmpeg | ffmpeg, only if frames or audio are needed |
430
431
  | photo | its path plus one honest line; the turn reads it with `read_image`, and says so in one line if it cannot | a model that accepts images |
431
432
 
432
- Voice is the one row with a hidden prerequisite. Without `faster-whisper`
433
- installed, a voice note still arrives — as a path the agent cannot read — so the
434
- bridge says transcription is off instead of pretending it heard something. Run
435
- `dsh-tg init --voice` after installing the transcriber; nothing else changes.
433
+ Voice is the one row with a hidden prerequisite: something has to turn audio into
434
+ text. Faster-whisper is what `init --voice` writes, but it is not the only answer —
435
+ `voice.provider` also takes `command` (whisper.cpp, Vosk, a wrapper of your own) or
436
+ `openai` (OpenAI, Groq, a local server; anything that speaks
437
+ `/audio/transcriptions`). With no backend configured, a voice note is not swallowed:
438
+ the bridge says what is missing and points at [`docs/VOICE.md`](docs/VOICE.md).
436
439
 
437
440
  A caption does not turn the attachment into a text-only message: it is folded into the same
438
441
  hand-over, so "why did this fail" plus a `.log` file arrives as one steer.
@@ -149,22 +149,30 @@ export async function handleBridgeCommands(ctx) {
149
149
  return true;
150
150
  }
151
151
  say(t(lang, 'ctrl.app.restarting', { pids: before.join(', '), exe: EXE }));
152
- spawn('taskkill', ['/IM', 'DeepSeek Harness.exe', '/T', '/F'], { windowsHide: true, detached: true }).on('close', async () => {
153
- const gone = await waitForExit(before, 12000);
154
- if (!gone) {
155
- say(t(lang, 'ctrl.app.stuck'));
156
- return;
157
- }
158
- if (!existsSync(EXE)) {
159
- say(t(lang, 'ctrl.app.noExe', { exe: EXE }));
160
- return;
161
- }
162
- spawn(EXE, [], { detached: true, stdio: 'ignore', windowsHide: false }).unref();
163
- const up = await waitForStart(15000);
164
- say(up.length
165
- ? t(lang, 'ctrl.app.restarted', { pids: up.join(', ') })
166
- : t(lang, 'ctrl.app.notUp'));
152
+ // Kill the processes that were just named, one by one. An image-name kill
153
+ // takes down every program with that name — a second DSH opened for another
154
+ // profile, or an instance started after this list was read — and the message
155
+ // above promised the pids it lists, not every window on the machine.
156
+ const kill = (pid) => new Promise((resolve) => {
157
+ spawn('taskkill', ['/PID', String(pid), '/T', '/F'], { windowsHide: true, detached: true })
158
+ .on('close', resolve)
159
+ .on('error', resolve);
167
160
  });
161
+ await Promise.all(before.map(kill));
162
+ const gone = await waitForExit(before, 12000);
163
+ if (!gone) {
164
+ say(t(lang, 'ctrl.app.stuck'));
165
+ return true;
166
+ }
167
+ if (!existsSync(EXE)) {
168
+ say(t(lang, 'ctrl.app.noExe', { exe: EXE }));
169
+ return true;
170
+ }
171
+ spawn(EXE, [], { detached: true, stdio: 'ignore', windowsHide: false }).unref();
172
+ const up = await waitForStart(15000);
173
+ say(up.length
174
+ ? t(lang, 'ctrl.app.restarted', { pids: up.join(', ') })
175
+ : t(lang, 'ctrl.app.notUp'));
168
176
  return true;
169
177
  }
170
178
  case '/stop': {
@@ -30,6 +30,7 @@ export async function handleModelCommand(ctx) {
30
30
  current: routes.length ? { provider: topic.provider, model: topic.model } : null,
31
31
  topic: topic.source === 'topic',
32
32
  fallback: topic.source === 'topic' ? modelOf(activeProfile) : null,
33
+ answered: state.answered?.[key] || null,
33
34
  t: (k, v) => t(lang, k, v),
34
35
  });
35
36
  say(card.text, { keyboard: card.keyboard });
@@ -5,7 +5,7 @@
5
5
  import { execFileSync, spawn, spawnSync } from 'node:child_process';
6
6
  import { cpSync, existsSync, copyFileSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
7
7
  import { homedir, tmpdir } from 'node:os';
8
- import { join, basename } from 'node:path';
8
+ import { basename, isAbsolute, join, relative } from 'node:path';
9
9
  import { fileURLToPath } from 'node:url';
10
10
  import { t, LANGS, normalizeLang } from '../i18n.mjs';
11
11
  import { addTask, clearGoal, doneTask, editTask, finishGoal, goalOf, progressOf, reopenGoal, removeTask, setGoal } from '../goals.mjs';
@@ -46,7 +46,17 @@ export async function handleSkillCommands(ctx) {
46
46
  const rows = skillsOf();
47
47
  const want = (arg || '').trim();
48
48
  if (want) {
49
- const dir = join(DSH_HOME, 'skills', want);
49
+ // A skill is one directory under `skills/`, and the name here is whatever
50
+ // was typed: `join` walks out of the root for `../..`, so the resolved
51
+ // path is checked to still be inside before anything is read. The old
52
+ // code could be pointed at any `SKILL.md` on the disk.
53
+ const root = join(DSH_HOME, 'skills');
54
+ const dir = join(root, want);
55
+ const inside = relative(root, dir);
56
+ if (!inside || inside.startsWith('..') || isAbsolute(inside)) {
57
+ say(t(lang, 'ctrl.skills.none', { name: want }));
58
+ return true;
59
+ }
50
60
  const body = read(join(dir, 'SKILL.md'));
51
61
  say(body
52
62
  ? t(lang, 'ctrl.skills.body', { name: want, body: body.slice(0, 3000) })
@@ -68,7 +68,7 @@ export function modelPress(data) {
68
68
  * provider prefix each is a wall, and a group heading stays readable when the
69
69
  * models have long names.
70
70
  */
71
- export function modelCard({ profile, routes, current = null, topic = false, fallback = null, t, limit = 60 }) {
71
+ export function modelCard({ profile, routes, current = null, topic = false, fallback = null, answered = null, t, limit = 60 }) {
72
72
  const now = current || (routes.find((route) => route.current) || null);
73
73
  const isNow = (route) => Boolean(now && route.provider === now.provider && route.model === now.model);
74
74
  const known = routes.filter((route) => routeData(route.provider, route.model));
@@ -117,6 +117,12 @@ export function modelCard({ profile, routes, current = null, topic = false, fall
117
117
  lines.push(t('ctrl.model.pickNowDefault', { route: `${fallback.provider}/${fallback.model}` }));
118
118
  }
119
119
  } else lines.push(t('ctrl.model.pickUnknown', { profile }));
120
+ // The route above is the one this topic is set to. After a fallback the turn
121
+ // ran somewhere else, and a card that only names the setting reads as "this is
122
+ // who answers" when it is not.
123
+ if (answered?.model) {
124
+ lines.push(t(answered.switched ? 'ctrl.model.answeredSwitched' : 'ctrl.model.answered', { model: answered.model }));
125
+ }
120
126
  lines.push('');
121
127
  // Three different silences, and they are not the same fact: a profile with no
122
128
  // models at all, a profile whose every route is too long to be a button, and