desky-agent 0.3.12 → 0.3.13

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
@@ -39,11 +39,34 @@ npx desky-agent start запустить в трее, без окна
39
39
  npx desky-agent stop выйти и отпустить порт (хуки не запустят Desky до open или start)
40
40
  npx desky-agent status плата, состояние, сессии
41
41
  npx desky-agent doctor проверить всё по порядку и подсказать, что исправить
42
+ npx desky-agent emotions какие эмоции Desky показывает, а какие выключены
43
+ npx desky-agent emotions off reading typing не показывать «читает» и «печатает»
44
+ npx desky-agent emotions on reading снова показывать; on all — все
45
+ npx desky-agent emotions calm только спокойные (тихий режим)
42
46
  npx desky-agent firmware версия прошивки в пакете и на плате
43
47
  npx desky-agent firmware update перепрошить плату версией из пакета (калибровка остаётся)
44
48
  npx desky-agent uninstall убрать всё, кроме настроек
45
49
  ```
46
50
 
51
+ ## Эмоции
52
+
53
+ Любую сценку, которую Desky играет за агентом, можно выключить: в пульте раздел «Емоції», в трее «Тихий режим», в терминале `npx desky-agent emotions`. Вместо выключенной эмоции Desky спокойно сидит, как когда ничего не происходит (состояние `idle`: руки опущены, изредка оглядывается), и её звук тоже молчит. Выключенные короткие вставки (кивок «слушает», «ошибка», «просыпается») просто пропускаются: остаётся то, что идёт под ними. У каждой эмоции в пульте есть «▶ Показати» — сыграть её на Desky прямо сейчас, даже выключенную.
54
+
55
+ | Имя в терминале | В пульте | Состояние | Спокойная |
56
+ |---|---|---|---|
57
+ | `typing` | Друкує | `work` | |
58
+ | `reading` | Читає код | `read` | да |
59
+ | `listening` | Слухає | `listen` | |
60
+ | `asking` | Кличе тебе | `ask` | да |
61
+ | `waiting` | Чекає на фонову задачу | `wait` | да |
62
+ | `happy` | Радіє готовому | `done` | |
63
+ | `error` | Засмучується через помилку | `error` | |
64
+ | `limits` | Втомився: скінчилися ліміти | `limit` | да |
65
+ | `waking` | Прокидається | `wake` | |
66
+ | `sleeping` | Спить | `sleep` | да |
67
+
68
+ В терминале годятся и сами имена состояний (`read`, `work`, …). «Только спокойные» (`calm`, «Лише спокійні», «Тихий режим») выключает всё, что не помечено спокойным. Выключенные хранятся в `~/.clawd-desk/config.json` списком `emotions_off` и переживают перезапуск и обновление; старый конфиг без этого ключа значит «всё включено». Если Desky не запущен, команда пишет в конфиг, и выбор действует со следующего запуска. Прошивка ничего об этом не знает: фильтрует приложение, выключенное состояние на плату просто не уходит.
69
+
47
70
  ## Прошивка
48
71
 
49
72
  Пакет везёт прошивку своей версии. Если на плате прошивка старше, `npx desky-agent` или приложение в трее обновляют её сами: пишется одна строка «прошивка Desky обновлена: 0.1.0 → 0.2.0». Калибровка и серийный номер в памяти робота при этом не стираются. Python и PlatformIO не нужны.
@@ -1,20 +1,20 @@
1
- Copyright (c) 2013 GitHub Inc.
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2013 GitHub Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,4 +1,4 @@
1
- rcedit-x64.exe — rcedit v2.0.0 from https://github.com/electron/rcedit/releases/tag/v2.0.0 (MIT, GitHub, Inc.).
2
- sha256 3e7801db1a5edbec91b49a24a094aad776cb4515488ea5a4ca2289c400eade2a
3
- The installer runs it on Windows to put the Desky head into the Electron exe, so the taskbar shows it.
4
- The npm package rcedit carries the same binary but all its versions are deprecated on npm.
1
+ rcedit-x64.exe — rcedit v2.0.0 from https://github.com/electron/rcedit/releases/tag/v2.0.0 (MIT, GitHub, Inc.).
2
+ sha256 3e7801db1a5edbec91b49a24a094aad776cb4515488ea5a4ca2289c400eade2a
3
+ The installer runs it on Windows to put the Desky head into the Electron exe, so the taskbar shows it.
4
+ The npm package rcedit carries the same binary but all its versions are deprecated on npm.
package/bin/cli.js CHANGED
@@ -13,6 +13,11 @@ const HELP = `desky-agent ${require('../package.json').version}: Desky Agent —
13
13
  npx desky-agent stop вийти й звільнити порт (хуки не запустять Desky до open або start)
14
14
  npx desky-agent status плата, стан, сесії
15
15
  npx desky-agent doctor перевірити все по черзі
16
+ npx desky-agent emotions які емоції Desky показує, а які вимкнено
17
+ npx desky-agent emotions off reading [typing ...]
18
+ не показувати: Desky лишається спокійним («нічого не робить»)
19
+ npx desky-agent emotions on reading | on all | calm
20
+ знову показувати; all — усі; calm — лише спокійні (тихий режим)
16
21
  npx desky-agent firmware прошивка в пакеті й на платі
17
22
  npx desky-agent firmware update
18
23
  перепрошити плату версією з пакета (калібрування залишається)
