desky-agent 0.3.0 → 0.3.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawd-desk",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "chip": "esp32s3",
5
5
  "board": "waveshare-esp32-s3-zero",
6
6
  "flash_size": "4MB",
@@ -27,7 +27,7 @@
27
27
  "file": "firmware.bin",
28
28
  "address": "0x10000",
29
29
  "size": 338304,
30
- "sha256": "0e39e3031dc1eba11c8fe993488c72dc8fa47a0ba57389c442147449d9a94cc9"
30
+ "sha256": "a73638b97c94b2ac2885c544b8bac8b8c08b44a42c8016e03fe023548fa636a0"
31
31
  }
32
32
  ]
33
33
  }
package/package.json CHANGED
@@ -1,40 +1,41 @@
1
- {
2
- "name": "desky-agent",
3
- "version": "0.3.0",
4
- "description": "Desky Agent: Desky, a desk robot that acts out what Claude Code is doing. Tray app, hooks and installer in one npx command",
5
- "keywords": [
6
- "claude-code",
7
- "claude",
8
- "hooks",
9
- "robot",
10
- "esp32",
11
- "tray",
12
- "desk-toy"
13
- ],
14
- "license": "MIT",
15
- "bin": {
16
- "desky-agent": "bin/cli.js"
17
- },
18
- "main": "electron/main.js",
19
- "files": [
20
- "bin",
21
- "src",
22
- "electron",
23
- "ui",
24
- "assets",
25
- "firmware"
26
- ],
27
- "engines": {
28
- "node": ">=18"
29
- },
30
- "scripts": {
31
- "test": "node --test",
32
- "prepack": "node scripts/pack-firmware.js",
33
- "start": "electron . --open"
34
- },
35
- "dependencies": {
36
- "electron": "44.9.3",
37
- "esptool-js": "0.7.0",
38
- "serialport": "13.0.0"
39
- }
40
- }
1
+ {
2
+ "name": "desky-agent",
3
+ "version": "0.3.1",
4
+ "description": "Desky Agent: Desky, a desk robot that acts out what Claude Code or Codex is doing. Tray app, hooks and installer in one npx command",
5
+ "keywords": [
6
+ "claude-code",
7
+ "claude",
8
+ "codex",
9
+ "hooks",
10
+ "robot",
11
+ "esp32",
12
+ "tray",
13
+ "desk-toy"
14
+ ],
15
+ "license": "MIT",
16
+ "bin": {
17
+ "desky-agent": "bin/cli.js"
18
+ },
19
+ "main": "electron/main.js",
20
+ "files": [
21
+ "bin",
22
+ "src",
23
+ "electron",
24
+ "ui",
25
+ "assets",
26
+ "firmware"
27
+ ],
28
+ "engines": {
29
+ "node": ">=18"
30
+ },
31
+ "scripts": {
32
+ "test": "node --test",
33
+ "prepack": "node scripts/pack-firmware.js",
34
+ "start": "electron . --open"
35
+ },
36
+ "dependencies": {
37
+ "electron": "44.9.3",
38
+ "esptool-js": "0.7.0",
39
+ "serialport": "13.0.0"
40
+ }
41
+ }
package/src/autostart.js CHANGED
@@ -1,106 +1,106 @@
1
- 'use strict';
2
- // Start Desky at login, on each system its own way. Used by the installer and by the tray's checkbox.
3
- // Windows: HKCU\...\Run "Desky Agent" macOS: ~/Library/LaunchAgents/desk.clawd.app.plist
4
- // Linux: ~/.config/autostart/clawd.desktop
5
- // No KeepAlive anywhere: "Выйти" and "desky-agent stop" must stay stopped until the next login.
6
-
7
- const fs = require('fs');
8
- const os = require('os');
9
- const path = require('path');
10
- const { spawnSync } = require('child_process');
11
- const paths = require('./paths');
12
-
13
- const RUN_KEY = 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run';
14
- const RUN_NAME = 'Desky Agent', OLD_RUN_NAME = 'Clawd'; // the Run value; "Clawd": 0.2.4 and older
15
- const LABEL = 'desk.clawd.app';
16
- const OLD_LABEL = 'desk.clawd.agent'; // the Python agent's LaunchAgent
17
- const agents = () => path.join(os.homedir(), 'Library', 'LaunchAgents');
18
- const PLIST = () => path.join(agents(), LABEL + '.plist');
19
- const DESKTOP = () => path.join(process.env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config'), 'autostart',
20
- 'clawd.desktop');
21
-
22
- function launchInfo() {
23
- return JSON.parse(fs.readFileSync(paths.LAUNCH, 'utf8'));
24
- }
25
-
26
- const xml = s => String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
27
-
28
- function plist(command, args) {
29
- const items = [command, ...args].map(a => `\t\t<string>${xml(a)}</string>`).join('\n');
30
- return `<?xml version="1.0" encoding="UTF-8"?>
31
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
32
- <plist version="1.0">
33
- <dict>
34
- \t<key>Label</key>
35
- \t<string>${LABEL}</string>
36
- \t<key>ProgramArguments</key>
37
- \t<array>
38
- ${items}
39
- \t</array>
40
- \t<key>RunAtLoad</key>
41
- \t<true/>
42
- \t<key>ProcessType</key>
43
- \t<string>Interactive</string>
44
- </dict>
45
- </plist>
46
- `;
47
- }
48
-
49
- // a .desktop Exec line: quote every argument, escape what the spec says to
50
- const execLine = argv => argv.map(a => '"' + String(a).replace(/(["`$\\])/g, '\\$1') + '"').join(' ');
51
-
52
- function desktopEntry(command, args, extra = '') {
53
- return `[Desktop Entry]
54
- Type=Application
55
- Name=Desky Agent
56
- Comment=Desky shows what Claude Code is doing
57
- Exec=${execLine([command, ...args])}
58
- Icon=${path.join(paths.HOME, 'clawd.png')}
59
- Terminal=false
60
- Categories=Utility;
61
- ${extra}`;
62
- }
63
-
64
- function winQuote(a) {
65
- return /[\s"]/.test(a) ? '"' + a.replace(/"/g, '\\"') + '"' : a;
66
- }
67
-
68
- function enable() {
69
- const { command, args = [] } = launchInfo();
70
- const argv = [...args, '--login'];
71
- if (process.platform === 'win32') {
72
- const value = [command, ...argv].map(winQuote).join(' ');
73
- spawnSync('reg', ['delete', RUN_KEY, '/v', OLD_RUN_NAME, '/f'], { windowsHide: true, stdio: 'ignore' });
74
- spawnSync('reg', ['add', RUN_KEY, '/v', RUN_NAME, '/t', 'REG_SZ', '/d', value, '/f'], { windowsHide: true });
75
- } else if (process.platform === 'darwin') {
76
- fs.mkdirSync(agents(), { recursive: true });
77
- fs.writeFileSync(PLIST(), plist(command, argv));
78
- } else {
79
- fs.mkdirSync(path.dirname(DESKTOP()), { recursive: true });
80
- fs.writeFileSync(DESKTOP(), desktopEntry(command, argv, 'X-GNOME-Autostart-enabled=true\n'));
81
- }
82
- }
83
-
84
- function disable() {
85
- if (process.platform === 'win32') {
86
- for (const v of [RUN_NAME, OLD_RUN_NAME]) spawnSync('reg', ['delete', RUN_KEY, '/v', v, '/f'], { windowsHide: true, stdio: 'ignore' });
87
- } else if (process.platform === 'darwin') {
88
- fs.rmSync(PLIST(), { force: true });
89
- } else {
90
- fs.rmSync(DESKTOP(), { force: true });
91
- }
92
- }
93
-
94
- function isEnabled() {
95
- if (process.platform === 'win32') {
96
- return spawnSync('reg', ['query', RUN_KEY, '/v', RUN_NAME], { windowsHide: true, stdio: 'ignore' }).status === 0;
97
- }
98
- return fs.existsSync(process.platform === 'darwin' ? PLIST() : DESKTOP());
99
- }
100
-
101
- // the tray asks every second; the registry or the disk once is enough until the checkbox changes it
102
- let cached = null;
103
- const isEnabledCached = () => (cached === null ? (cached = isEnabled()) : cached);
104
- const forget = () => { cached = null; };
105
-
106
- module.exports = { enable, disable, isEnabled, isEnabledCached, forget, plist, desktopEntry, execLine, LABEL, OLD_LABEL, RUN_KEY };
1
+ 'use strict';
2
+ // Start Desky at login, on each system its own way. Used by the installer and by the tray's checkbox.
3
+ // Windows: HKCU\...\Run "Desky Agent" macOS: ~/Library/LaunchAgents/desk.clawd.app.plist
4
+ // Linux: ~/.config/autostart/clawd.desktop
5
+ // No KeepAlive anywhere: "Выйти" and "desky-agent stop" must stay stopped until the next login.
6
+
7
+ const fs = require('fs');
8
+ const os = require('os');
9
+ const path = require('path');
10
+ const { spawnSync } = require('child_process');
11
+ const paths = require('./paths');
12
+
13
+ const RUN_KEY = 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run';
14
+ const RUN_NAME = 'Desky Agent', OLD_RUN_NAME = 'Clawd'; // the Run value; "Clawd": 0.2.4 and older
15
+ const LABEL = 'desk.clawd.app';
16
+ const OLD_LABEL = 'desk.clawd.agent'; // the Python agent's LaunchAgent
17
+ const agents = () => path.join(os.homedir(), 'Library', 'LaunchAgents');
18
+ const PLIST = () => path.join(agents(), LABEL + '.plist');
19
+ const DESKTOP = () => path.join(process.env.XDG_CONFIG_HOME || path.join(os.homedir(), '.config'), 'autostart',
20
+ 'clawd.desktop');
21
+
22
+ function launchInfo() {
23
+ return JSON.parse(fs.readFileSync(paths.LAUNCH, 'utf8'));
24
+ }
25
+
26
+ const xml = s => String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
27
+
28
+ function plist(command, args) {
29
+ const items = [command, ...args].map(a => `\t\t<string>${xml(a)}</string>`).join('\n');
30
+ return `<?xml version="1.0" encoding="UTF-8"?>
31
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
32
+ <plist version="1.0">
33
+ <dict>
34
+ \t<key>Label</key>
35
+ \t<string>${LABEL}</string>
36
+ \t<key>ProgramArguments</key>
37
+ \t<array>
38
+ ${items}
39
+ \t</array>
40
+ \t<key>RunAtLoad</key>
41
+ \t<true/>
42
+ \t<key>ProcessType</key>
43
+ \t<string>Interactive</string>
44
+ </dict>
45
+ </plist>
46
+ `;
47
+ }
48
+
49
+ // a .desktop Exec line: quote every argument, escape what the spec says to
50
+ const execLine = argv => argv.map(a => '"' + String(a).replace(/(["`$\\])/g, '\\$1') + '"').join(' ');
51
+
52
+ function desktopEntry(command, args, extra = '') {
53
+ return `[Desktop Entry]
54
+ Type=Application
55
+ Name=Desky Agent
56
+ Comment=Desky shows what Claude Code is doing
57
+ Exec=${execLine([command, ...args])}
58
+ Icon=${path.join(paths.HOME, 'clawd.png')}
59
+ Terminal=false
60
+ Categories=Utility;
61
+ ${extra}`;
62
+ }
63
+
64
+ function winQuote(a) {
65
+ return /[\s"]/.test(a) ? '"' + a.replace(/"/g, '\\"') + '"' : a;
66
+ }
67
+
68
+ function enable() {
69
+ const { command, args = [] } = launchInfo();
70
+ const argv = [...args, '--login'];
71
+ if (process.platform === 'win32') {
72
+ const value = [command, ...argv].map(winQuote).join(' ');
73
+ spawnSync('reg', ['delete', RUN_KEY, '/v', OLD_RUN_NAME, '/f'], { windowsHide: true, stdio: 'ignore' });
74
+ spawnSync('reg', ['add', RUN_KEY, '/v', RUN_NAME, '/t', 'REG_SZ', '/d', value, '/f'], { windowsHide: true });
75
+ } else if (process.platform === 'darwin') {
76
+ fs.mkdirSync(agents(), { recursive: true });
77
+ fs.writeFileSync(PLIST(), plist(command, argv));
78
+ } else {
79
+ fs.mkdirSync(path.dirname(DESKTOP()), { recursive: true });
80
+ fs.writeFileSync(DESKTOP(), desktopEntry(command, argv, 'X-GNOME-Autostart-enabled=true\n'));
81
+ }
82
+ }
83
+
84
+ function disable() {
85
+ if (process.platform === 'win32') {
86
+ for (const v of [RUN_NAME, OLD_RUN_NAME]) spawnSync('reg', ['delete', RUN_KEY, '/v', v, '/f'], { windowsHide: true, stdio: 'ignore' });
87
+ } else if (process.platform === 'darwin') {
88
+ fs.rmSync(PLIST(), { force: true });
89
+ } else {
90
+ fs.rmSync(DESKTOP(), { force: true });
91
+ }
92
+ }
93
+
94
+ function isEnabled() {
95
+ if (process.platform === 'win32') {
96
+ return spawnSync('reg', ['query', RUN_KEY, '/v', RUN_NAME], { windowsHide: true, stdio: 'ignore' }).status === 0;
97
+ }
98
+ return fs.existsSync(process.platform === 'darwin' ? PLIST() : DESKTOP());
99
+ }
100
+
101
+ // the tray asks every second; the registry or the disk once is enough until the checkbox changes it
102
+ let cached = null;
103
+ const isEnabledCached = () => (cached === null ? (cached = isEnabled()) : cached);
104
+ const forget = () => { cached = null; };
105
+
106
+ module.exports = { enable, disable, isEnabled, isEnabledCached, forget, plist, desktopEntry, execLine, LABEL, OLD_LABEL, RUN_KEY };
package/src/board.js CHANGED
@@ -1,69 +1,69 @@
1
- 'use strict';
2
- // The board's "who" answer and what to do about its firmware: docs/firmware_contract.md, sections 2 and 3.
3
- // Pure functions, no port: the link, the status, doctor and the firmware updater all use them.
4
-
5
- const PKG_VERSION = require('../package.json').version;
6
- const PROTO = 3; // the command set this package speaks
7
-
8
- /** "clawd-desk 3 fw=0.2.0 chip=esp32s3 sn=CD-0007" -> { proto, fw, chip, sn }; null when the line is not Desky's.
9
- * Protocol 2 boards say only "clawd-desk 2": fw, chip and sn come back null. Unknown fields are kept, order is free. */
10
- function parseWho(line) {
11
- const parts = String(line || '').trim().split(/\s+/);
12
- if (parts[0] !== 'clawd-desk') return null;
13
- const proto = Number.parseInt(parts[1], 10);
14
- const info = { proto: Number.isFinite(proto) ? proto : null, fw: null, chip: null, sn: null };
15
- for (const p of parts.slice(2)) {
16
- const eq = p.indexOf('=');
17
- if (eq > 0) info[p.slice(0, eq)] = p.slice(eq + 1);
18
- }
19
- if (info.sn === '-') info.sn = null;
20
- return info;
21
- }
22
-
23
- /** semver order, prerelease below its release; -1, 0, 1. Not semver -> null. */
24
- function compareVersions(a, b) {
25
- const re = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+.*)?$/;
26
- const ma = re.exec(String(a || ''));
27
- const mb = re.exec(String(b || ''));
28
- if (!ma || !mb) return null;
29
- for (let i = 1; i <= 3; i++) {
30
- const d = Number(ma[i]) - Number(mb[i]);
31
- if (d) return d < 0 ? -1 : 1;
32
- }
33
- const pa = ma[4];
34
- const pb = mb[4];
35
- if (pa === pb) return 0;
36
- if (!pa) return 1;
37
- if (!pb) return -1;
38
- const xa = pa.split('.');
39
- const xb = pb.split('.');
40
- for (let i = 0; i < Math.max(xa.length, xb.length); i++) {
41
- if (xa[i] === undefined) return -1;
42
- if (xb[i] === undefined) return 1;
43
- const na = /^\d+$/.test(xa[i]);
44
- const nb = /^\d+$/.test(xb[i]);
45
- if (na && nb && Number(xa[i]) !== Number(xb[i])) return Number(xa[i]) < Number(xb[i]) ? -1 : 1;
46
- if (na !== nb) return na ? -1 : 1;
47
- if (xa[i] !== xb[i]) return xa[i] < xb[i] ? -1 : 1;
48
- }
49
- return 0;
50
- }
51
-
52
- /** The contract's table (section 3). bundled: the firmware version this package carries.
53
- * -> { action: 'ok' | 'update' | 'newer' | 'upgrade-package' | 'mismatch', why } */
54
- function verdict(info, bundled = PKG_VERSION, proto = PROTO) {
55
- if (!info) return { action: 'mismatch', why: 'плата не відповіла як Desky' };
56
- if (!info.fw) return { action: 'update', why: 'на платі прошивка без версії (протокол ' + info.proto + ')' };
57
- const c = compareVersions(info.fw, bundled);
58
- if (c === null) return { action: 'mismatch', why: 'незрозуміла версія прошивки: ' + info.fw };
59
- if (c < 0) return { action: 'update', why: `прошивка ${info.fw} старша за ${bundled}` };
60
- if (c > 0) {
61
- return info.proto === proto
62
- ? { action: 'newer', why: `прошивка ${info.fw} новіша за пакет ${bundled}, працює` }
63
- : { action: 'upgrade-package', why: `прошивка ${info.fw} новіша за пакет ${bundled}: npx desky-agent@latest` };
64
- }
65
- if (info.proto !== proto) return { action: 'mismatch', why: `та сама версія ${bundled}, але протокол ${info.proto}, а не ${proto}` };
66
- return { action: 'ok', why: 'прошивка ' + info.fw };
67
- }
68
-
69
- module.exports = { parseWho, compareVersions, verdict, PROTO, PKG_VERSION };
1
+ 'use strict';
2
+ // The board's "who" answer and what to do about its firmware: docs/firmware_contract.md, sections 2 and 3.
3
+ // Pure functions, no port: the link, the status, doctor and the firmware updater all use them.
4
+
5
+ const PKG_VERSION = require('../package.json').version;
6
+ const PROTO = 3; // the command set this package speaks
7
+
8
+ /** "clawd-desk 3 fw=0.2.0 chip=esp32s3 sn=CD-0007" -> { proto, fw, chip, sn }; null when the line is not Desky's.
9
+ * Protocol 2 boards say only "clawd-desk 2": fw, chip and sn come back null. Unknown fields are kept, order is free. */
10
+ function parseWho(line) {
11
+ const parts = String(line || '').trim().split(/\s+/);
12
+ if (parts[0] !== 'clawd-desk') return null;
13
+ const proto = Number.parseInt(parts[1], 10);
14
+ const info = { proto: Number.isFinite(proto) ? proto : null, fw: null, chip: null, sn: null };
15
+ for (const p of parts.slice(2)) {
16
+ const eq = p.indexOf('=');
17
+ if (eq > 0) info[p.slice(0, eq)] = p.slice(eq + 1);
18
+ }
19
+ if (info.sn === '-') info.sn = null;
20
+ return info;
21
+ }
22
+
23
+ /** semver order, prerelease below its release; -1, 0, 1. Not semver -> null. */
24
+ function compareVersions(a, b) {
25
+ const re = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+.*)?$/;
26
+ const ma = re.exec(String(a || ''));
27
+ const mb = re.exec(String(b || ''));
28
+ if (!ma || !mb) return null;
29
+ for (let i = 1; i <= 3; i++) {
30
+ const d = Number(ma[i]) - Number(mb[i]);
31
+ if (d) return d < 0 ? -1 : 1;
32
+ }
33
+ const pa = ma[4];
34
+ const pb = mb[4];
35
+ if (pa === pb) return 0;
36
+ if (!pa) return 1;
37
+ if (!pb) return -1;
38
+ const xa = pa.split('.');
39
+ const xb = pb.split('.');
40
+ for (let i = 0; i < Math.max(xa.length, xb.length); i++) {
41
+ if (xa[i] === undefined) return -1;
42
+ if (xb[i] === undefined) return 1;
43
+ const na = /^\d+$/.test(xa[i]);
44
+ const nb = /^\d+$/.test(xb[i]);
45
+ if (na && nb && Number(xa[i]) !== Number(xb[i])) return Number(xa[i]) < Number(xb[i]) ? -1 : 1;
46
+ if (na !== nb) return na ? -1 : 1;
47
+ if (xa[i] !== xb[i]) return xa[i] < xb[i] ? -1 : 1;
48
+ }
49
+ return 0;
50
+ }
51
+
52
+ /** The contract's table (section 3). bundled: the firmware version this package carries.
53
+ * -> { action: 'ok' | 'update' | 'newer' | 'upgrade-package' | 'mismatch', why } */
54
+ function verdict(info, bundled = PKG_VERSION, proto = PROTO) {
55
+ if (!info) return { action: 'mismatch', why: 'плата не відповіла як Desky' };
56
+ if (!info.fw) return { action: 'update', why: 'на платі прошивка без версії (протокол ' + info.proto + ')' };
57
+ const c = compareVersions(info.fw, bundled);
58
+ if (c === null) return { action: 'mismatch', why: 'незрозуміла версія прошивки: ' + info.fw };
59
+ if (c < 0) return { action: 'update', why: `прошивка ${info.fw} старша за ${bundled}` };
60
+ if (c > 0) {
61
+ return info.proto === proto
62
+ ? { action: 'newer', why: `прошивка ${info.fw} новіша за пакет ${bundled}, працює` }
63
+ : { action: 'upgrade-package', why: `прошивка ${info.fw} новіша за пакет ${bundled}: npx desky-agent@latest` };
64
+ }
65
+ if (info.proto !== proto) return { action: 'mismatch', why: `та сама версія ${bundled}, але протокол ${info.proto}, а не ${proto}` };
66
+ return { action: 'ok', why: 'прошивка ' + info.fw };
67
+ }
68
+
69
+ module.exports = { parseWho, compareVersions, verdict, PROTO, PKG_VERSION };