desky-agent 0.3.2 → 0.3.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.
Binary file
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clawd-desk",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
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": 339200,
30
- "sha256": "55a4c95fbce83460f9ca5e80ae1deef92846a32b46a38b072c0bb1f6dbf542ea"
30
+ "sha256": "598356e15112da0a3088f6bd1b2201c00cfa03ffdd89aab97e9b85de17697b0b"
31
31
  }
32
32
  ]
33
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "desky-agent",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
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
5
  "keywords": [
6
6
  "claude-code",
package/ui/app.html CHANGED
@@ -656,6 +656,28 @@ svg.alive .eye { transform-box: fill-box; transform-origin: center; animation: b
656
656
 
657
657
  // ---------------------------------------------------------------- talking to the daemon
658
658
  let up = false, connected = false, manual = false, beat = null;
659
+ // "on" powers the servos one by one, 400 ms each (play.cpp attachAll), and the board reads nothing meanwhile: a move
660
+ // sent behind it waits, and the "home" that ends a demo is already queued and cuts that move off at once. So "on"
661
+ // goes only when the servos are let go (the heartbeat says so), and the next command waits until the board is back.
662
+ // a move the wizard waits for: any line that reaches the board mid-move stops that move (play.cpp pollStop), so a
663
+ // demo's "home", then its move, then "home" again only work one after another. Done on the board's "ok <cmd>",
664
+ // refused on "Нельзя"/"err", and 4 s at most whatever happens (an old firmware, a lost line).
665
+ const waiters = [];
666
+ function move(cmd, ms = 4000) {
667
+ const word = cmd.trim().split(/\s+/)[0].toLowerCase();
668
+ return new Promise(resolve => {
669
+ const w = { word };
670
+ w.done = ok => { clearTimeout(w.t); const i = waiters.indexOf(w); if (i >= 0) waiters.splice(i, 1); resolve(ok); };
671
+ w.t = setTimeout(() => w.done(false), ms);
672
+ waiters.push(w);
673
+ send(cmd);
674
+ });
675
+ }
676
+ let onUntil = 0; // until then the board is still busy with the last "on" (any page sends it)
677
+ async function servosOn() {
678
+ if (!beat || /отпущены/.test(beat)) await send('on');
679
+ await wait(Math.max(0, onUntil - Date.now()));
680
+ }
659
681
  async function api(path, body) {
660
682
  const r = await fetch(path, body === undefined ? {} : { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });
661
683
  if (!r.ok) throw new Error((await r.json().catch(() => ({}))).error || r.status);
@@ -676,6 +698,7 @@ svg.alive .eye { transform-box: fill-box; transform-origin: center; animation: b
676
698
  const FACTORY = ['trim', 'inv', 'here', 'save', 'swap', 'flip', 'probe', 'hold', 'yawhold', 'sn', 'calset', 'face'];
677
699
  async function send(cmd, quiet) {
678
700
  if (FACTORY.includes(cmd.trim().split(/\s+/)[0].toLowerCase())) await api('/cmd', { line: 'factory on', hand: false }).catch(() => {});
701
+ if (cmd === 'on') onUntil = Date.now() + 1800;
679
702
  if (!quiet) { lastHand = Date.now(); manual = true; showMode(); if (!/^trim /.test(cmd)) atRef = null; }
680
703
  try { await api('/cmd', { line: cmd, hand: !quiet }); } catch (e) { log('не надіслано: ' + e.message, 'dim'); }
681
704
  }
@@ -942,6 +965,9 @@ svg.alive .eye { transform-box: fill-box; transform-origin: center; animation: b
942
965
  let SWAP = null, FLIP = null;
943
966
  const touched = [0, 0, 0, 0]; // when this window last moved a joint's trim: ignore echoes then
944
967
  function onLine(line) {
968
+ const ok = line.match(/^ok (\S+)/);
969
+ if (ok) { const w = waiters.find(x => x.word === ok[1]); if (w) w.done(true); }
970
+ else if (/^(Нельзя|err )/.test(line) && waiters.length) waiters[0].done(false);
945
971
  if (/^Серво отпущены/i.test(line)) $('limpbox').hidden = false;
946
972
  if (/^Нельзя:/.test(line)) toast('Desky так не стане: зачепить стіл або ноутбук', true);
947
973
  let m = line.match(/поза: J1 ([+-]?\d+)\s+J2 ([+-]?\d+)\s+J3 (-?\d+)\s+J4 (-?\d+)/);
@@ -1378,7 +1404,7 @@ svg.alive .eye { transform-box: fill-box; transform-origin: center; animation: b
1378
1404
  foot: [back('color'), spacer(), fix, ok],
1379
1405
  });
1380
1406
  $('wizBody').querySelector('.slot .row').appendChild(replay);
1381
- async function demo() { C3 && C3.state('wave', true); await send('on'); await send('home'); await send('wave'); await wait(3500); await send('home'); }
1407
+ async function demo() { C3 && C3.state('wave', true); await servosOn(); await move('home'); await move('wave', 8000); await move('home'); }
1382
1408
  busy(replay, demo);
1383
1409
  }
1384
1410
 
@@ -1403,7 +1429,7 @@ svg.alive .eye { transform-box: fill-box; transform-origin: center; animation: b
1403
1429
  foot: [back('check'), spacer(), btn('Пропустити крок', 'ghost', () => go('screen'))],
1404
1430
  });
1405
1431
  const ch = $('wizBody').querySelector('.choices'); ch.append(ca, cb);
1406
- async function show() { await send('on'); await send('home'); await send('j1 10'); await wait(1600); await send('home'); }
1432
+ async function show() { await servosOn(); await move('home'); await move('j1 10'); await wait(1200); await move('home'); }
1407
1433
  async function answer(ok) {
1408
1434
  if (ok) { go('screen'); return; }
1409
1435
  if (W.retried) { note.hidden = false; note.className = 'note bad';
@@ -1456,7 +1482,7 @@ svg.alive .eye { transform-box: fill-box; transform-origin: center; animation: b
1456
1482
  foot: [back(j === 0 ? 'screen' : 'j' + (j - 1)), spacer(), btn('Пропустити суглоб', 'ghost', () => go(j < 3 ? 'j' + (j + 1) : 'done'))],
1457
1483
  });
1458
1484
  $('wizBody').querySelector('.choices').append(yes, no);
1459
- async function show() { await send('on'); await send('home'); await send('j' + jj.n + ' ' + (jj.base + jj.plus)); await wait(1500); await send('home'); }
1485
+ async function show() { await servosOn(); await move('home'); await move('j' + jj.n + ' ' + (jj.base + jj.plus)); await wait(1200); await move('home'); }
1460
1486
  async function answer(ok) {
1461
1487
  if (ok) { await send('home'); go('j' + j, 'centre'); return; }
1462
1488
  if (W.retried) { note.hidden = false; note.className = 'note bad';
@@ -1488,7 +1514,7 @@ svg.alive .eye { transform-box: fill-box; transform-origin: center; animation: b
1488
1514
  foot: [back('j' + j), spacer(), done],
1489
1515
  });
1490
1516
  W.onCal = k => { if (k === j) dial.sync(); };
1491
- (async () => { await send('on'); await toRef(j); await send('cal', true); })();
1517
+ (async () => { await servosOn(); await toRef(j); await send('cal', true); })();
1492
1518
  setTimeout(() => dial.querySelector('input').focus(), 80);
1493
1519
  }
1494
1520