@@ -47,7 +52,8 @@ async function status() {
47
52
  const link = st.connected ? `плата на ${st.port}` : 'плату не під\'єднано';
48
53
  const OURS = ['desky-agent', 'clawdydesk']; // clawdydesk: the same app before the rename (0.2.4 and older)
49
54
  const who = OURS.includes(st.app) ? `Desky Agent ${st.version}` : 'стара програма на Python (agent/)';
50
- console.log(`${who}; ${link}; показує: ${NAMES[st.state] || st.state}; сесій: ${st.sessions}`
55
+ const hidden = st.actual && st.actual !== st.state ? ` (агент: ${NAMES[st.actual] || st.actual}, емоцію вимкнено)` : '';
56
+ console.log(`${who}; ${link}; показує: ${NAMES[st.state] || st.state}${hidden}; сесій: ${st.sessions}`
51
57
  + (st.manual ? '; ручне керування' : ''));
52
58
  if (st.board) {
53
59
  console.log(` плата: прошивка ${st.board.fw || 'без версії'}, протокол ${st.board.proto}`
@@ -106,6 +112,68 @@ async function doctor() {
106
112
  }
107
113
  }
108
114
 
115
+ function postJson(p, body) {
116
+ const http = require('http');
117
+ const data = Buffer.from(JSON.stringify(body));
118
+ return new Promise(resolve => {
119
+ const req = http.request({ host: '127.0.0.1', port: paths.port(), path: p, method: 'POST', timeout: 2000,
120
+ headers: { 'Content-Type': 'application/json', 'Content-Length': data.length } }, res => {
121
+ let s = '';
122
+ res.on('data', c => (s += c));
123
+ res.on('end', () => {
124
+ let j = {};
125
+ try { j = JSON.parse(s); } catch (e) { /* not ours */ }
126
+ resolve({ code: res.statusCode, body: j });
127
+ });
128
+ });
129
+ req.on('timeout', () => req.destroy());
130
+ req.on('error', () => resolve(null));
131
+ req.end(data);
132
+ });
133
+ }
134
+
135
+ /** emotions [off|on <names...>|on all|calm]: the running app takes it at once, else config.json for the next start. */
136
+ async function emotionsCmd(args) {
137
+ const { EMOTIONS, NOT_CALM, emotionKey } = require('../src/core');
138
+ const { loadConfig, writeConfig } = require('../src/daemon');
139
+ const ins = require('../src/install');
140
+ const words = args.filter(a => !a.startsWith('-')).slice(1);
141
+ const live = await ins.get('/config');
142
+ const running = Boolean(live && live.config);
143
+ let off = new Set((running ? live.config : loadConfig()).emotions_off || []);
144
+ const verb = (words[0] || '').toLowerCase();
145
+ if (verb) {
146
+ const names = words.slice(1);
147
+ if (verb === 'calm' || verb === 'quiet') off = new Set(NOT_CALM);
148
+ else if (verb === 'on' && names.length === 1 && names[0].toLowerCase() === 'all') off = new Set();
149
+ else if (verb === 'off' && names.length === 1 && names[0].toLowerCase() === 'all') off = new Set(EMOTIONS.map(e => e.key));
150
+ else if (verb === 'on' || verb === 'off') {
151
+ if (!names.length) fail(`яку емоцію? наприклад: desky-agent emotions ${verb} reading`);
152
+ for (const n of names) {
153
+ if (n.toLowerCase() === 'idle') fail('idle — спокійна поза, в яку йдуть вимкнені емоції; її не вимкнути');
154
+ const k = emotionKey(n);
155
+ if (!k) fail(`не знаю емоції «${n}». Є: ` + EMOTIONS.map(e => e.alias[0] || e.key).join(', '));
156
+ if (verb === 'off') off.add(k);
157
+ else off.delete(k);
158
+ }
159
+ } else fail('desky-agent emotions [off|on <емоція> | on all | calm]');
160
+ const next = { emotions_off: EMOTIONS.map(e => e.key).filter(k => off.has(k)) };
161
+ if (running) {
162
+ const r = await postJson('/config', next);
163
+ if (!r || r.code !== 200) fail('Desky не прийняв: ' + ((r && r.body.error) || 'не відповідає'));
164
+ } else {
165
+ writeConfig(next);
166
+ }
167
+ }
168
+ console.log('Емоції Desky' + (running ? '' : ' (Desky не запущено: діє з наступного запуску)') + ':');
169
+ for (const e of EMOTIONS) {
170
+ const name = (e.alias[0] || e.key).padEnd(9);
171
+ console.log(` ${off.has(e.key) ? 'вимк ' : 'увімк'} ${name} ${e.label}${e.calm ? '' : ' *'}`);
172
+ }
173
+ console.log(' * не спокійна: вимикається командою calm. Замість вимкненої емоції Desky «нічого не робить».');
174
+ return [...off];
175
+ }
176
+
109
177
  function askYes(question) {
110
178
  const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });
111
179
  return new Promise(resolve => rl.question(question, a => {
@@ -178,6 +246,9 @@ async function main() {
178
246
  return ins().install({ open: !args.includes('--no-open'), yes: args.includes('--yes') || args.includes('-y') });
179
247
  case 'firmware':
180
248
  return firmwareCmd(args);
249
+ case 'emotions':
250
+ case 'emotion':
251
+ return emotionsCmd(args);
181
252
  case 'open':
182
253
  return startApp([]);
183
254
  case 'start':