desky-agent 0.0.0-stage → 0.3.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/LICENSE +21 -0
- package/README.md +49 -2
- package/assets/clawd.ico +0 -0
- package/assets/clawd.png +0 -0
- package/bin/cli.js +206 -0
- package/electron/icons.js +79 -0
- package/electron/main.js +219 -0
- package/firmware/boot_app0.bin +0 -0
- package/firmware/bootloader.bin +0 -0
- package/firmware/firmware.bin +0 -0
- package/firmware/manifest.json +33 -0
- package/firmware/partitions.bin +0 -0
- package/package.json +38 -4
- package/src/autostart.js +106 -0
- package/src/board.js +69 -0
- package/src/core.js +172 -0
- package/src/daemon.js +446 -0
- package/src/firmware.js +207 -0
- package/src/flasher.js +113 -0
- package/src/hook.js +86 -0
- package/src/install.js +375 -0
- package/src/link.js +207 -0
- package/src/paths.js +44 -0
- package/src/updater.js +138 -0
- package/src/webserial.js +130 -0
- package/ui/app.html +1470 -0
- package/ui/clawd3d.js +375 -0
- package/ui/models/A04_cap_J2.stl +0 -0
- package/ui/models/A04_cap_J3.stl +0 -0
- package/ui/models/A04_cap_J4.stl +0 -0
- package/ui/models/B0_base.stl +0 -0
- package/ui/models/B1_body.stl +0 -0
- package/ui/models/B2_face_plate.stl +0 -0
- package/ui/models/B3_side_left.stl +0 -0
- package/ui/models/B4_side_right.stl +0 -0
- package/ui/models/C1_column.stl +0 -0
- package/ui/models/C2_column_lid.stl +0 -0
- package/ui/models/D1_desk_frame.stl +0 -0
- package/ui/models/D2_desk_top.stl +0 -0
- package/ui/models/L1_laptop.stl +0 -0
- package/ui/models/P1_mug.stl +0 -0
- package/ui/models/P2_plant.stl +0 -0
- package/ui/models/R1_arm_left.stl +0 -0
- package/ui/models/R2_arm_right.stl +0 -0
- package/ui/models/S1_seat.stl +0 -0
- package/ui/models/S2_spacer.stl +0 -0
- package/ui/vendor/OrbitControls.js +1532 -0
- package/ui/vendor/RoomEnvironment.js +144 -0
- package/ui/vendor/STLLoader.js +410 -0
- package/ui/vendor/three.LICENSE +21 -0
- package/ui/vendor/three.module.min.js +6 -0
package/ui/app.html
ADDED
|
@@ -0,0 +1,1470 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="uk">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title>Desky Agent</title>
|
|
7
|
+
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Crect x='2' y='3' width='12' height='9' fill='%23D9774B'/%3E%3Crect x='5' y='5' width='2' height='3' fill='%23222'/%3E%3Crect x='9' y='5' width='2' height='3' fill='%23222'/%3E%3Crect x='0' y='6' width='2' height='3' fill='%23D9774B'/%3E%3Crect x='14' y='6' width='2' height='3' fill='%23D9774B'/%3E%3Crect x='3' y='12' width='2' height='3' fill='%23D9774B'/%3E%3Crect x='11' y='12' width='2' height='3' fill='%23D9774B'/%3E%3C/svg%3E">
|
|
8
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
9
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
10
|
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Unbounded:wght@500;600&family=Onest:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap">
|
|
11
|
+
<script type="importmap">{ "imports": { "three": "/vendor/three.module.min.js" } }</script>
|
|
12
|
+
<script type="module" src="/clawd3d.js"></script>
|
|
13
|
+
<style>
|
|
14
|
+
/* Desky's control app, served by the agent daemon. Left: Desky's face and state, the pages, the link and Stop.
|
|
15
|
+
Right: the page: overview, moves, calibration, settings, monitor. Over everything: the setup wizard. */
|
|
16
|
+
:root {
|
|
17
|
+
--bg: #F4F2EE; --side: #EDEAE5; --card: #FFFFFF; --sunk: #F6F4F1; --ink: #1F1D1A; --muted: #736E68; --faint: #A7A19A;
|
|
18
|
+
--line: #E6E2DC; --line2: #D6D1CA;
|
|
19
|
+
--clawd: #D9774B; --clawd-hi: #C4643A; --clawd-ink: #FFFFFF; --clawd-soft: #FBEDE5; --clawd-glow: rgba(217, 119, 75, .22);
|
|
20
|
+
--ok: #3C8A55; --ok-soft: #E6F3EA; --bad: #C2462A; --bad-soft: #FBE9E4; --desk: #A39D95;
|
|
21
|
+
--term: #1E1C1A; --termfg: #E6E1DA; --termdim: #8E877F;
|
|
22
|
+
--shadow: 0 1px 2px rgba(40, 30, 20, .05), 0 2px 10px rgba(40, 30, 20, .045);
|
|
23
|
+
--shadow-lg: 0 24px 80px rgba(40, 25, 10, .22), 0 4px 16px rgba(40, 25, 10, .08);
|
|
24
|
+
--r: 14px; --rc: 9px; --h: 36px;
|
|
25
|
+
--f-display: "Unbounded", "Segoe UI", system-ui, sans-serif;
|
|
26
|
+
--f-body: "Onest", "Segoe UI", system-ui, sans-serif;
|
|
27
|
+
--f-mono: "JetBrains Mono", Consolas, monospace;
|
|
28
|
+
}
|
|
29
|
+
@media (prefers-color-scheme: dark) { :root {
|
|
30
|
+
--bg: #151413; --side: #1A1918; --card: #211F1D; --sunk: #1A1917; --ink: #EDEAE5; --muted: #A29C94; --faint: #6F6A64;
|
|
31
|
+
--line: #2D2A27; --line2: #3B3733;
|
|
32
|
+
--clawd: #E3825A; --clawd-hi: #EC9167; --clawd-ink: #1A0F0A; --clawd-soft: #33231B; --clawd-glow: rgba(227, 130, 90, .2);
|
|
33
|
+
--ok: #6BBF86; --ok-soft: #1C2E22; --bad: #E56A4C; --bad-soft: #3A1F18; --desk: #6E6862;
|
|
34
|
+
--term: #100F0E; --shadow: none; --shadow-lg: 0 24px 80px rgba(0, 0, 0, .55); color-scheme: dark } }
|
|
35
|
+
* { box-sizing: border-box; }
|
|
36
|
+
[hidden] { display: none !important; }
|
|
37
|
+
html, body { height: 100%; }
|
|
38
|
+
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--f-body); -webkit-font-smoothing: antialiased; }
|
|
39
|
+
h1, h2, h3, p { margin: 0; }
|
|
40
|
+
.mono { font-family: var(--f-mono); }
|
|
41
|
+
|
|
42
|
+
/* ---------------------------------------------------------------- shell */
|
|
43
|
+
.app { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100%; }
|
|
44
|
+
aside { background: var(--side); border-right: 1px solid var(--line); padding: 20px 16px; display: flex; flex-direction: column; gap: 18px;
|
|
45
|
+
position: sticky; top: 0; height: 100vh; overflow-y: auto; }
|
|
46
|
+
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font: 600 17px var(--f-display); letter-spacing: -.01em; }
|
|
47
|
+
.brand svg { width: 26px; height: 20px; border-radius: 3px; }
|
|
48
|
+
.brand .brand2 { margin-left: -4px; color: var(--clawd); font-weight: 500; }
|
|
49
|
+
.who { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 16px 16px; display: grid; justify-items: center;
|
|
50
|
+
gap: 4px; text-align: center; box-shadow: var(--shadow); }
|
|
51
|
+
.who svg { width: 136px; height: 102px; margin-bottom: 10px; border-radius: 12px; box-shadow: 0 8px 24px var(--clawd-glow); }
|
|
52
|
+
.who .k { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
|
|
53
|
+
.who .s { font: 600 18px var(--f-display); letter-spacing: -.01em; }
|
|
54
|
+
.who .w { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
|
|
55
|
+
nav { display: grid; gap: 2px; }
|
|
56
|
+
nav button, .wizlink { all: unset; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--rc); cursor: pointer;
|
|
57
|
+
color: var(--muted); font-weight: 500; }
|
|
58
|
+
nav button svg, .wizlink svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
|
|
59
|
+
nav button:hover, .wizlink:hover { color: var(--ink); background: rgba(127, 110, 90, .08); }
|
|
60
|
+
nav button[aria-selected="true"] { color: var(--ink); background: var(--card); box-shadow: var(--shadow); }
|
|
61
|
+
nav button[aria-selected="true"] svg { color: var(--clawd); }
|
|
62
|
+
nav button:focus-visible, .wizlink:focus-visible { outline: 2px solid var(--clawd); outline-offset: 1px; }
|
|
63
|
+
.wizlink { color: var(--clawd-hi); border: 1px dashed color-mix(in srgb, var(--clawd) 45%, transparent); justify-content: center; }
|
|
64
|
+
.wizlink:hover { color: var(--clawd-hi); background: var(--clawd-soft); }
|
|
65
|
+
.links { margin-top: auto; display: grid; gap: 0; border-top: 1px solid var(--line); padding-top: 12px; }
|
|
66
|
+
.lk { display: flex; align-items: center; gap: 8px; padding: 5px 8px; font-size: 13px; color: var(--muted); }
|
|
67
|
+
.lk span:last-child { margin-left: auto; color: var(--ink); font-weight: 500; text-align: right; }
|
|
68
|
+
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
|
|
69
|
+
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }
|
|
70
|
+
.dot.bad { background: var(--bad); }
|
|
71
|
+
.dot.warn { background: var(--clawd); }
|
|
72
|
+
|
|
73
|
+
main { padding: 28px 32px 48px; display: grid; gap: 20px; align-content: start; max-width: 1100px; width: 100%; }
|
|
74
|
+
.page { display: grid; gap: 20px; align-content: start; animation: fadein .25s ease; }
|
|
75
|
+
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } }
|
|
76
|
+
.title { display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
|
|
77
|
+
.title h1 { font: 600 23px var(--f-display); letter-spacing: -.015em; }
|
|
78
|
+
.title p { color: var(--muted); margin-top: 4px; }
|
|
79
|
+
|
|
80
|
+
/* ---------------------------------------------------------------- cards and controls */
|
|
81
|
+
.cols { display: grid; gap: 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
|
|
82
|
+
.cols.wide { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
|
|
83
|
+
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px; display: flex;
|
|
84
|
+
flex-direction: column; gap: 16px; min-width: 0; }
|
|
85
|
+
.card > .hd { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 30px; }
|
|
86
|
+
.card h2 { font-size: 15px; font-weight: 600; }
|
|
87
|
+
.card .sub { color: var(--muted); font-size: 13px; margin-top: -10px; }
|
|
88
|
+
.muted { color: var(--muted); }
|
|
89
|
+
.small { font-size: 12.5px; }
|
|
90
|
+
|
|
91
|
+
button { font: 500 13.5px var(--f-body); color: var(--ink); background: var(--card); border: 1px solid var(--line2); border-radius: var(--rc);
|
|
92
|
+
height: var(--h); padding: 0 14px; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, color .12s, box-shadow .12s; }
|
|
93
|
+
button:hover:not(:disabled) { background: var(--sunk); border-color: var(--faint); }
|
|
94
|
+
button:active:not(:disabled) { transform: translateY(1px); }
|
|
95
|
+
button:disabled { opacity: .4; cursor: default; }
|
|
96
|
+
button:focus-visible, input:focus-visible { outline: 2px solid var(--clawd); outline-offset: 2px; }
|
|
97
|
+
button.pri { background: var(--clawd); border-color: var(--clawd); color: var(--clawd-ink); }
|
|
98
|
+
button.pri:hover:not(:disabled) { background: var(--clawd-hi); border-color: var(--clawd-hi); box-shadow: 0 4px 14px var(--clawd-glow); }
|
|
99
|
+
button.ghost { background: none; border-color: transparent; color: var(--muted); }
|
|
100
|
+
button.ghost:hover:not(:disabled) { color: var(--ink); background: var(--sunk); border-color: transparent; }
|
|
101
|
+
button.sm { height: 30px; padding: 0 10px; font-size: 13px; }
|
|
102
|
+
button.lg { height: 44px; padding: 0 22px; font-size: 14.5px; font-weight: 600; border-radius: 11px; }
|
|
103
|
+
button[aria-pressed="true"] { background: var(--clawd-soft); border-color: var(--clawd); }
|
|
104
|
+
button.stop { width: 100%; height: 40px; background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 600; }
|
|
105
|
+
button.stop:hover:not(:disabled) { background: var(--bad); border-color: var(--bad); filter: brightness(1.08); }
|
|
106
|
+
|
|
107
|
+
.btns { display: grid; gap: 8px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
108
|
+
.btns button { width: 100%; padding: 0 6px; }
|
|
109
|
+
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
|
|
110
|
+
.row.end { justify-content: flex-end; }
|
|
111
|
+
|
|
112
|
+
input.num, input.text, .raw input { font: 13.5px var(--f-mono); height: var(--h); padding: 0 10px; border: 1px solid var(--line2); border-radius: var(--rc);
|
|
113
|
+
background: var(--card); color: var(--ink); min-width: 0; }
|
|
114
|
+
input.num { width: 76px; text-align: right; }
|
|
115
|
+
input.num.s { width: 60px; height: 30px; }
|
|
116
|
+
input.text { width: 100%; }
|
|
117
|
+
input[type=checkbox] { accent-color: var(--clawd); width: 15px; height: 15px; margin: 0; }
|
|
118
|
+
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; font-size: 13px; user-select: none; }
|
|
119
|
+
|
|
120
|
+
/* range: one look in Edge and Firefox */
|
|
121
|
+
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: none; margin: 0; cursor: pointer; }
|
|
122
|
+
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px;
|
|
123
|
+
background: linear-gradient(var(--clawd), var(--clawd)) 0 / var(--p, 50%) 100% no-repeat, var(--line); }
|
|
124
|
+
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%;
|
|
125
|
+
background: var(--card); border: 2px solid var(--clawd); box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
|
|
126
|
+
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line); }
|
|
127
|
+
input[type=range]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--clawd); }
|
|
128
|
+
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--card); border: 2px solid var(--clawd); }
|
|
129
|
+
input[type=range]:disabled { opacity: .5; }
|
|
130
|
+
|
|
131
|
+
/* the centre dial: a range that fills from the middle, with a tick at zero */
|
|
132
|
+
.dial { display: grid; gap: 8px; }
|
|
133
|
+
.dial .track { position: relative; }
|
|
134
|
+
.dial .track::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--line2); pointer-events: none; }
|
|
135
|
+
.dial input[type=range] { height: 30px; position: relative; }
|
|
136
|
+
.dial input[type=range]::-webkit-slider-runnable-track { height: 8px; border-radius: 4px;
|
|
137
|
+
background: linear-gradient(90deg, transparent var(--a, 50%), var(--clawd) var(--a, 50%), var(--clawd) var(--b, 50%), transparent var(--b, 50%)), var(--line); }
|
|
138
|
+
.dial input[type=range]::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: -8px; border-width: 3px; }
|
|
139
|
+
.dial input[type=range]::-moz-range-progress { background: transparent; }
|
|
140
|
+
.dial input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-width: 3px; }
|
|
141
|
+
.dial .ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
|
|
142
|
+
.dial .ends b { color: var(--ink); font: 600 15px var(--f-mono); font-variant-numeric: tabular-nums; }
|
|
143
|
+
.dial .fine { display: flex; gap: 6px; align-items: center; justify-content: center; }
|
|
144
|
+
.dial .fine button { min-width: 44px; font-family: var(--f-mono); }
|
|
145
|
+
.dial .fine button[data-z] { font-family: var(--f-body); }
|
|
146
|
+
.dial.warn input[type=range]::-webkit-slider-thumb { border-color: var(--bad); }
|
|
147
|
+
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
|
|
148
|
+
.hint.warn { color: var(--bad); }
|
|
149
|
+
|
|
150
|
+
/* banners */
|
|
151
|
+
.banner { display: flex; align-items: center; gap: 16px; padding: 12px 14px 12px 16px; border-radius: var(--r); background: var(--clawd-soft);
|
|
152
|
+
border: 1px solid color-mix(in srgb, var(--clawd) 35%, transparent); }
|
|
153
|
+
.banner p { flex: 1; }
|
|
154
|
+
.banner b { font-weight: 600; }
|
|
155
|
+
.banner.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
|
|
156
|
+
|
|
157
|
+
/* toast */
|
|
158
|
+
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 60;
|
|
159
|
+
background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 500; font-size: 13.5px;
|
|
160
|
+
box-shadow: var(--shadow-lg); transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); }
|
|
161
|
+
.toast.on { opacity: 1; transform: translate(-50%, 0); }
|
|
162
|
+
.toast.bad { background: var(--bad); color: #fff; }
|
|
163
|
+
|
|
164
|
+
/* ---------------------------------------------------------------- the 3D stage (ui/clawd3d.js) */
|
|
165
|
+
.scene3d { position: relative; min-height: 240px; border-radius: var(--r); overflow: hidden; display: grid; place-items: center;
|
|
166
|
+
background: radial-gradient(70% 60% at 50% 62%, color-mix(in srgb, var(--clawd) 16%, transparent), transparent 70%),
|
|
167
|
+
radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--ink) 9%, transparent) 1px, transparent 1.4px) 0 0 / 18px 18px,
|
|
168
|
+
linear-gradient(180deg, var(--sunk), var(--card)); }
|
|
169
|
+
.scene3d canvas.c3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none;
|
|
170
|
+
animation: c3in .6s ease both; }
|
|
171
|
+
.scene3d canvas.c3d:active { cursor: grabbing; }
|
|
172
|
+
@keyframes c3in { from { opacity: 0; transform: scale(.97); } }
|
|
173
|
+
.scene3d .tip3d { position: absolute; right: 12px; bottom: 10px; font-size: 11.5px; color: var(--faint); pointer-events: none;
|
|
174
|
+
display: none; align-items: center; gap: 6px; }
|
|
175
|
+
.scene3d .tip3d svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; }
|
|
176
|
+
body.has3d .scene3d .tip3d { display: flex; }
|
|
177
|
+
body.has3d .scene3d > .flat { display: none; }
|
|
178
|
+
body:not(.has3d) #moveScene { display: none; }
|
|
179
|
+
body.has3d .sketches { display: none; }
|
|
180
|
+
#moveScene { height: 300px; }
|
|
181
|
+
|
|
182
|
+
/* ---------------------------------------------------------------- overview */
|
|
183
|
+
.herocard { padding: 0; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); overflow: hidden; gap: 0; }
|
|
184
|
+
.herocard .scene3d { min-height: 340px; border-radius: 0; }
|
|
185
|
+
.herocard .scene3d > .flat { width: 200px; height: 150px; border-radius: 18px; box-shadow: 0 16px 40px var(--clawd-glow); }
|
|
186
|
+
.herocard .info { padding: 28px 28px 24px; display: flex; flex-direction: column; gap: 6px; border-left: 1px solid var(--line); }
|
|
187
|
+
.herocard .k { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
|
|
188
|
+
.herocard .s { font: 600 30px/1.15 var(--f-display); letter-spacing: -.025em; }
|
|
189
|
+
.herocard .w { color: var(--muted); font-size: 14.5px; }
|
|
190
|
+
.herocard .live { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; margin-bottom: 10px; padding: 4px 10px 4px 8px;
|
|
191
|
+
border-radius: 999px; background: var(--clawd-soft); color: var(--clawd-hi); font-size: 12px; font-weight: 600; }
|
|
192
|
+
.herocard .live i { width: 7px; height: 7px; border-radius: 50%; background: var(--clawd); animation: pulse 1.4s ease-in-out infinite; }
|
|
193
|
+
.herocard .mini { margin-top: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-top: 18px; }
|
|
194
|
+
.herocard .mini div { padding: 10px 12px; border-radius: 10px; background: var(--sunk); border: 1px solid var(--line); }
|
|
195
|
+
.herocard .mini small { display: block; font-size: 11.5px; color: var(--muted); }
|
|
196
|
+
.herocard .mini b { font-weight: 600; }
|
|
197
|
+
.list { display: grid; border: 1px solid var(--line); border-radius: var(--rc); overflow: hidden; }
|
|
198
|
+
.li { display: flex; align-items: center; gap: 12px; padding: 0 14px; height: 44px; border-top: 1px solid var(--line); }
|
|
199
|
+
.li:first-child { border-top: 0; }
|
|
200
|
+
.li .mono { color: var(--muted); font-size: 12.5px; }
|
|
201
|
+
.badge { margin-left: auto; font-size: 12.5px; font-weight: 500; padding: 2px 10px; border-radius: 999px; background: var(--sunk); border: 1px solid var(--line); }
|
|
202
|
+
.badge.ask { background: var(--clawd-soft); border-color: transparent; color: var(--clawd-hi); }
|
|
203
|
+
.empty { display: grid; place-items: center; text-align: center; gap: 4px; padding: 24px 16px; border: 1px dashed var(--line2); border-radius: var(--rc); color: var(--muted); }
|
|
204
|
+
.empty b { color: var(--ink); font-weight: 500; }
|
|
205
|
+
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: var(--rc); }
|
|
206
|
+
.fact { padding: 12px 14px; border-left: 1px solid var(--line); }
|
|
207
|
+
.fact:first-child { border-left: 0; }
|
|
208
|
+
.fact .k { font-size: 12px; color: var(--muted); }
|
|
209
|
+
.fact .v { font-weight: 600; margin-top: 2px; }
|
|
210
|
+
|
|
211
|
+
/* ---------------------------------------------------------------- moves */
|
|
212
|
+
.fader { display: grid; grid-template-columns: 128px minmax(0, 1fr) 52px; gap: 16px; align-items: center; }
|
|
213
|
+
.fader label { font-weight: 500; line-height: 1.3; }
|
|
214
|
+
.fader label small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
|
|
215
|
+
.fader output { font: 500 13.5px var(--f-mono); text-align: right; font-variant-numeric: tabular-nums; }
|
|
216
|
+
.sketches { display: grid; grid-template-columns: 3fr 2fr; gap: 12px; }
|
|
217
|
+
.sketches figure, .fig { margin: 0; background: var(--sunk); border: 1px solid var(--line); border-radius: var(--rc); padding: 8px 8px 6px; }
|
|
218
|
+
.sketches svg, .fig svg { width: 100%; height: auto; display: block; }
|
|
219
|
+
.sketches figcaption, .fig figcaption { font-size: 12px; color: var(--muted); text-align: center; }
|
|
220
|
+
.sep { height: 1px; background: var(--line); margin: 0 -20px; }
|
|
221
|
+
.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
|
222
|
+
.opt small { display: block; color: var(--muted); font-size: 12.5px; }
|
|
223
|
+
|
|
224
|
+
/* ---------------------------------------------------------------- calibration */
|
|
225
|
+
.calhero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center;
|
|
226
|
+
background: linear-gradient(120deg, var(--clawd-soft), var(--card) 70%); }
|
|
227
|
+
.calhero h2 { font: 600 17px var(--f-display); letter-spacing: -.01em; }
|
|
228
|
+
.calhero p { color: var(--muted); margin-top: 4px; max-width: 560px; }
|
|
229
|
+
.joints { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
|
|
230
|
+
.joint .hd small { display: block; color: var(--muted); font: 12px var(--f-mono); }
|
|
231
|
+
.joint .pic { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
|
|
232
|
+
.joint .fig svg { height: 112px; }
|
|
233
|
+
.joint .dir { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line); }
|
|
234
|
+
.joint .dir span { margin-right: auto; font-size: 13px; color: var(--muted); }
|
|
235
|
+
.joint .dir span b { color: var(--ink); font-weight: 500; }
|
|
236
|
+
.tog { display: grid; gap: 0; }
|
|
237
|
+
.tog .field { padding: 12px 0; }
|
|
238
|
+
.savebar { position: sticky; bottom: 16px; display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 20px; background: var(--card);
|
|
239
|
+
border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 6px 24px rgba(40, 30, 20, .08); }
|
|
240
|
+
.savebar p { margin-right: auto; color: var(--muted); font-size: 13px; }
|
|
241
|
+
.savebar p.ok { color: var(--ok); }
|
|
242
|
+
.savebar p.bad { color: var(--bad); }
|
|
243
|
+
.savebar.dirty { border-color: var(--clawd); box-shadow: 0 6px 24px var(--clawd-glow); }
|
|
244
|
+
.savebar.dirty p { color: var(--clawd-hi); font-weight: 500; }
|
|
245
|
+
|
|
246
|
+
/* ---------------------------------------------------------------- Desky's colour */
|
|
247
|
+
.swatches { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
|
|
248
|
+
.swatch { height: auto; padding: 12px 6px 10px; display: grid; justify-items: center; gap: 8px; border-radius: 14px; white-space: normal;
|
|
249
|
+
line-height: 1.2; font-size: 13px; }
|
|
250
|
+
.swatch .chip { width: 52px; height: 39px; border-radius: 8px; background: var(--c); position: relative;
|
|
251
|
+
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1), 0 6px 16px color-mix(in srgb, var(--c) 35%, transparent);
|
|
252
|
+
transition: transform .2s cubic-bezier(.2, .8, .2, 1); }
|
|
253
|
+
.swatch .chip::before, .swatch .chip::after { content: ""; position: absolute; top: 12px; width: 7px; height: 14px; background: var(--e); }
|
|
254
|
+
.swatch .chip::before { left: 11px; }
|
|
255
|
+
.swatch .chip::after { right: 11px; }
|
|
256
|
+
.swatch:hover:not(:disabled) .chip { transform: translateY(-2px) rotate(-3deg); }
|
|
257
|
+
.swatch[aria-checked="true"] { border-color: var(--clawd); background: var(--clawd-soft); box-shadow: 0 0 0 3px var(--clawd-glow); }
|
|
258
|
+
.swatch[aria-checked="true"] .chip { transform: scale(1.06); }
|
|
259
|
+
.swatch small { display: block; color: var(--muted); font-size: 11.5px; }
|
|
260
|
+
.colorcard .hint { margin-top: -6px; }
|
|
261
|
+
.wiz .swatches { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
262
|
+
|
|
263
|
+
/* ---------------------------------------------------------------- settings */
|
|
264
|
+
.set { display: grid; }
|
|
265
|
+
.field { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
|
|
266
|
+
.field:first-child { border-top: 0; padding-top: 0; }
|
|
267
|
+
.field:last-child { padding-bottom: 0; }
|
|
268
|
+
.field label { font-weight: 500; }
|
|
269
|
+
.field label small { display: block; color: var(--muted); font-size: 12.5px; font-weight: 400; }
|
|
270
|
+
.field .in { display: flex; align-items: center; gap: 8px; }
|
|
271
|
+
.field .unit { font-size: 12.5px; color: var(--muted); width: 84px; }
|
|
272
|
+
.field.col { grid-template-columns: 1fr; gap: 8px; }
|
|
273
|
+
|
|
274
|
+
/* ---------------------------------------------------------------- monitor */
|
|
275
|
+
.term { background: var(--term); border-radius: var(--r); overflow: hidden; display: grid; grid-template-rows: auto 1fr auto; height: calc(100vh - 190px); min-height: 360px; }
|
|
276
|
+
.term .bar { display: flex; align-items: center; gap: 16px; padding: 10px 14px; border-bottom: 1px solid rgba(255, 255, 255, .07); color: var(--termdim); font-size: 12.5px; }
|
|
277
|
+
.term .bar .check { color: var(--termdim); }
|
|
278
|
+
.term .bar button { margin-left: auto; color: var(--termdim); }
|
|
279
|
+
.term .bar button:hover:not(:disabled) { background: rgba(255, 255, 255, .06); color: var(--termfg); }
|
|
280
|
+
.legend { display: flex; gap: 14px; }
|
|
281
|
+
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
|
|
282
|
+
.log { padding: 12px 14px; font: 12.5px/1.6 var(--f-mono); color: var(--termfg); overflow: auto; white-space: pre-wrap; }
|
|
283
|
+
.log .me { color: #F2B48F; }
|
|
284
|
+
.log .agent { color: #9FC6F0; }
|
|
285
|
+
.log .info, .log .dim { color: var(--termdim); }
|
|
286
|
+
.raw { display: flex; gap: 8px; padding: 10px; border-top: 1px solid rgba(255, 255, 255, .07); }
|
|
287
|
+
.raw input { flex: 1; background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .1); color: var(--termfg); }
|
|
288
|
+
.raw input::placeholder { color: var(--termdim); }
|
|
289
|
+
.raw button { background: rgba(255, 255, 255, .08); border-color: transparent; color: var(--termfg); }
|
|
290
|
+
.raw button:hover:not(:disabled) { background: rgba(255, 255, 255, .14); border-color: transparent; }
|
|
291
|
+
|
|
292
|
+
/* ---------------------------------------------------------------- the face: blinks while alive */
|
|
293
|
+
svg.alive .eye { transform-box: fill-box; transform-origin: center; animation: blink 5.2s infinite; }
|
|
294
|
+
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 95.5% { transform: scaleY(.1); } }
|
|
295
|
+
@media (prefers-reduced-motion: reduce) { svg.alive .eye { animation: none; } .page, .wiz .step { animation: none !important; } }
|
|
296
|
+
|
|
297
|
+
/* ---------------------------------------------------------------- setup wizard */
|
|
298
|
+
.wiz { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px;
|
|
299
|
+
background: color-mix(in srgb, var(--bg) 88%, transparent); }
|
|
300
|
+
.wiz .panel { width: min(960px, 100%); max-height: calc(100vh - 48px); background: var(--card); border: 1px solid var(--line); border-radius: 22px;
|
|
301
|
+
box-shadow: var(--shadow-lg); display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; }
|
|
302
|
+
.wiz .top { display: flex; align-items: center; gap: 16px; padding: 16px 18px 14px 24px; border-bottom: 1px solid var(--line); }
|
|
303
|
+
.wiz .top .brand { padding: 0; font-size: 15px; }
|
|
304
|
+
.prog { flex: 1; display: grid; gap: 6px; }
|
|
305
|
+
.prog .bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; }
|
|
306
|
+
.prog .bars i { height: 4px; border-radius: 2px; background: var(--line); transition: background .3s; }
|
|
307
|
+
.prog .bars i.done { background: var(--clawd); }
|
|
308
|
+
.prog .bars i.now { background: linear-gradient(90deg, var(--clawd) 50%, var(--line) 50%); }
|
|
309
|
+
.prog .lbl { font-size: 12px; color: var(--muted); }
|
|
310
|
+
.prog .lbl b { color: var(--ink); font-weight: 500; }
|
|
311
|
+
.wiz .x { width: 34px; height: 34px; padding: 0; display: grid; place-items: center; border-radius: 50%; }
|
|
312
|
+
.wiz .x svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; }
|
|
313
|
+
.wiz .body { overflow-y: auto; overflow-x: hidden; }
|
|
314
|
+
.wiz .step { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 460px; animation: stepin .35s cubic-bezier(.2, .8, .2, 1); }
|
|
315
|
+
@keyframes stepin { from { opacity: 0; transform: translateX(14px); } }
|
|
316
|
+
.wiz .stage { background: radial-gradient(120% 90% at 50% 40%, var(--clawd-soft), var(--sunk) 70%); border-right: 1px solid var(--line);
|
|
317
|
+
display: grid; place-items: center; padding: 28px; gap: 12px; align-content: center; }
|
|
318
|
+
.wiz .stage .views { display: grid; gap: 12px; width: 100%; max-width: 380px; }
|
|
319
|
+
.wiz .stage .views.two { grid-template-columns: 1fr 1fr; max-width: 440px; }
|
|
320
|
+
.wiz .stage .views:not(.two) { max-width: 280px; }
|
|
321
|
+
.wiz .stage .fig { background: var(--card); }
|
|
322
|
+
.wiz .stage .big { width: min(300px, 80%); height: auto; border-radius: 22px; box-shadow: 0 20px 50px var(--clawd-glow); }
|
|
323
|
+
.wiz .stage .cap { font-size: 12.5px; color: var(--muted); text-align: center; }
|
|
324
|
+
.wiz .stage.s3 { padding: 0; display: block; position: relative; }
|
|
325
|
+
.wiz .stage.s3 .scene3d { position: absolute; inset: 0; border-radius: 0; background: radial-gradient(70% 60% at 50% 60%, color-mix(in srgb, var(--clawd) 20%, transparent), transparent 70%), radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--ink) 9%, transparent) 1px, transparent 1.4px) 0 0 / 18px 18px, var(--sunk); }
|
|
326
|
+
.wiz .stage.s3 .cap3 { position: absolute; left: 16px; top: 14px; z-index: 1; padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 600;
|
|
327
|
+
background: color-mix(in srgb, var(--card) 85%, transparent); border: 1px solid var(--line); color: var(--ink); }
|
|
328
|
+
.wiz .stage.s3 .cap3 i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--clawd); margin-right: 7px; animation: pulse 1.4s ease-in-out infinite; }
|
|
329
|
+
.wiz .content { padding: 32px 32px 24px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
|
|
330
|
+
.wiz .kick { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--clawd-hi); font-weight: 600; }
|
|
331
|
+
.wiz h2 { font: 600 24px/1.2 var(--f-display); letter-spacing: -.02em; }
|
|
332
|
+
.wiz .lead { color: var(--muted); font-size: 14.5px; line-height: 1.55; }
|
|
333
|
+
.wiz .lead b { color: var(--ink); font-weight: 500; }
|
|
334
|
+
.wiz .foot { margin-top: auto; display: flex; gap: 8px; align-items: center; padding-top: 16px; }
|
|
335
|
+
.wiz .foot .sp { margin-right: auto; }
|
|
336
|
+
.checks { display: grid; gap: 8px; }
|
|
337
|
+
.ck { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--sunk); }
|
|
338
|
+
.ck .ic { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--line); color: var(--muted); }
|
|
339
|
+
.ck .ic svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }
|
|
340
|
+
.ck.ok .ic { background: var(--ok); color: #fff; }
|
|
341
|
+
.ck.wait .ic { background: none; border: 2px solid var(--line2); border-top-color: var(--clawd); animation: spin 1s linear infinite; }
|
|
342
|
+
.ck.bad .ic { background: var(--bad); color: #fff; }
|
|
343
|
+
@keyframes spin { to { transform: rotate(360deg); } }
|
|
344
|
+
.ck div { flex: 1; min-width: 0; }
|
|
345
|
+
.ck b { display: block; font-weight: 500; }
|
|
346
|
+
.ck small { color: var(--muted); font-size: 12.5px; }
|
|
347
|
+
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
|
|
348
|
+
.choice { height: auto; padding: 14px 12px 12px; display: grid; justify-items: center; gap: 8px; border-radius: 14px; white-space: normal; text-align: center; line-height: 1.3; }
|
|
349
|
+
.choice svg { width: 100%; max-width: 150px; height: auto; border-radius: 8px; background: var(--sunk); }
|
|
350
|
+
.choice:hover:not(:disabled) { border-color: var(--clawd); background: var(--clawd-soft); }
|
|
351
|
+
.choice.yes { border-color: color-mix(in srgb, var(--ok) 50%, var(--line2)); }
|
|
352
|
+
.choice.yes:hover:not(:disabled) { border-color: var(--ok); background: var(--ok-soft); }
|
|
353
|
+
.note { padding: 10px 14px; border-radius: 12px; background: var(--clawd-soft); color: var(--clawd-hi); font-size: 13px; font-weight: 500; }
|
|
354
|
+
.note.bad { background: var(--bad-soft); color: var(--bad); }
|
|
355
|
+
.note.ok { background: var(--ok-soft); color: var(--ok); }
|
|
356
|
+
.watch { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
|
|
357
|
+
.watch .pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--clawd); animation: pulse 1.2s ease-in-out infinite; flex: none; }
|
|
358
|
+
@keyframes pulse { 50% { box-shadow: 0 0 0 7px var(--clawd-glow); } }
|
|
359
|
+
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
|
|
360
|
+
.confetti i { position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px; animation: fall 2.4s ease-in forwards; }
|
|
361
|
+
@keyframes fall { to { transform: translateY(560px) rotate(540deg); opacity: 0; } }
|
|
362
|
+
|
|
363
|
+
/* ---------------------------------------------------------------- narrow windows */
|
|
364
|
+
@media (max-width: 1100px) { .cols.wide { grid-template-columns: 1fr; } .joints { grid-template-columns: 1fr; } }
|
|
365
|
+
@media (max-width: 900px) {
|
|
366
|
+
.app { grid-template-columns: 1fr; }
|
|
367
|
+
aside { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 16px; gap: 14px; }
|
|
368
|
+
.who { grid-template-columns: auto 1fr; justify-items: start; text-align: left; column-gap: 14px; padding: 12px; }
|
|
369
|
+
.who svg { width: 72px; height: 54px; margin: 0; grid-row: 1 / 4; }
|
|
370
|
+
nav { grid-auto-flow: column; justify-content: start; overflow-x: auto; scrollbar-width: none; }
|
|
371
|
+
nav::-webkit-scrollbar { display: none; }
|
|
372
|
+
.links { margin-top: 0; grid-template-columns: 1fr 1fr; column-gap: 16px; }
|
|
373
|
+
main { padding: 20px 16px 40px; }
|
|
374
|
+
.cols { grid-template-columns: 1fr; }
|
|
375
|
+
.wiz { padding: 0; }
|
|
376
|
+
.wiz .panel { max-height: 100vh; height: 100%; border-radius: 0; }
|
|
377
|
+
.wiz .step { grid-template-columns: 1fr; }
|
|
378
|
+
.wiz .stage { border-right: 0; border-bottom: 1px solid var(--line); padding: 20px; }
|
|
379
|
+
.wiz .stage.s3 { height: 300px; }
|
|
380
|
+
.wiz .content { padding: 22px 18px 18px; }
|
|
381
|
+
.herocard { grid-template-columns: 1fr; }
|
|
382
|
+
.herocard .info { border-left: 0; border-top: 1px solid var(--line); }
|
|
383
|
+
}
|
|
384
|
+
@media (max-width: 600px) {
|
|
385
|
+
.btns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
386
|
+
.fader { grid-template-columns: minmax(0, 1fr) 52px; gap: 6px 12px; }
|
|
387
|
+
.fader input { grid-column: 1 / -1; grid-row: 2; }
|
|
388
|
+
.facts { grid-template-columns: 1fr; }
|
|
389
|
+
.fact { border-left: 0; border-top: 1px solid var(--line); }
|
|
390
|
+
.fact:first-child { border-top: 0; }
|
|
391
|
+
.banner { flex-wrap: wrap; }
|
|
392
|
+
.calhero { grid-template-columns: 1fr; }
|
|
393
|
+
.choices { grid-template-columns: 1fr; }
|
|
394
|
+
.swatches { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
395
|
+
.tog .field { grid-template-columns: 1fr; gap: 10px; }
|
|
396
|
+
}
|
|
397
|
+
</style>
|
|
398
|
+
</head>
|
|
399
|
+
<body>
|
|
400
|
+
<div class="app">
|
|
401
|
+
<aside>
|
|
402
|
+
<div class="brand"><svg viewBox="0 0 64 48" aria-hidden="true" id="logo"></svg>Desky<span class="brand2">Agent</span></div>
|
|
403
|
+
<div class="who">
|
|
404
|
+
<svg id="face" class="alive" viewBox="0 0 64 48" aria-hidden="true"></svg>
|
|
405
|
+
<div class="k" id="aKicker">Зараз показує</div>
|
|
406
|
+
<div class="s" id="aState">—</div>
|
|
407
|
+
<div class="w" id="aWhat"></div>
|
|
408
|
+
</div>
|
|
409
|
+
<nav role="tablist">
|
|
410
|
+
<button type="button" role="tab" data-tab="home" aria-selected="true"><svg viewBox="0 0 24 24"><path d="M4 11l8-7 8 7v8.5a.5.5 0 0 1-.5.5H15v-6H9v6H4.5a.5.5 0 0 1-.5-.5z"/></svg>Огляд</button>
|
|
411
|
+
<button type="button" role="tab" data-tab="move"><svg viewBox="0 0 24 24"><path d="M4 7h9M19 7h1M4 17h3M13 17h7"/><circle cx="16" cy="7" r="2.5"/><circle cx="10" cy="17" r="2.5"/></svg>Рухи</button>
|
|
412
|
+
<button type="button" role="tab" data-tab="cal"><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="7.5"/><circle cx="12" cy="12" r="2.5"/><path d="M12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3"/></svg>Калібрування</button>
|
|
413
|
+
<button type="button" role="tab" data-tab="cfg"><svg viewBox="0 0 24 24"><path d="M4 6h16M4 12h16M4 18h16"/><circle cx="9" cy="6" r="1.8" fill="currentColor"/><circle cx="15" cy="12" r="1.8" fill="currentColor"/><circle cx="7" cy="18" r="1.8" fill="currentColor"/></svg>Налаштування</button>
|
|
414
|
+
<button type="button" role="tab" data-tab="mon"><svg viewBox="0 0 24 24"><rect x="3" y="4.5" width="18" height="15" rx="2.5"/><path d="M7.5 9.5l3 2.5-3 2.5M13 15h3.5"/></svg>Монітор</button>
|
|
415
|
+
</nav>
|
|
416
|
+
<button type="button" class="wizlink" id="openWiz"><svg viewBox="0 0 24 24"><path d="M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8z"/><path d="M19 16l.7 2 2 .7-2 .7-.7 2-.7-2-2-.7 2-.7z"/></svg>Майстер налаштування</button>
|
|
417
|
+
<div class="links">
|
|
418
|
+
<div class="lk" title="програма Desky на цьому комп'ютері"><span class="dot" id="dDaemon"></span><span>Програма</span><span id="sDaemon">…</span></div>
|
|
419
|
+
<div class="lk" title="плата Desky через USB"><span class="dot" id="dC3"></span><span>Плата</span><span id="sC3">…</span></div>
|
|
420
|
+
<div class="lk" title="відповідь плати раз на 3 с"><span class="dot" id="dServo"></span><span>Серво</span><span id="health">—</span></div>
|
|
421
|
+
<div class="lk" title="хто зараз керує Desky"><span class="dot" id="dMode"></span><span>Керує</span><span id="sMode">—</span></div>
|
|
422
|
+
</div>
|
|
423
|
+
<button type="button" class="stop" id="stop" title="зупинити будь-який рух">Стоп</button>
|
|
424
|
+
</aside>
|
|
425
|
+
|
|
426
|
+
<main>
|
|
427
|
+
<div class="banner bad" id="downbox" hidden><p><b>Програма Desky не відповідає.</b> Відкрий застосунок Desky ще раз.</p></div>
|
|
428
|
+
<div class="banner bad" id="nocbox" hidden><p><b>Плату не під'єднано.</b> Перевір кабель USB — програма знайде плату сама.</p><button type="button" class="sm" id="reset">Перезапустити плату</button></div>
|
|
429
|
+
<div class="banner" id="manualbox" hidden><p><b>Ручне керування.</b> Агент на паузі. Через хвилину без команд або коли закриєш вікно Desky сам повернеться до агента.</p><button type="button" class="pri sm" id="toAgent">Повернути агенту</button></div>
|
|
430
|
+
<div class="banner" id="limpbox" hidden><p><b>Серво відпущені.</b> Desky обм'як, повзунки й сценки його не рухають.</p><button type="button" class="pri sm" data-cmd="on">Тримати позу</button></div>
|
|
431
|
+
|
|
432
|
+
<!-- ============================================================ overview -->
|
|
433
|
+
<section data-page="home" class="page">
|
|
434
|
+
<div class="title"><div><h1>Огляд</h1><p>Що робить Claude Code і що показує Desky.</p></div></div>
|
|
435
|
+
<div class="card herocard">
|
|
436
|
+
<div class="scene3d" id="homeScene"><svg id="bigface" class="alive flat" viewBox="0 0 64 48" aria-hidden="true"></svg>
|
|
437
|
+
<div class="tip3d"><svg viewBox="0 0 16 16"><path d="M13 8a5 5 0 1 1-1.5-3.5M13 2.5V5h-2.5"/></svg>потягни, щоб покрутити</div></div>
|
|
438
|
+
<div class="info">
|
|
439
|
+
<span class="live"><i></i>наживо</span>
|
|
440
|
+
<div class="k" id="hKicker">Зараз показує</div><div class="s" id="hState">—</div><div class="w" id="hWhat"></div>
|
|
441
|
+
<div class="mini"><div><small>Сесії</small><b id="hSess">—</b></div><div><small>Плата</small><b id="hBoard">—</b></div></div>
|
|
442
|
+
</div>
|
|
443
|
+
</div>
|
|
444
|
+
<div class="card">
|
|
445
|
+
<div class="hd"><h2>Сесії Claude Code</h2><span class="muted small" id="sessCount"></span></div>
|
|
446
|
+
<div id="sessions"></div>
|
|
447
|
+
<div class="facts">
|
|
448
|
+
<div class="fact"><div class="k">Звук</div><div class="v" id="fQuiet">—</div></div>
|
|
449
|
+
<div class="fact"><div class="k">Тихі години</div><div class="v" id="fHours">—</div></div>
|
|
450
|
+
<div class="fact"><div class="k">Плата працює</div><div class="v" id="fUp">—</div></div>
|
|
451
|
+
</div>
|
|
452
|
+
</div>
|
|
453
|
+
<div class="cols">
|
|
454
|
+
<div class="card">
|
|
455
|
+
<div class="hd"><h2>Показати стан</h2></div>
|
|
456
|
+
<p class="sub">Desky зіграє його зараз. Агент стане на паузу.</p>
|
|
457
|
+
<div class="btns" id="statesRow"></div>
|
|
458
|
+
</div>
|
|
459
|
+
<div class="card">
|
|
460
|
+
<div class="hd"><h2>Послухати звук</h2></div>
|
|
461
|
+
<p class="sub">Лише звук, Desky не рухається.</p>
|
|
462
|
+
<div class="btns" id="soundsRow"></div>
|
|
463
|
+
</div>
|
|
464
|
+
</div>
|
|
465
|
+
</section>
|
|
466
|
+
|
|
467
|
+
<!-- ============================================================ moves -->
|
|
468
|
+
<section data-page="move" class="page" hidden>
|
|
469
|
+
<div class="title"><div><h1>Рухи</h1><p>Постав Desky у позу або запусти сценку. Агент стане на паузу.</p></div></div>
|
|
470
|
+
<div class="cols wide">
|
|
471
|
+
<div class="card">
|
|
472
|
+
<div class="hd"><h2>Суглоби</h2><label class="check"><input type="checkbox" id="live" checked> рухати одразу</label></div>
|
|
473
|
+
<div class="scene3d" id="moveScene"><div class="tip3d"><svg viewBox="0 0 16 16"><path d="M13 8a5 5 0 1 1-1.5-3.5M13 2.5V5h-2.5"/></svg>потягни, щоб покрутити</div></div>
|
|
474
|
+
<div class="sketches">
|
|
475
|
+
<figure><svg id="side" viewBox="0 0 240 170" role="img" aria-label="Вигляд збоку: нахил і руки"></svg><figcaption>збоку, стіл праворуч</figcaption></figure>
|
|
476
|
+
<figure><svg id="topv" viewBox="0 0 160 170" role="img" aria-label="Вигляд згори: поворот"></svg><figcaption>згори, стіл угорі</figcaption></figure>
|
|
477
|
+
</div>
|
|
478
|
+
<div class="fader"><label for="f0">Поворот<small>J1 · ±45°</small></label><input type="range" id="f0" min="-45" max="45" step="1" value="0"><output id="o0">0°</output></div>
|
|
479
|
+
<div class="fader"><label for="f1">Нахил<small>J2 · + уперед</small></label><input type="range" id="f1" min="-10" max="25" step="1" value="0"><output id="o1">0°</output></div>
|
|
480
|
+
<div class="fader"><label for="f2">Права рука<small>J3 · 0° висить</small></label><input type="range" id="f2" min="-30" max="160" step="1" value="65"><output id="o2">65°</output></div>
|
|
481
|
+
<div class="fader"><label for="f3">Ліва рука<small>J4 · 0° висить</small></label><input type="range" id="f3" min="-30" max="160" step="1" value="65"><output id="o3">65°</output></div>
|
|
482
|
+
<div class="row">
|
|
483
|
+
<button type="button" id="home">У центр</button>
|
|
484
|
+
<button type="button" id="mirror" aria-pressed="false" title="права й ліва рука рухаються разом">Руки разом</button>
|
|
485
|
+
<button type="button" class="pri" id="send" hidden>Поїхали</button>
|
|
486
|
+
<button type="button" class="ghost" data-cmd="where" title="запитати в плати, де зараз суглоби" style="margin-left:auto">Оновити позу</button>
|
|
487
|
+
</div>
|
|
488
|
+
</div>
|
|
489
|
+
|
|
490
|
+
<div class="card">
|
|
491
|
+
<div class="hd"><h2>Сценки</h2></div>
|
|
492
|
+
<div class="btns">
|
|
493
|
+
<button type="button" data-cmd="type">Друкує</button>
|
|
494
|
+
<button type="button" data-cmd="wave">Махає</button>
|
|
495
|
+
<button type="button" data-cmd="look">Озирається</button>
|
|
496
|
+
<button type="button" data-cmd="nod">Киває</button>
|
|
497
|
+
<button type="button" data-cmd="happy">Радіє</button>
|
|
498
|
+
<button type="button" data-cmd="sleep">Спить</button>
|
|
499
|
+
</div>
|
|
500
|
+
<div class="fader"><label for="spd">Швидкість рук</label><input type="range" id="spd" min="10" max="150" step="5" value="60"><output id="ospd">60°/с</output></div>
|
|
501
|
+
<div class="sep"></div>
|
|
502
|
+
<div class="hd"><h2>Серво</h2></div>
|
|
503
|
+
<div class="btns">
|
|
504
|
+
<button type="button" data-cmd="on">Тримати</button>
|
|
505
|
+
<button type="button" data-cmd="off" title="зняти струм: Desky обм'якне, його можна повернути рукою">Відпустити</button>
|
|
506
|
+
<button type="button" data-cmd="beep">Пискнути</button>
|
|
507
|
+
</div>
|
|
508
|
+
<div class="opt"><div>Ворушиться в спокої<small>дрібні рухи, коли нічого не відбувається</small></div><button type="button" class="sm" data-cmd="idle">увімк / вимк</button></div>
|
|
509
|
+
<div class="opt"><div>Тримати після руху<small>інакше відпускає за 0,6 с</small></div><button type="button" class="sm" data-cmd="hold">увімк / вимк</button></div>
|
|
510
|
+
</div>
|
|
511
|
+
</div>
|
|
512
|
+
</section>
|
|
513
|
+
|
|
514
|
+
<!-- ============================================================ calibration -->
|
|
515
|
+
<section data-page="cal" class="page" hidden>
|
|
516
|
+
<div class="title"><div><h1>Калібрування</h1><p>Де в Desky нуль і куди рухається кожен суглоб.</p></div>
|
|
517
|
+
<button type="button" class="ghost" data-cmd="cal">Оновити з плати</button></div>
|
|
518
|
+
<div class="card calhero">
|
|
519
|
+
<div><h2>Покроковий майстер</h2><p>Desky сам покаже кожен рух, а ти лише скажеш, чи так. Центр виставляєш повзунком і одразу бачиш результат на Desky. Приблизно 3 хвилини.</p></div>
|
|
520
|
+
<button type="button" class="pri lg" id="calWiz">Почати калібрування</button>
|
|
521
|
+
</div>
|
|
522
|
+
<div class="joints" id="joints"></div>
|
|
523
|
+
<div class="card">
|
|
524
|
+
<div class="hd"><h2>Проводи й екран</h2></div>
|
|
525
|
+
<div class="set tog">
|
|
526
|
+
<div class="field"><label>Поворот і нахил переплутані<small>Повзунок повороту нахиляє Desky, а нахилу — крутить? Серво під'єднані навпаки. <span id="swapV"></span></small></label>
|
|
527
|
+
<button type="button" class="sm" id="swapYP">Поміняти місцями</button></div>
|
|
528
|
+
<div class="field"><label>Екран догори дриґом<small>Очі-галочки «^ ^» мають дивитися кутиками вгору. <span id="flipV"></span></small></label>
|
|
529
|
+
<span class="in"><button type="button" class="sm ghost" id="faceTest">Показати «^ ^»</button><button type="button" class="sm" id="flipScr">Перевернути</button></span></div>
|
|
530
|
+
</div>
|
|
531
|
+
<p class="muted small">Ці дві зміни плата зберігає одразу.</p>
|
|
532
|
+
</div>
|
|
533
|
+
<div class="savebar" id="calbar"><p id="calMsg">Зміни центру й напрямку діють одразу, але після перезапуску плати зникнуть, якщо їх не зберегти.</p><button type="button" class="pri" id="calSave">Зберегти в платі</button></div>
|
|
534
|
+
</section>
|
|
535
|
+
|
|
536
|
+
<!-- ============================================================ settings -->
|
|
537
|
+
<section data-page="cfg" class="page" hidden>
|
|
538
|
+
<div class="title"><div><h1>Налаштування</h1><p>Як Desky реагує на Claude Code. Змінюється одразу, без перезапуску.</p></div></div>
|
|
539
|
+
<div class="card colorcard">
|
|
540
|
+
<div class="hd"><h2>Колір Desky</h2><span class="muted small" id="colorNow"></span></div>
|
|
541
|
+
<p class="hint">Якого кольору твій Desky. Під нього підлаштуються застосунок і 3D-модель, а Desky перефарбує обличчя на своєму екрані.</p>
|
|
542
|
+
<div class="swatches" id="cfgSwatches" role="radiogroup" aria-label="Колір Desky"></div>
|
|
543
|
+
</div>
|
|
544
|
+
<div class="cols">
|
|
545
|
+
<div class="card">
|
|
546
|
+
<div class="hd"><h2>Звук</h2></div>
|
|
547
|
+
<div class="set">
|
|
548
|
+
<div class="field"><label for="qh0">Тихі години<small>без звуку, лише рухи</small></label>
|
|
549
|
+
<span class="in"><input class="num s" type="number" id="qh0" min="0" max="24"><span class="muted">–</span><input class="num s" type="number" id="qh1" min="0" max="24"><span class="unit">год</span></span></div>
|
|
550
|
+
<div class="field"><label for="ask_times">Пищати «чекає»<small>разом із першим разом</small></label>
|
|
551
|
+
<span class="in"><input class="num" type="number" id="ask_times" min="0"><span class="unit">разів</span></span></div>
|
|
552
|
+
<div class="field"><label for="ask_repeat_secs">Повтор трелі</label>
|
|
553
|
+
<span class="in"><input class="num" type="number" id="ask_repeat_secs" min="0"><span class="unit" data-for="ask_repeat_secs"></span></span></div>
|
|
554
|
+
</div>
|
|
555
|
+
</div>
|
|
556
|
+
<div class="card">
|
|
557
|
+
<div class="hd"><h2>Час</h2></div>
|
|
558
|
+
<div class="set">
|
|
559
|
+
<div class="field"><label for="done_secs">«Закінчив» триває<small>потім «нічого не робить»</small></label>
|
|
560
|
+
<span class="in"><input class="num" type="number" id="done_secs" min="0"><span class="unit" data-for="done_secs"></span></span></div>
|
|
561
|
+
<div class="field"><label for="sleep_secs">Засинає через<small>якщо немає подій</small></label>
|
|
562
|
+
<span class="in"><input class="num" type="number" id="sleep_secs" min="0"><span class="unit" data-for="sleep_secs"></span></span></div>
|
|
563
|
+
</div>
|
|
564
|
+
</div>
|
|
565
|
+
<div class="card">
|
|
566
|
+
<div class="hd"><h2>Забувати сесію</h2></div>
|
|
567
|
+
<div class="set">
|
|
568
|
+
<div class="field"><label for="session_ttl_secs">Мовчить<small>після «закінчив» або простою</small></label>
|
|
569
|
+
<span class="in"><input class="num" type="number" id="session_ttl_secs" min="0"><span class="unit" data-for="session_ttl_secs"></span></span></div>
|
|
570
|
+
<div class="field"><label for="busy_ttl_secs">Працювала й зникла<small>термінал закрили; довше 10 хв команди не йдуть</small></label>
|
|
571
|
+
<span class="in"><input class="num" type="number" id="busy_ttl_secs" min="0"><span class="unit" data-for="busy_ttl_secs"></span></span></div>
|
|
572
|
+
<div class="field"><label for="ask_ttl_secs">Питання без відповіді</label>
|
|
573
|
+
<span class="in"><input class="num" type="number" id="ask_ttl_secs" min="0"><span class="unit" data-for="ask_ttl_secs"></span></span></div>
|
|
574
|
+
</div>
|
|
575
|
+
</div>
|
|
576
|
+
<div class="card">
|
|
577
|
+
<div class="hd"><h2>«Читає» чи «працює»</h2></div>
|
|
578
|
+
<div class="set">
|
|
579
|
+
<div class="field col"><label for="read_tools">Інструменти для «читає»<small>через кому; решта — «працює»</small></label>
|
|
580
|
+
<input class="text" type="text" id="read_tools"></div>
|
|
581
|
+
</div>
|
|
582
|
+
</div>
|
|
583
|
+
</div>
|
|
584
|
+
<div class="savebar"><p id="cfgMsg">Час — у секундах.</p><button type="button" class="ghost" id="defCfg">За замовчуванням</button><button type="button" class="pri" id="saveCfg">Зберегти</button></div>
|
|
585
|
+
</section>
|
|
586
|
+
|
|
587
|
+
<!-- ============================================================ monitor -->
|
|
588
|
+
<section data-page="mon" class="page" hidden>
|
|
589
|
+
<div class="title"><div><h1>Монітор</h1><p>Усе, що йде на плату і приходить від неї. Плата відповідає текстом прошивки.</p></div></div>
|
|
590
|
+
<div class="term">
|
|
591
|
+
<div class="bar">
|
|
592
|
+
<span class="legend"><span><i style="background:#F2B48F"></i>ти</span><span><i style="background:#9FC6F0"></i>агент</span><span><i style="background:#E6E1DA"></i>плата</span></span>
|
|
593
|
+
<label class="check"><input type="checkbox" id="showAgent" checked> команди агента</label>
|
|
594
|
+
<button type="button" class="ghost sm" id="clearLog">Очистити</button>
|
|
595
|
+
</div>
|
|
596
|
+
<div class="log" id="log" aria-live="polite"></div>
|
|
597
|
+
<form class="raw" id="rawf"><input id="raw" placeholder="pose 0 10 80 80 · state ask · help" autocomplete="off"><button type="button" id="helpBtn">help</button><button type="submit">Надіслати</button></form>
|
|
598
|
+
</div>
|
|
599
|
+
</section>
|
|
600
|
+
</main>
|
|
601
|
+
</div>
|
|
602
|
+
|
|
603
|
+
<!-- ============================================================ setup wizard -->
|
|
604
|
+
<div class="wiz" id="wiz" hidden role="dialog" aria-modal="true" aria-labelledby="wizTitle">
|
|
605
|
+
<div class="panel">
|
|
606
|
+
<div class="top">
|
|
607
|
+
<div class="brand"><svg viewBox="0 0 64 48" aria-hidden="true" id="wizLogo"></svg>Desky<span class="brand2">Agent</span></div>
|
|
608
|
+
<div class="prog"><div class="bars" id="wizBars"></div><div class="lbl" id="wizLbl"></div></div>
|
|
609
|
+
<button type="button" class="ghost x" id="wizClose" title="закрити майстер"><svg viewBox="0 0 16 16"><path d="M3.5 3.5l9 9M12.5 3.5l-9 9"/></svg></button>
|
|
610
|
+
</div>
|
|
611
|
+
<div class="body" id="wizBody"></div>
|
|
612
|
+
</div>
|
|
613
|
+
</div>
|
|
614
|
+
<div class="toast" id="toast" role="status"></div>
|
|
615
|
+
|
|
616
|
+
<script>
|
|
617
|
+
(() => {
|
|
618
|
+
const $ = id => document.getElementById(id);
|
|
619
|
+
const css = n => getComputedStyle(document.documentElement).getPropertyValue(n).trim();
|
|
620
|
+
const wait = ms => new Promise(r => setTimeout(r, ms));
|
|
621
|
+
const NAMES = { wake: 'прокинувся', listen: 'слухає', work: 'працює', read: 'читає', ask: 'чекає на тебе',
|
|
622
|
+
error: 'помилка', done: 'закінчив', idle: 'нічого не робить', sleep: 'спить' };
|
|
623
|
+
const WHAT = { wake: 'Щойно прокинувся', listen: 'Почув твоє повідомлення', work: 'Claude Code пише код або запускає команди',
|
|
624
|
+
read: 'Claude Code читає файли', ask: 'Claude Code чекає на відповідь', error: 'Інструмент повернув помилку',
|
|
625
|
+
done: 'Задачу виконано', idle: 'Сесії відкриті, тиша', sleep: 'Давно не було подій' };
|
|
626
|
+
const SOUNDS = { wake: 'прокинувся', tick: 'тік', ask: 'трель', error: 'помилка', done: 'готово', sleep: 'засинає' };
|
|
627
|
+
// The colours Desky is printed in (src/core.js COLORS). body and eye: his plastic and the face on his screen (the
|
|
628
|
+
// board keeps them, "color"); a and d: the app's accent, hover and text on it, for light and dark windows
|
|
629
|
+
const PALETTE = {
|
|
630
|
+
orange: { name: 'Помаранчевий', body: '#D9774B', eye: '#000000', a: ['#D9774B', '#C4643A', '#FFFFFF'], d: ['#E3825A', '#EC9167', '#1A0F0A'] },
|
|
631
|
+
white: { name: 'Білий', body: '#ECE8E1', eye: '#000000', a: ['#8A7D6B', '#73675A', '#FFFFFF'], d: ['#D6CEC2', '#E6DFD5', '#1A1712'] },
|
|
632
|
+
mint: { name: 'М\'ятний', body: '#7CC4A4', eye: '#000000', a: ['#3E9A75', '#2F8263', '#FFFFFF'], d: ['#6CC49E', '#88D3B2', '#0D1F17'] },
|
|
633
|
+
blue: { name: 'Блакитний', body: '#6FA3D8', eye: '#000000', a: ['#3B7BC2', '#2D66A8', '#FFFFFF'], d: ['#6FA7E0', '#8BBAEA', '#0D1824'] },
|
|
634
|
+
graphite: { name: 'Графіт', body: '#3D3B39', eye: '#F2EFEA', a: ['#3D3B39', '#2A2826', '#FFFFFF'], d: ['#BDB7AF', '#D3CDC5', '#1A1917'] },
|
|
635
|
+
};
|
|
636
|
+
let COLOR = 'orange', boardColor = null, boardFw = null, colorAsked = false;
|
|
637
|
+
const canColor = () => { const v = String(boardFw || '').split('.').map(Number); return v.length === 3 && (v[0] > 0 || v[1] > 2 || (v[1] === 2 && v[2] >= 4)); };
|
|
638
|
+
let CFG = null;
|
|
639
|
+
|
|
640
|
+
// ---------------------------------------------------------------- toast
|
|
641
|
+
function toast(text, bad) {
|
|
642
|
+
const t = $('toast'); t.textContent = text; t.className = 'toast on' + (bad ? ' bad' : '');
|
|
643
|
+
clearTimeout(toast.t); toast.t = setTimeout(() => { t.className = 'toast' + (bad ? ' bad' : ''); }, 3200);
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// ---------------------------------------------------------------- pages
|
|
647
|
+
const TABS = document.querySelectorAll('nav button');
|
|
648
|
+
let curTab = 'home', C3 = null;
|
|
649
|
+
function showTab(name) {
|
|
650
|
+
curTab = name;
|
|
651
|
+
TABS.forEach(b => b.setAttribute('aria-selected', String(b.dataset.tab === name)));
|
|
652
|
+
document.querySelectorAll('[data-page]').forEach(p => { p.hidden = p.dataset.page !== name; });
|
|
653
|
+
try { localStorage.setItem('clawd.tab', name); } catch (e) {}
|
|
654
|
+
if (name === 'mon') logEl.scrollTop = logEl.scrollHeight;
|
|
655
|
+
place3d();
|
|
656
|
+
}
|
|
657
|
+
// one 3D Desky: on the overview he plays the agent's state, on "Рухи" he follows the sliders, in the wizard the step
|
|
658
|
+
function place3d() {
|
|
659
|
+
if (!C3 || !$('wiz').hidden) return;
|
|
660
|
+
C3.glow(null);
|
|
661
|
+
if (curTab === 'home') { C3.mount($('homeScene'), 'hero'); C3.state(lastState || 'idle'); }
|
|
662
|
+
else if (curTab === 'move') { C3.mount($('moveScene'), 'moves'); C3.pose(pose()); }
|
|
663
|
+
else C3.mount(null);
|
|
664
|
+
}
|
|
665
|
+
addEventListener('clawd3d', () => { C3 = window.Clawd3D; C3.colors(PALETTE[COLOR].body, PALETTE[COLOR].eye); document.body.classList.add('has3d'); place3d(); if (!$('wiz').hidden && W.step) go(W.step, W.sub); });
|
|
666
|
+
TABS.forEach(b => b.onclick = () => showTab(b.dataset.tab));
|
|
667
|
+
|
|
668
|
+
// ---------------------------------------------------------------- talking to the daemon
|
|
669
|
+
let up = false, connected = false, manual = false, beat = null;
|
|
670
|
+
async function api(path, body) {
|
|
671
|
+
const r = await fetch(path, body === undefined ? {} : { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });
|
|
672
|
+
if (!r.ok) throw new Error((await r.json().catch(() => ({}))).error || r.status);
|
|
673
|
+
return r.json();
|
|
674
|
+
}
|
|
675
|
+
function showMode() {
|
|
676
|
+
$('manualbox').hidden = !manual || !$('wiz').hidden;
|
|
677
|
+
$('dMode').className = 'dot ' + (manual ? 'warn' : 'on');
|
|
678
|
+
$('sMode').textContent = manual ? 'ти' : 'агент';
|
|
679
|
+
// in manual mode Desky shows what the app says, not this: call it the agent's state then
|
|
680
|
+
$('aKicker').textContent = $('hKicker').textContent = manual ? 'Агент зараз' : 'Зараз показує';
|
|
681
|
+
}
|
|
682
|
+
async function setManual(on) {
|
|
683
|
+
try { manual = (await api('/manual', { on })).manual; } catch (e) {}
|
|
684
|
+
showMode();
|
|
685
|
+
}
|
|
686
|
+
// every hand command takes Desky from the agent; the daemon gives him back 15 s after the last keep-alive
|
|
687
|
+
// calibration writes the board's memory: the firmware takes it only after "factory on" (docs/firmware_contract.md)
|
|
688
|
+
const FACTORY = ['trim', 'inv', 'here', 'save', 'swap', 'flip', 'probe', 'hold', 'yawhold', 'sn', 'calset', 'face'];
|
|
689
|
+
async function send(cmd, quiet) {
|
|
690
|
+
if (FACTORY.includes(cmd.trim().split(/\s+/)[0].toLowerCase())) await api('/cmd', { line: 'factory on', hand: false }).catch(() => {});
|
|
691
|
+
if (!quiet) { lastHand = Date.now(); manual = true; showMode(); }
|
|
692
|
+
try { await api('/cmd', { line: cmd, hand: !quiet }); } catch (e) { log('не надіслано: ' + e.message, 'dim'); }
|
|
693
|
+
}
|
|
694
|
+
let lastHand = 0;
|
|
695
|
+
setInterval(() => {
|
|
696
|
+
if (!$('wiz').hidden && connected) lastHand = Date.now(); // the wizard holds Desky for as long as it is open
|
|
697
|
+
if (manual && Date.now() - lastHand < 60000) setManual(true);
|
|
698
|
+
}, 5000);
|
|
699
|
+
$('toAgent').onclick = () => { lastHand = 0; manual = false; setManual(false); };
|
|
700
|
+
|
|
701
|
+
// ---------------------------------------------------------------- monitor
|
|
702
|
+
const logEl = $('log');
|
|
703
|
+
function log(text, cls) {
|
|
704
|
+
if (cls === 'agent' && !$('showAgent').checked) return;
|
|
705
|
+
const s = document.createElement('span'); if (cls) s.className = cls;
|
|
706
|
+
s.textContent = (cls === 'me' || cls === 'agent' ? '> ' : '') + text + '\n';
|
|
707
|
+
const stick = logEl.scrollTop + logEl.clientHeight >= logEl.scrollHeight - 20;
|
|
708
|
+
logEl.appendChild(s);
|
|
709
|
+
while (logEl.childNodes.length > 500) logEl.removeChild(logEl.firstChild);
|
|
710
|
+
if (stick) logEl.scrollTop = logEl.scrollHeight;
|
|
711
|
+
}
|
|
712
|
+
$('clearLog').onclick = () => { logEl.innerHTML = ''; };
|
|
713
|
+
let since = 0, primed = false;
|
|
714
|
+
async function pollLines() {
|
|
715
|
+
try {
|
|
716
|
+
const lines = await api('/lines?since=' + since);
|
|
717
|
+
for (const l of lines) {
|
|
718
|
+
since = l.n;
|
|
719
|
+
log(l.text, l.kind === 'c3' ? '' : l.kind);
|
|
720
|
+
if (l.kind === 'c3') onLine(l.text);
|
|
721
|
+
}
|
|
722
|
+
if (!primed) { primed = true; send('cal', true); send('where', true); }
|
|
723
|
+
} catch (e) {}
|
|
724
|
+
}
|
|
725
|
+
setInterval(pollLines, 300);
|
|
726
|
+
|
|
727
|
+
// ---------------------------------------------------------------- status
|
|
728
|
+
const dur = s => s < 120 ? Math.round(s) + ' с' : s < 7200 ? Math.round(s / 60) + ' хв' : (s / 3600).toFixed(1).replace('.0', '').replace('.', ',') + ' год';
|
|
729
|
+
const plural = (n, a, b, c) => { const m = n % 10, h = n % 100; return m === 1 && h !== 11 ? a : m >= 2 && m <= 4 && (h < 12 || h > 14) ? b : c; };
|
|
730
|
+
let firstStatus = true, port = '', lastState = null;
|
|
731
|
+
async function pollStatus() {
|
|
732
|
+
let st;
|
|
733
|
+
try { st = await api('/status'); up = true; } catch (e) { up = false; }
|
|
734
|
+
$('dDaemon').className = 'dot ' + (up ? 'on' : 'bad');
|
|
735
|
+
$('sDaemon').textContent = up ? 'працює' : 'не відповідає';
|
|
736
|
+
$('downbox').hidden = up;
|
|
737
|
+
if (!up) { connected = false; beat = null; $('nocbox').hidden = true; enable(); wizTick(); return; }
|
|
738
|
+
const was = connected;
|
|
739
|
+
connected = st.connected; port = st.port || '';
|
|
740
|
+
if (connected && !was) { boardColor = null; colorAsked = false; send('cal', true); }
|
|
741
|
+
boardFw = connected && st.board ? st.board.fw : null;
|
|
742
|
+
if (connected && canColor() && !colorAsked) { colorAsked = true; send('color', true); }
|
|
743
|
+
$('dC3').className = 'dot ' + (connected ? 'on' : 'bad');
|
|
744
|
+
$('sC3').textContent = connected ? st.port : 'немає';
|
|
745
|
+
$('nocbox').hidden = connected;
|
|
746
|
+
beat = connected && st.heartbeat && st.heartbeat_age < 8 ? st.heartbeat : null;
|
|
747
|
+
if (beat) {
|
|
748
|
+
const limp = /отпущены/.test(beat);
|
|
749
|
+
$('dServo').className = 'dot ' + (limp ? 'warn' : 'on');
|
|
750
|
+
$('health').textContent = limp ? 'відпущені' : 'тримають';
|
|
751
|
+
$('fUp').textContent = dur(+(beat.match(/(\d+) с/) || [0, 0])[1]);
|
|
752
|
+
$('limpbox').hidden = !limp;
|
|
753
|
+
} else {
|
|
754
|
+
$('dServo').className = 'dot' + (connected ? ' bad' : ''); $('health').textContent = connected ? 'мовчать' : '—';
|
|
755
|
+
$('fUp').textContent = '—'; $('limpbox').hidden = true;
|
|
756
|
+
}
|
|
757
|
+
manual = st.manual; showMode();
|
|
758
|
+
|
|
759
|
+
$('aState').textContent = $('hState').textContent = NAMES[st.state] || st.state;
|
|
760
|
+
$('aWhat').textContent = $('hWhat').textContent = WHAT[st.state] || '';
|
|
761
|
+
$('fQuiet').textContent = st.quiet_now ? 'вимкнено' : 'увімкнено';
|
|
762
|
+
if (CFG) { const [a, b] = CFG.quiet_hours; $('fHours').textContent = a === b ? 'немає' : a + ':00 – ' + b + ':00'; }
|
|
763
|
+
|
|
764
|
+
const ses = Object.entries(st.by_session || {}), host = $('sessions');
|
|
765
|
+
$('sessCount').textContent = ses.length ? ses.length + ' ' + plural(ses.length, 'відкрита', 'відкриті', 'відкрито') : '';
|
|
766
|
+
host.innerHTML = '';
|
|
767
|
+
if (!ses.length) host.innerHTML = '<div class="empty"><b>Сесій немає</b>Запусти Claude Code, і Desky прокинеться.</div>';
|
|
768
|
+
else {
|
|
769
|
+
const list = document.createElement('div'); list.className = 'list';
|
|
770
|
+
for (const [sid, s] of ses) {
|
|
771
|
+
const r = document.createElement('div'); r.className = 'li';
|
|
772
|
+
r.innerHTML = '<span class="mono"></span><span class="badge"></span>';
|
|
773
|
+
r.querySelector('.mono').textContent = sid;
|
|
774
|
+
const b = r.querySelector('.badge'); b.textContent = NAMES[s] || s; if (s === 'ask') b.classList.add('ask');
|
|
775
|
+
list.appendChild(r);
|
|
776
|
+
}
|
|
777
|
+
host.appendChild(list);
|
|
778
|
+
}
|
|
779
|
+
if (st.state !== lastState) {
|
|
780
|
+
lastState = st.state; ['face', 'logo', 'bigface'].forEach(id => drawFace($(id), st.state));
|
|
781
|
+
if (C3 && curTab === 'home' && $('wiz').hidden) C3.state(st.state);
|
|
782
|
+
}
|
|
783
|
+
$('hSess').textContent = ses.length ? ses.length + ' ' + plural(ses.length, 'відкрита', 'відкриті', 'відкрито') : 'немає';
|
|
784
|
+
$('hBoard').textContent = connected ? 'на зв\'язку' : 'не під\'єднано';
|
|
785
|
+
enable();
|
|
786
|
+
wizTick();
|
|
787
|
+
if (firstStatus) {
|
|
788
|
+
firstStatus = false;
|
|
789
|
+
let seen = false; try { seen = !!localStorage.getItem('clawd.onboarded'); } catch (e) { seen = true; }
|
|
790
|
+
if (!seen) wizOpen();
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
function enable() {
|
|
794
|
+
document.querySelectorAll('[data-cmd], #send, #home, #stop, #swapYP, #flipScr, #faceTest, #calSave, #rawf button, #joints button, #joints input, #statesRow button, #soundsRow button')
|
|
795
|
+
.forEach(b => { b.disabled = !connected; });
|
|
796
|
+
$('reset').disabled = !up || !connected;
|
|
797
|
+
F.forEach(f => { f.disabled = !connected; });
|
|
798
|
+
}
|
|
799
|
+
setInterval(pollStatus, 1000);
|
|
800
|
+
|
|
801
|
+
// a small picture of the face the state shows, as the firmware draws it: orange face, black eyes
|
|
802
|
+
function drawFace(s, state) {
|
|
803
|
+
s.innerHTML = '';
|
|
804
|
+
const c = PALETTE[COLOR].eye, add = (x, y, w, h, cls) => { const r = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
|
|
805
|
+
r.setAttribute('x', x); r.setAttribute('y', y); r.setAttribute('width', w); r.setAttribute('height', h); r.setAttribute('fill', c);
|
|
806
|
+
if (cls) r.setAttribute('class', cls); s.appendChild(r); };
|
|
807
|
+
const bg = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
|
|
808
|
+
bg.setAttribute('width', 64); bg.setAttribute('height', 48); bg.setAttribute('rx', 4); bg.setAttribute('fill', PALETTE[COLOR].body); s.appendChild(bg);
|
|
809
|
+
const eyes = { work: [9, 7, 0, 6], read: [7, 8, -4, 6], ask: [13, 13, 0, 0], sleep: [11, 2, 0, 4], idle: [8, 14, 0, 0],
|
|
810
|
+
wake: [8, 14, 0, 0], listen: [8, 14, 0, 0] }[state];
|
|
811
|
+
if (state === 'done' || state === 'happy') { for (const x of [16, 48]) for (let i = 0; i < 6; i++) { add(x - 6 + i, 26 - i, 2, 2); add(x + i, 21 + i, 2, 2); } return; }
|
|
812
|
+
if (state === 'sad') { for (const x of [16, 48]) for (let i = 0; i < 6; i++) { add(x - 6 + i, 20 + i, 2, 2); add(x + i, 25 - i, 2, 2); } return; }
|
|
813
|
+
if (state === 'error') { for (const [x, d] of [[16, 1], [48, -1]]) for (let i = 0; i < 6; i++) { add(x - d * 6 + d * i, 18 + i, 2, 2); add(x - d * 6 + d * i, 30 - i, 2, 2); } return; }
|
|
814
|
+
const [w, h, dx, dy] = eyes || [8, 14, 0, 0];
|
|
815
|
+
for (const x of [16, 48]) add(x - w / 2 + dx, 24 - h / 2 + dy, w, h, state === 'sleep' ? '' : 'eye');
|
|
816
|
+
if (state === 'sleep') add(54, 4, 5, 2), add(57, 6, 2, 2), add(54, 8, 5, 2);
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
// ---------------------------------------------------------------- previews
|
|
820
|
+
for (const [k, v] of Object.entries(NAMES)) {
|
|
821
|
+
const b = document.createElement('button'); b.type = 'button'; b.textContent = v; b.onclick = () => send('state ' + k); $('statesRow').appendChild(b);
|
|
822
|
+
}
|
|
823
|
+
for (const [k, v] of Object.entries(SOUNDS)) {
|
|
824
|
+
const b = document.createElement('button'); b.type = 'button'; b.textContent = v; b.onclick = () => send('sound ' + k, true); $('soundsRow').appendChild(b);
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
// ---------------------------------------------------------------- settings
|
|
828
|
+
const NUMS = ['done_secs', 'sleep_secs', 'ask_repeat_secs', 'ask_times', 'session_ttl_secs', 'busy_ttl_secs', 'ask_ttl_secs'];
|
|
829
|
+
let DEF = null;
|
|
830
|
+
// "600" means little at a glance: show it as minutes or hours next to the box
|
|
831
|
+
const human = s => !(s >= 0) ? '' : s < 60 ? s + ' с' : s % 3600 === 0 ? s / 3600 + ' год' : s % 60 === 0 ? s / 60 + ' хв'
|
|
832
|
+
: (s / 60).toFixed(1).replace('.', ',') + ' хв';
|
|
833
|
+
function units() { document.querySelectorAll('.unit[data-for]').forEach(u => { const v = $(u.dataset.for).value; u.textContent = v === '' ? 'с' : 'с · ' + human(+v); }); }
|
|
834
|
+
NUMS.forEach(k => $(k).addEventListener('input', units));
|
|
835
|
+
function fillCfg(c) {
|
|
836
|
+
CFG = c;
|
|
837
|
+
if (c.color && c.color !== COLOR) applyColor(c.color);
|
|
838
|
+
reconcileColor();
|
|
839
|
+
$('qh0').value = c.quiet_hours[0]; $('qh1').value = c.quiet_hours[1];
|
|
840
|
+
NUMS.forEach(k => { $(k).value = c[k]; });
|
|
841
|
+
$('read_tools').value = c.read_tools.join(', ');
|
|
842
|
+
units();
|
|
843
|
+
}
|
|
844
|
+
async function loadCfg() { try { const r = await api('/config'); DEF = r.defaults; fillCfg(r.config); } catch (e) {} }
|
|
845
|
+
const say = (t, cls) => { const m = $('cfgMsg'); m.className = cls || ''; m.textContent = t;
|
|
846
|
+
clearTimeout(say.t); say.t = setTimeout(() => { m.className = ''; m.textContent = 'Час — у секундах.'; }, 4000); };
|
|
847
|
+
$('saveCfg').onclick = async () => {
|
|
848
|
+
const body = { quiet_hours: [+$('qh0').value, +$('qh1').value], read_tools: $('read_tools').value.split(',').map(s => s.trim()).filter(Boolean) };
|
|
849
|
+
NUMS.forEach(k => { body[k] = +$(k).value; });
|
|
850
|
+
try { fillCfg((await api('/config', body)).config); say('Збережено', 'ok'); }
|
|
851
|
+
catch (e) { say(e.message, 'bad'); }
|
|
852
|
+
};
|
|
853
|
+
$('defCfg').onclick = () => { if (DEF) { const keep = CFG; fillCfg(DEF); CFG = keep; } say('Підставлено значення за замовчуванням — збережи, щоб застосувати'); };
|
|
854
|
+
loadCfg();
|
|
855
|
+
|
|
856
|
+
// ---------------------------------------------------------------- Desky's colour
|
|
857
|
+
function applyColor(name) {
|
|
858
|
+
COLOR = PALETTE[name] ? name : 'orange';
|
|
859
|
+
const c = PALETTE[COLOR], dark = matchMedia('(prefers-color-scheme: dark)').matches, [a, hi, ink] = dark ? c.d : c.a;
|
|
860
|
+
const st = document.documentElement.style;
|
|
861
|
+
st.setProperty('--clawd', a); st.setProperty('--clawd-hi', hi); st.setProperty('--clawd-ink', ink);
|
|
862
|
+
st.setProperty('--clawd-soft', `color-mix(in srgb, ${a} ${dark ? 18 : 12}%, var(--card))`);
|
|
863
|
+
st.setProperty('--clawd-glow', `color-mix(in srgb, ${a} 24%, transparent)`);
|
|
864
|
+
['face', 'logo', 'bigface', 'wizLogo'].forEach(id => $(id) && drawFace($(id), id === 'wizLogo' ? 'idle' : lastState || 'idle'));
|
|
865
|
+
if (C3) C3.colors(c.body, c.eye);
|
|
866
|
+
document.querySelectorAll('.swatch').forEach(b => b.setAttribute('aria-checked', String(b.dataset.color === COLOR)));
|
|
867
|
+
$('colorNow').textContent = c.name;
|
|
868
|
+
buildJoints();
|
|
869
|
+
}
|
|
870
|
+
const colorLine = n => 'color ' + PALETTE[n].body.slice(1).toLowerCase() + ' ' + PALETTE[n].eye.slice(1).toLowerCase();
|
|
871
|
+
// chosen here: the app takes it at once, the config keeps it, the board repaints his face and keeps it too
|
|
872
|
+
async function pickColor(name) {
|
|
873
|
+
applyColor(name);
|
|
874
|
+
try { CFG = (await api('/config', { color: COLOR })).config; } catch (e) {}
|
|
875
|
+
if (connected && canColor()) { boardColor = COLOR; send(colorLine(COLOR), true); }
|
|
876
|
+
}
|
|
877
|
+
// the board and the config disagree: a board left at the factory orange takes the chosen colour, any other colour on
|
|
878
|
+
// the board is the robot's own (printed and set at the factory) and wins
|
|
879
|
+
function reconcileColor() {
|
|
880
|
+
if (!CFG || !boardColor || boardColor === 'other' || boardColor === CFG.color) return;
|
|
881
|
+
if (boardColor === 'orange') { if (connected && canColor()) send(colorLine(CFG.color), true); boardColor = CFG.color; }
|
|
882
|
+
else pickColor(boardColor);
|
|
883
|
+
}
|
|
884
|
+
function swatches(host) {
|
|
885
|
+
host.innerHTML = '';
|
|
886
|
+
for (const [k, c] of Object.entries(PALETTE)) {
|
|
887
|
+
const b = document.createElement('button'); b.type = 'button'; b.className = 'swatch'; b.dataset.color = k;
|
|
888
|
+
b.setAttribute('role', 'radio'); b.setAttribute('aria-checked', String(k === COLOR));
|
|
889
|
+
b.innerHTML = `<span class="chip" style="--c:${c.body};--e:${c.eye}"></span><span>${c.name}${k === 'orange' ? '<small>основний</small>' : ''}</span>`;
|
|
890
|
+
b.onclick = () => pickColor(k);
|
|
891
|
+
host.appendChild(b);
|
|
892
|
+
}
|
|
893
|
+
return host;
|
|
894
|
+
}
|
|
895
|
+
swatches($('cfgSwatches'));
|
|
896
|
+
|
|
897
|
+
// ---------------------------------------------------------------- what the board prints back (firmware text, Russian)
|
|
898
|
+
const CAL = [{ dir: 1, trim: 0 }, { dir: 1, trim: 0 }, { dir: 1, trim: 0 }, { dir: -1, trim: 0 }];
|
|
899
|
+
let SWAP = null, FLIP = null;
|
|
900
|
+
const touched = [0, 0, 0, 0]; // when this window last moved a joint's trim: ignore echoes then
|
|
901
|
+
function onLine(line) {
|
|
902
|
+
if (/^Серво отпущены/i.test(line)) $('limpbox').hidden = false;
|
|
903
|
+
if (/^Нельзя:/.test(line)) toast('Desky так не стане: зачепить стіл або ноутбук', true);
|
|
904
|
+
let m = line.match(/поза: J1 ([+-]?\d+)\s+J2 ([+-]?\d+)\s+J3 (-?\d+)\s+J4 (-?\d+)/);
|
|
905
|
+
if (m && !dragging) setFaders([+m[1], +m[2], +m[3], +m[4]]);
|
|
906
|
+
m = line.match(/J([1-4]) [^:]+: направление ([+-]\d)/);
|
|
907
|
+
if (m) { CAL[+m[1] - 1].dir = +m[2]; calChanged(+m[1] - 1); }
|
|
908
|
+
m = line.match(/J([1-4]) [^:]+:.*подстройка ([+-]\d+) us/);
|
|
909
|
+
if (m && Date.now() - touched[+m[1] - 1] > 900) { CAL[+m[1] - 1].trim = +m[2]; calChanged(+m[1] - 1); }
|
|
910
|
+
// firmware's cal: "поворот на GPIO1, наклон на GPIO2; экран как есть" as wired in docs/pinout.html
|
|
911
|
+
m = line.match(/поворот на GPIO(\d+), наклон на GPIO(\d+)(?:; экран (.+))?/);
|
|
912
|
+
if (m) {
|
|
913
|
+
SWAP = +m[1] > +m[2]; $('swapV').textContent = SWAP ? 'Зараз: поміняні місцями.' : 'Зараз: як на схемі.';
|
|
914
|
+
if (m[3]) { FLIP = /перев/.test(m[3]); $('flipV').textContent = FLIP ? 'Зараз: перевернутий.' : 'Зараз: як є.'; }
|
|
915
|
+
}
|
|
916
|
+
if (/^сохранено/.test(line)) { calDirty(false); }
|
|
917
|
+
m = line.match(/^цвет ([0-9a-f]{6}) ([0-9a-f]{6})/i);
|
|
918
|
+
if (m) { boardColor = Object.keys(PALETTE).find(k => PALETTE[k].body.slice(1).toLowerCase() === m[1].toLowerCase()) || 'other'; reconcileColor(); }
|
|
919
|
+
if (/^err (trim|inv|here|save|swap|flip|face)/.test(line)) toast('Плата не прийняла команду: ' + line.slice(4), true);
|
|
920
|
+
wizLine(line);
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
// ---------------------------------------------------------------- faders
|
|
924
|
+
const F = [0, 1, 2, 3].map(i => $('f' + i)), O = [0, 1, 2, 3].map(i => $('o' + i));
|
|
925
|
+
const fill = f => f.style.setProperty('--p', (f.value - f.min) / (f.max - f.min) * 100 + '%');
|
|
926
|
+
const pose = () => F.map(f => +f.value);
|
|
927
|
+
let dragging = false, lastSent = 0, timer = null;
|
|
928
|
+
function setFaders(P) { P.forEach((v, i) => { F[i].value = v; }); refresh(); }
|
|
929
|
+
function refresh() {
|
|
930
|
+
const P = pose();
|
|
931
|
+
P.forEach((v, i) => { O[i].textContent = (i < 2 && v > 0 ? '+' : '') + v + '°'; fill(F[i]); });
|
|
932
|
+
drawSide($('side'), P); drawTop($('topv'), P[0], true);
|
|
933
|
+
if (C3 && curTab === 'move' && $('wiz').hidden) C3.pose(P);
|
|
934
|
+
}
|
|
935
|
+
const sendPose = () => send('pose ' + pose().join(' '));
|
|
936
|
+
function queueLive() {
|
|
937
|
+
if (!$('live').checked || !connected) return;
|
|
938
|
+
clearTimeout(timer);
|
|
939
|
+
const wt = Math.max(0, 180 - (Date.now() - lastSent));
|
|
940
|
+
timer = setTimeout(() => { lastSent = Date.now(); sendPose(); }, wt);
|
|
941
|
+
}
|
|
942
|
+
F.forEach((f, i) => {
|
|
943
|
+
f.addEventListener('pointerdown', () => { dragging = true; });
|
|
944
|
+
f.addEventListener('pointerup', () => { dragging = false; });
|
|
945
|
+
f.addEventListener('input', () => {
|
|
946
|
+
if ($('mirror').getAttribute('aria-pressed') === 'true' && i >= 2) F[5 - i].value = f.value;
|
|
947
|
+
refresh(); queueLive();
|
|
948
|
+
});
|
|
949
|
+
});
|
|
950
|
+
$('mirror').onclick = () => {
|
|
951
|
+
const on = $('mirror').getAttribute('aria-pressed') !== 'true';
|
|
952
|
+
$('mirror').setAttribute('aria-pressed', String(on));
|
|
953
|
+
if (on) { F[3].value = F[2].value; refresh(); queueLive(); }
|
|
954
|
+
};
|
|
955
|
+
$('live').onchange = () => { $('send').hidden = $('live').checked; };
|
|
956
|
+
$('send').onclick = sendPose;
|
|
957
|
+
$('home').onclick = () => { setFaders([0, 0, 65, 65]); send('home'); };
|
|
958
|
+
$('stop').onclick = () => send('stop');
|
|
959
|
+
document.querySelectorAll('[data-cmd]').forEach(b => b.onclick = () => send(b.dataset.cmd, ['where', 'cal'].includes(b.dataset.cmd)));
|
|
960
|
+
const spd = $('spd');
|
|
961
|
+
spd.oninput = () => { $('ospd').textContent = spd.value + '°/с'; fill(spd); };
|
|
962
|
+
spd.onchange = () => send('speed ' + spd.value);
|
|
963
|
+
fill(spd);
|
|
964
|
+
$('reset').onclick = async () => { try { await api('/reset', {}); } catch (e) {} setTimeout(() => send('cal', true), 5000); };
|
|
965
|
+
$('rawf').onsubmit = e => { e.preventDefault(); const v = $('raw').value.trim(); if (v) { send(v, /^(where|cal|help|who|ping|sound )/.test(v)); $('raw').value = ''; } };
|
|
966
|
+
$('helpBtn').onclick = () => send('help', true);
|
|
967
|
+
|
|
968
|
+
// ---------------------------------------------------------------- joints: what each one is and how to judge it
|
|
969
|
+
// as factory/clawd_factory/calibrate.py: direction first, then the centre (an arm's trim counts along its direction)
|
|
970
|
+
const US_PER_DEG = 1000 / 90; // MG90S, as the firmware: about 1000 us per 90 deg
|
|
971
|
+
const J = [
|
|
972
|
+
{ n: 1, name: 'Поворот голови', short: 'Поворот', base: 0, plus: 15, ref: 0,
|
|
973
|
+
plusText: 'Голова повернулася <b>праворуч</b>, якщо дивитися Desky в обличчя.',
|
|
974
|
+
refText: 'голова дивиться <b>прямо вперед</b>, рівно на ноутбук', lo: 'ліворуч', hi: 'праворуч' },
|
|
975
|
+
{ n: 2, name: 'Нахил голови', short: 'Нахил', base: 0, plus: 10, ref: 0,
|
|
976
|
+
plusText: 'Голова нахилилася <b>вперед</b>, до ноутбука.',
|
|
977
|
+
refText: 'голова стоїть <b>рівно</b>: не нахилена ні вперед, ні назад', lo: 'назад', hi: 'вперед' },
|
|
978
|
+
{ n: 3, name: 'Права рука', short: 'Права рука', base: 65, plus: 20, ref: 0,
|
|
979
|
+
plusText: 'Права рука Desky <b>піднялася вперед</b>. Це та, що в тебе <b>зліва</b>, коли дивишся йому в обличчя.',
|
|
980
|
+
refText: 'права рука <b>висить рівно вниз</b>', lo: 'назад', hi: 'вперед' },
|
|
981
|
+
{ n: 4, name: 'Ліва рука', short: 'Ліва рука', base: 65, plus: 20, ref: 0,
|
|
982
|
+
plusText: 'Ліва рука Desky <b>піднялася вперед</b>. Це та, що в тебе <b>справа</b>, коли дивишся йому в обличчя.',
|
|
983
|
+
refText: 'ліва рука <b>висить рівно вниз</b>', lo: 'назад', hi: 'вперед' },
|
|
984
|
+
];
|
|
985
|
+
const HOME = [0, 0, 65, 65];
|
|
986
|
+
const FACTORY_DIR = [1, 1, 1, -1]; // play.cpp dirOf: the arms are mirror images
|
|
987
|
+
const poseWith = (j, v) => { const p = HOME.slice(); p[j] = v; return p; };
|
|
988
|
+
const trimToDeg = j => CAL[j].trim * CAL[j].dir / US_PER_DEG;
|
|
989
|
+
const degToTrim = (j, d) => Math.max(-500, Math.min(500, Math.round(d * US_PER_DEG * CAL[j].dir)));
|
|
990
|
+
const fmtDeg = d => (d > 0.04 ? '+' : d < -0.04 ? '−' : '') + Math.abs(d).toFixed(1).replace('.', ',') + '°';
|
|
991
|
+
|
|
992
|
+
// a live trim: the firmware moves the servo at once (play.cpp, "trim"); at most one line per 110 ms, the last one always
|
|
993
|
+
const trimQ = [null, null, null, null], trimT = [0, 0, 0, 0], trimTimer = [];
|
|
994
|
+
function sendTrim(j, us) {
|
|
995
|
+
CAL[j].trim = us; touched[j] = Date.now(); calDirty(true);
|
|
996
|
+
trimQ[j] = us;
|
|
997
|
+
if (trimTimer[j]) return;
|
|
998
|
+
const go = () => {
|
|
999
|
+
trimTimer[j] = null;
|
|
1000
|
+
if (trimQ[j] === null) return;
|
|
1001
|
+
const v = trimQ[j]; trimQ[j] = null; trimT[j] = Date.now();
|
|
1002
|
+
send('trim j' + (j + 1) + ' ' + (v >= 0 ? '+' : '') + v);
|
|
1003
|
+
trimTimer[j] = setTimeout(go, 110);
|
|
1004
|
+
};
|
|
1005
|
+
const wt = Math.max(0, 110 - (Date.now() - trimT[j]));
|
|
1006
|
+
trimTimer[j] = setTimeout(go, wt);
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
// the centre dial in degrees (±45° = ±500 us), filled from the middle; fine steps of 0.5° and the arrow keys
|
|
1010
|
+
function makeDial(j, onMove) {
|
|
1011
|
+
const d = document.createElement('div'); d.className = 'dial';
|
|
1012
|
+
d.innerHTML = `<div class="ends"><span>← ${J[j].lo}</span><b></b><span>${J[j].hi} →</span></div>
|
|
1013
|
+
<div class="track"><input type="range" min="-45" max="45" step="0.1" aria-label="центр: ${J[j].short}"></div>
|
|
1014
|
+
<div class="fine"><button type="button" class="sm" data-d="-2">−2°</button><button type="button" class="sm" data-d="-0.5">−½°</button>
|
|
1015
|
+
<button type="button" class="sm ghost" data-z>у нуль</button>
|
|
1016
|
+
<button type="button" class="sm" data-d="0.5">+½°</button><button type="button" class="sm" data-d="2">+2°</button></div>
|
|
1017
|
+
<div class="hint"></div>`;
|
|
1018
|
+
const r = d.querySelector('input'), b = d.querySelector('.ends b'), hint = d.querySelector('.hint');
|
|
1019
|
+
const paint = () => {
|
|
1020
|
+
const v = +r.value, p = (v + 45) / 90 * 100;
|
|
1021
|
+
r.style.setProperty('--a', Math.min(50, p) + '%'); r.style.setProperty('--b', Math.max(50, p) + '%');
|
|
1022
|
+
b.textContent = fmtDeg(v);
|
|
1023
|
+
const us = Math.abs(degToTrim(j, v)), big = us > 200;
|
|
1024
|
+
d.classList.toggle('warn', big);
|
|
1025
|
+
hint.className = 'hint' + (big ? ' warn' : '');
|
|
1026
|
+
hint.innerHTML = big ? 'Зсув понад 18°: ходу в один бік стане менше. Краще переставити качалку серво на сусідній зубець і почати з нуля.'
|
|
1027
|
+
: 'Стрілки ← → на клавіатурі рухають на 0,1°. Зсув ' + (us ? '≈ ' + us + ' мкс' : 'нульовий') + '.';
|
|
1028
|
+
};
|
|
1029
|
+
const set = (v, push) => { r.value = Math.max(-45, Math.min(45, Math.round(v * 10) / 10)); paint(); if (push) { sendTrim(j, degToTrim(j, +r.value)); onMove && onMove(); } };
|
|
1030
|
+
r.addEventListener('input', () => set(+r.value, true));
|
|
1031
|
+
d.querySelectorAll('[data-d]').forEach(x => x.onclick = () => set(+r.value + +x.dataset.d, true));
|
|
1032
|
+
d.querySelector('[data-z]').onclick = () => set(0, true);
|
|
1033
|
+
d.sync = () => { if (Date.now() - touched[j] > 900 && document.activeElement !== r) set(trimToDeg(j), false); };
|
|
1034
|
+
set(trimToDeg(j), false);
|
|
1035
|
+
return d;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
// ---------------------------------------------------------------- calibration page
|
|
1039
|
+
const dials = [];
|
|
1040
|
+
function buildJoints() {
|
|
1041
|
+
const host = $('joints'); host.innerHTML = '';
|
|
1042
|
+
J.forEach((jj, j) => {
|
|
1043
|
+
const c = document.createElement('div'); c.className = 'card joint';
|
|
1044
|
+
c.innerHTML = `<div class="hd"><div><h2>${jj.name}</h2><small>J${jj.n}</small></div><button type="button" class="sm ghost" data-goref>Поставити в нуль</button></div>
|
|
1045
|
+
<div class="pic"><figure class="fig"><svg viewBox="0 0 160 120"></svg><figcaption>в обличчя</figcaption></figure>
|
|
1046
|
+
<figure class="fig"><svg viewBox="0 0 240 170"></svg><figcaption>${j === 0 ? 'згори' : 'збоку'}</figcaption></figure></div>
|
|
1047
|
+
<p class="hint">Центр: ${jj.refText}.</p>`;
|
|
1048
|
+
const dial = makeDial(j); dials[j] = dial; c.appendChild(dial);
|
|
1049
|
+
const dir = document.createElement('div'); dir.className = 'dir';
|
|
1050
|
+
dir.innerHTML = '<span>Напрямок: <b></b></span><button type="button" class="sm" data-test>Перевірити</button><button type="button" class="sm ghost" data-inv>Розвернути</button>';
|
|
1051
|
+
c.appendChild(dir);
|
|
1052
|
+
const [front, other] = c.querySelectorAll('svg');
|
|
1053
|
+
c.draw = () => {
|
|
1054
|
+
const P = poseWith(j, jj.ref);
|
|
1055
|
+
drawFront(front, P, j);
|
|
1056
|
+
if (j === 0) { other.setAttribute('viewBox', '0 0 160 170'); drawTop(other, 0); } else drawSide(other, P, j);
|
|
1057
|
+
dir.querySelector('b').textContent = CAL[j].dir === FACTORY_DIR[j] ? 'як із заводу' : 'розвернутий';
|
|
1058
|
+
};
|
|
1059
|
+
c.querySelector('[data-goref]').onclick = () => send('pose ' + poseWith(j, jj.ref).join(' '));
|
|
1060
|
+
dir.querySelector('[data-test]').onclick = async () => {
|
|
1061
|
+
await send('home'); await send('j' + jj.n + ' ' + (jj.base + jj.plus)); await wait(1400); await send('home');
|
|
1062
|
+
toast(jj.plusText.replace(/<[^>]+>/g, '') + ' Якщо ні — «Розвернути».');
|
|
1063
|
+
};
|
|
1064
|
+
dir.querySelector('[data-inv]').onclick = async () => { await send('inv j' + jj.n); calDirty(true); await send('cal', true); };
|
|
1065
|
+
c.draw();
|
|
1066
|
+
host.appendChild(c);
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
function calChanged(j) {
|
|
1070
|
+
const c = $('joints').children[j]; if (c && c.draw) c.draw();
|
|
1071
|
+
if (dials[j]) dials[j].sync();
|
|
1072
|
+
wizCal(j);
|
|
1073
|
+
}
|
|
1074
|
+
let dirty = false;
|
|
1075
|
+
function calDirty(on) {
|
|
1076
|
+
dirty = on; $('calbar').classList.toggle('dirty', on);
|
|
1077
|
+
$('calMsg').textContent = on ? 'Є незбережені зміни. Desky уже рухається з ними, але після перезапуску плати вони зникнуть.'
|
|
1078
|
+
: 'Усе збережено в платі.';
|
|
1079
|
+
}
|
|
1080
|
+
$('calSave').onclick = async () => { await send('save'); toast('Збережено в платі'); };
|
|
1081
|
+
$('swapYP').onclick = async () => { await send('swap'); await send('cal', true); };
|
|
1082
|
+
$('flipScr').onclick = async () => { await send('flip'); await send('face happy'); await send('cal', true); };
|
|
1083
|
+
$('faceTest').onclick = async () => { await send('face happy'); await wait(2500); await send('face eyes'); };
|
|
1084
|
+
$('calWiz').onclick = () => wizOpen('wires');
|
|
1085
|
+
|
|
1086
|
+
// ---------------------------------------------------------------- sketches (as firmware/panel.html)
|
|
1087
|
+
const NS = 'http://www.w3.org/2000/svg';
|
|
1088
|
+
function el(svg, tag, a) { const e = document.createElementNS(NS, tag); for (const k in a) e.setAttribute(k, a[k]); svg.appendChild(e); return e; }
|
|
1089
|
+
// side view, desk to the right. hl: the joint to pick out (1: the head, 2/3: an arm), the rest fades
|
|
1090
|
+
function drawSide(side, P, hl) {
|
|
1091
|
+
const [, pitch, aR, aL] = P;
|
|
1092
|
+
side.innerHTML = '';
|
|
1093
|
+
const ink = css('--ink'), cl = css('--clawd'), desk = css('--desk');
|
|
1094
|
+
const ox = 70, oy = 150, J2 = [0, 46.5];
|
|
1095
|
+
const pt = (y, z) => [ox + y * 1.1, oy - z * 1.1];
|
|
1096
|
+
const pp = (y, z) => { const r = -pitch * Math.PI / 180, dy = y - J2[0], dz = z - J2[1];
|
|
1097
|
+
return pt(J2[0] + dy * Math.cos(r) - dz * Math.sin(r), J2[1] + dy * Math.sin(r) + dz * Math.cos(r)); };
|
|
1098
|
+
const poly = (pts, fill, op = 1) => el(side, 'polygon', { points: pts.map(p => p.join(',')).join(' '), fill, opacity: op });
|
|
1099
|
+
poly([pt(29, 57), pt(79, 57), pt(79, 61), pt(29, 61)], desk);
|
|
1100
|
+
poly([pt(33, 61), pt(71, 61), pt(71, 67), pt(33, 67)], desk, .7);
|
|
1101
|
+
poly([pt(-22, 0), pt(30, 0), pt(30, 29), pt(-22, 29)], desk, .5);
|
|
1102
|
+
poly([pt(-26, 29.5), pt(26, 29.5), pt(26, 33.5), pt(-26, 33.5)], desk, .8);
|
|
1103
|
+
poly([pp(-18, 64.5), pp(18, 64.5), pp(18, 116.5), pp(-18, 116.5)], cl, hl >= 2 ? .45 : 1);
|
|
1104
|
+
poly([pp(-18, 35.5), pp(11, 35.5), pp(11, 64.5), pp(-18, 64.5)], cl, hl >= 2 ? .35 : .7);
|
|
1105
|
+
const sh = [-2.2, 90];
|
|
1106
|
+
[[aR, 2], [aL, 3]].forEach(([a, k]) => {
|
|
1107
|
+
const op = hl >= 2 ? (hl === k ? 1 : .18) : k === 2 ? 1 : .55;
|
|
1108
|
+
const r = a * Math.PI / 180, tip = [sh[0] + 26 * Math.sin(r), sh[1] - 26 * Math.cos(r)];
|
|
1109
|
+
const p0 = pp(...sh), p1 = pp(...tip);
|
|
1110
|
+
el(side, 'line', { x1: p0[0], y1: p0[1], x2: p1[0], y2: p1[1], stroke: hl === k ? cl : ink, 'stroke-width': 7, 'stroke-linecap': 'round', opacity: op,
|
|
1111
|
+
...(hl === k ? { filter: 'drop-shadow(0 0 2px rgba(0,0,0,.35))' } : {}) });
|
|
1112
|
+
});
|
|
1113
|
+
if (hl === 1) { // the arc the head travels
|
|
1114
|
+
const c = pt(...J2);
|
|
1115
|
+
el(side, 'path', { d: `M ${c[0] + 6} ${c[1] - 82} A 82 82 0 0 1 ${c[0] + 50} ${c[1] - 66}`, fill: 'none', stroke: cl, 'stroke-width': 2, 'stroke-dasharray': '4 4', opacity: .8 });
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
// top view, desk at the top; + yaw turns the head to Desky's left, which is your right when you face him
|
|
1119
|
+
function drawTop(top, yaw, label) {
|
|
1120
|
+
top.innerHTML = '';
|
|
1121
|
+
const ink = css('--ink'), cl = css('--clawd'), desk = css('--desk'), mut = css('--muted');
|
|
1122
|
+
const tx = 80, ty = 115;
|
|
1123
|
+
el(top, 'rect', { x: 14, y: 8, width: 132, height: 52, rx: 3, fill: desk, opacity: .6 });
|
|
1124
|
+
const g = el(top, 'g', { transform: `rotate(${-yaw} ${tx} ${ty})` });
|
|
1125
|
+
el(g, 'rect', { x: tx - 32, y: ty - 18, width: 64, height: 34, rx: 2, fill: cl });
|
|
1126
|
+
el(g, 'polygon', { points: `${tx - 8},${ty - 18} ${tx + 8},${ty - 18} ${tx},${ty - 30}`, fill: ink });
|
|
1127
|
+
if (label) el(top, 'text', { x: 80, y: 162, 'text-anchor': 'middle', fill: mut, 'font-size': 11, 'font-family': 'JetBrains Mono, monospace' }).textContent = (yaw > 0 ? '+' : '') + Math.round(yaw) + '°';
|
|
1128
|
+
}
|
|
1129
|
+
// front view: you face Desky, so his right arm is on your left. Yaw slides the eyes, pitch shrinks the head, an arm
|
|
1130
|
+
// raised forward looks shorter (cos), and past 90° it points up
|
|
1131
|
+
function drawFront(svg, P, hl) {
|
|
1132
|
+
const [yaw, pitch, aR, aL] = P;
|
|
1133
|
+
svg.innerHTML = '';
|
|
1134
|
+
const ink = css('--ink'), cl = css('--clawd'), desk = css('--desk');
|
|
1135
|
+
const cx = 80;
|
|
1136
|
+
el(svg, 'rect', { x: 20, y: 104, width: 120, height: 10, rx: 2, fill: desk, opacity: .55 });
|
|
1137
|
+
el(svg, 'rect', { x: cx - 26, y: 72, width: 52, height: 32, rx: 4, fill: cl, opacity: hl >= 2 ? .5 : .75 });
|
|
1138
|
+
const hh = 46 * Math.cos(pitch * Math.PI / 180) - 4 * Math.sin(pitch * Math.PI / 180);
|
|
1139
|
+
const shift = Math.sin(yaw * Math.PI / 180) * 14, sq = Math.cos(yaw * Math.PI / 180);
|
|
1140
|
+
const hw = 60 * (0.82 + 0.18 * sq);
|
|
1141
|
+
el(svg, 'rect', { x: cx - hw / 2, y: 72 - hh, width: hw, height: hh, rx: 5, fill: cl, opacity: hl >= 2 ? .5 : 1 });
|
|
1142
|
+
for (const ex of [-13, 13]) el(svg, 'rect', { x: cx + ex * sq + shift - 3.5, y: 72 - hh / 2 - 7 + pitch * .25, width: 7, height: 14, fill: '#000', opacity: hl >= 2 ? .5 : 1 });
|
|
1143
|
+
[[aR, 2, -1], [aL, 3, 1]].forEach(([a, k, side]) => {
|
|
1144
|
+
const sx = cx + side * 31, sy = 80, L = 26 * Math.cos(a * Math.PI / 180);
|
|
1145
|
+
const on = hl === k, op = hl >= 2 ? (on ? 1 : .2) : .8;
|
|
1146
|
+
el(svg, 'line', { x1: sx, y1: sy, x2: sx + side * 3, y2: sy + L, stroke: on ? cl : ink, 'stroke-width': 7, 'stroke-linecap': 'round', opacity: op });
|
|
1147
|
+
el(svg, 'circle', { cx: sx + side * 3, cy: sy + L, r: 4.5, fill: on ? cl : ink, opacity: op });
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
// a pose moving on a loop between two poses, for pictures that show what is about to happen
|
|
1152
|
+
function animate(draws, A, B) {
|
|
1153
|
+
let t0 = performance.now(), id = 0, alive = true;
|
|
1154
|
+
const ease = u => u < .5 ? 2 * u * u : 1 - Math.pow(-2 * u + 2, 2) / 2;
|
|
1155
|
+
const frame = now => {
|
|
1156
|
+
if (!alive) return;
|
|
1157
|
+
const T = 3000, u = ((now - t0) % T) / T;
|
|
1158
|
+
const k = u < .15 ? 0 : u < .45 ? ease((u - .15) / .3) : u < .7 ? 1 : u < 1 ? 1 - ease((u - .7) / .3) : 0;
|
|
1159
|
+
const P = A.map((a, i) => a + (B[i] - a) * k);
|
|
1160
|
+
draws.forEach(f => f(P));
|
|
1161
|
+
id = requestAnimationFrame(frame);
|
|
1162
|
+
};
|
|
1163
|
+
// drawn at once, so the picture is there before the first animation frame; without motion: the end pose, still
|
|
1164
|
+
if (matchMedia('(prefers-reduced-motion: reduce)').matches) { draws.forEach(f => f(B)); return () => {}; }
|
|
1165
|
+
t0 -= 3000 * .55; // start on the moved pose: what to look for comes first
|
|
1166
|
+
frame(performance.now());
|
|
1167
|
+
return () => { alive = false; cancelAnimationFrame(id); };
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
// ---------------------------------------------------------------- setup wizard
|
|
1171
|
+
const STEPS = ['hello', 'connect', 'color', 'check', 'wires', 'screen', 'j0', 'j1', 'j2', 'j3', 'done'];
|
|
1172
|
+
const STEP_NAMES = { hello: 'Привіт', connect: 'Підключення', color: 'Колір', check: 'Перевірка', wires: 'Проводи', screen: 'Екран',
|
|
1173
|
+
j0: 'Поворот', j1: 'Нахил', j2: 'Права рука', j3: 'Ліва рука', done: 'Готово' };
|
|
1174
|
+
const W = { step: null, sub: null, stop: null, retried: false, orig: null, onTick: null, onLine: null, onCal: null };
|
|
1175
|
+
const IC_OK = '<svg viewBox="0 0 16 16"><path d="M3.5 8.5l3 3 6-7"/></svg>', IC_BAD = '<svg viewBox="0 0 16 16"><path d="M4.5 4.5l7 7M11.5 4.5l-7 7"/></svg>';
|
|
1176
|
+
|
|
1177
|
+
function wizOpen(from) {
|
|
1178
|
+
$('wiz').hidden = false; showMode();
|
|
1179
|
+
drawFace($('wizLogo'), 'idle');
|
|
1180
|
+
go(from || 'hello');
|
|
1181
|
+
setTimeout(() => { const b = $('wizBody').querySelector('button.pri'); b && b.focus(); }, 50);
|
|
1182
|
+
}
|
|
1183
|
+
async function wizClose(finished) {
|
|
1184
|
+
if (W.stop) W.stop();
|
|
1185
|
+
revertCentre();
|
|
1186
|
+
W.step = null; W.onTick = W.onLine = W.onCal = null;
|
|
1187
|
+
$('wiz').hidden = true; showMode();
|
|
1188
|
+
place3d();
|
|
1189
|
+
try { localStorage.setItem('clawd.onboarded', '1'); } catch (e) {}
|
|
1190
|
+
if (connected) send('home');
|
|
1191
|
+
if (finished) showTab('home');
|
|
1192
|
+
}
|
|
1193
|
+
$('openWiz').onclick = () => wizOpen();
|
|
1194
|
+
$('wizClose').onclick = () => wizClose(false);
|
|
1195
|
+
document.addEventListener('keydown', e => { if (e.key === 'Escape' && !$('wiz').hidden) wizClose(false); });
|
|
1196
|
+
|
|
1197
|
+
function progress(name) {
|
|
1198
|
+
const i = STEPS.indexOf(name);
|
|
1199
|
+
$('wizBars').innerHTML = STEPS.map((s, k) => `<i class="${k < i || name === 'done' ? 'done' : k === i ? 'now' : ''}" title="${STEP_NAMES[s]}"></i>`).join('');
|
|
1200
|
+
$('wizLbl').innerHTML = `Крок ${i + 1} з ${STEPS.length} · <b>${STEP_NAMES[name]}</b>`;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
// one step: a stage on the left (pictures), the words and buttons on the right
|
|
1204
|
+
const SHOT3 = ['yaw', 'side', 'armR', 'armL'];
|
|
1205
|
+
function frame({ kick, title, lead, stage, scene, cap, body, foot }) {
|
|
1206
|
+
if (W.stop) { W.stop(); W.stop = null; }
|
|
1207
|
+
W.onTick = W.onLine = W.onCal = null;
|
|
1208
|
+
const s = document.createElement('div'); s.className = 'step';
|
|
1209
|
+
s.innerHTML = `<div class="stage"></div><div class="content"><div class="kick"></div><h2 id="wizTitle"></h2><p class="lead"></p><div class="slot"></div><div class="foot"></div></div>`;
|
|
1210
|
+
s.querySelector('.kick').textContent = kick || '';
|
|
1211
|
+
s.querySelector('h2').textContent = title;
|
|
1212
|
+
s.querySelector('.lead').innerHTML = lead || '';
|
|
1213
|
+
const stg = s.querySelector('.stage');
|
|
1214
|
+
let host = null;
|
|
1215
|
+
if (C3 && scene) {
|
|
1216
|
+
host = h('<div class="scene3d"><div class="tip3d"><svg viewBox="0 0 16 16"><path d="M13 8a5 5 0 1 1-1.5-3.5M13 2.5V5h-2.5"/></svg>потягни, щоб покрутити</div></div>');
|
|
1217
|
+
stg.classList.add('s3'); stg.appendChild(host);
|
|
1218
|
+
if (cap) { const c = h('<div class="cap3"><i></i></div>'); c.append(cap); stg.appendChild(c); }
|
|
1219
|
+
} else if (stage) stg.append(...[].concat(stage));
|
|
1220
|
+
if (body) s.querySelector('.slot').append(...[].concat(body));
|
|
1221
|
+
const f = s.querySelector('.foot');
|
|
1222
|
+
(foot || []).forEach(b => f.appendChild(b));
|
|
1223
|
+
$('wizBody').innerHTML = ''; $('wizBody').appendChild(s); $('wizBody').scrollTop = 0;
|
|
1224
|
+
if (C3) C3.glow(null);
|
|
1225
|
+
if (host) { C3.mount(host, scene.shot); if (scene.glow != null) C3.glow(scene.glow); if (scene.run) scene.run(C3); }
|
|
1226
|
+
return s;
|
|
1227
|
+
}
|
|
1228
|
+
function btn(text, cls, onclick) { const b = document.createElement('button'); b.type = 'button'; b.className = cls || ''; b.innerHTML = text; b.onclick = onclick; return b; }
|
|
1229
|
+
function spacer() { const s = document.createElement('span'); s.className = 'sp'; return s; }
|
|
1230
|
+
function h(html) { const d = document.createElement('div'); d.innerHTML = html.trim(); return d.firstElementChild; }
|
|
1231
|
+
function bigFace(state) { const s = document.createElementNS(NS, 'svg'); s.setAttribute('viewBox', '0 0 64 48'); s.setAttribute('class', 'big alive'); drawFace(s, state); return s; }
|
|
1232
|
+
function fig(viewBox, caption) {
|
|
1233
|
+
const f = document.createElement('figure'); f.className = 'fig';
|
|
1234
|
+
const s = document.createElementNS(NS, 'svg'); s.setAttribute('viewBox', viewBox); f.appendChild(s);
|
|
1235
|
+
if (caption) { const c = document.createElement('figcaption'); c.textContent = caption; f.appendChild(c); }
|
|
1236
|
+
return [f, s];
|
|
1237
|
+
}
|
|
1238
|
+
function views(...figs) { const v = document.createElement('div'); v.className = 'views' + (figs.length > 1 ? ' two' : ''); figs.forEach(f => v.appendChild(f)); return v; }
|
|
1239
|
+
function back(to) { return btn('Назад', 'ghost', () => go(to)); }
|
|
1240
|
+
const busy = async (b, fn) => { const all = [...$('wizBody').querySelectorAll('button')]; all.forEach(x => x.disabled = true); try { await fn(); } finally { all.forEach(x => x.disabled = false); W.onTick && W.onTick(); } };
|
|
1241
|
+
|
|
1242
|
+
// a centre the user moved but did not confirm ("Назад", closing): give the joint back what it had
|
|
1243
|
+
function revertCentre() {
|
|
1244
|
+
if (W.orig !== null && W.step && W.step[0] === 'j' && W.sub === 'centre') sendTrim(+W.step[1], W.orig);
|
|
1245
|
+
W.orig = null;
|
|
1246
|
+
}
|
|
1247
|
+
function go(name, sub) {
|
|
1248
|
+
revertCentre();
|
|
1249
|
+
W.step = name; W.sub = sub || null; W.retried = false;
|
|
1250
|
+
progress(name);
|
|
1251
|
+
const fixed = { hello: stHello, connect: stConnect, color: stColor, check: stCheck, wires: stWires, screen: stScreen, done: stDone }[name];
|
|
1252
|
+
if (fixed) fixed(); else if (sub === 'centre') stCentre(+name[1]); else stDir(+name[1]);
|
|
1253
|
+
}
|
|
1254
|
+
function wizTick() { if (!$('wiz').hidden && W.onTick) W.onTick(); }
|
|
1255
|
+
function wizLine(line) { if (!$('wiz').hidden && W.onLine) W.onLine(line); }
|
|
1256
|
+
function wizCal(j) { if (!$('wiz').hidden && W.onCal) W.onCal(j); }
|
|
1257
|
+
|
|
1258
|
+
// ---- 1. hello
|
|
1259
|
+
function stHello() {
|
|
1260
|
+
frame({
|
|
1261
|
+
kick: 'Ласкаво просимо до Desky Agent', title: 'Привіт! Я Desky',
|
|
1262
|
+
lead: 'Я сиджу біля ноутбука й показую, що зараз робить <b>Claude Code</b>: пише код, читає файли, чекає на твою відповідь або вже закінчив.<br><br>Налаштуймо мене разом: під\'єднаємо плату, перевіримо рухи й за потреби відкалібруємо. Це займе кілька хвилин.',
|
|
1263
|
+
stage: [bigFace('idle'), h('<div class="cap">Desky · робот, який живе поруч із Claude Code</div>')],
|
|
1264
|
+
scene: { shot: 'hero', run: c => c.state('idle', true) }, cap: 'Desky за роботою',
|
|
1265
|
+
foot: [btn('Пропустити', 'ghost', () => wizClose(false)), spacer(), btn('Почнімо', 'pri lg', () => go('connect'))],
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
// ---- 2. the cable
|
|
1270
|
+
function stConnect() {
|
|
1271
|
+
const rows = h(`<div class="checks">
|
|
1272
|
+
<div class="ck" data-k="app"><span class="ic"></span><div><b>Програма Desky Agent</b><small></small></div></div>
|
|
1273
|
+
<div class="ck" data-k="board"><span class="ic"></span><div><b>Плата</b><small></small></div></div>
|
|
1274
|
+
<div class="ck" data-k="servo"><span class="ic"></span><div><b>Серво</b><small></small></div></div></div>`);
|
|
1275
|
+
const next = btn('Далі', 'pri lg', () => go('color'));
|
|
1276
|
+
const face = bigFace('sleep');
|
|
1277
|
+
frame({
|
|
1278
|
+
kick: 'Підключення', title: 'Під\'єднай Desky',
|
|
1279
|
+
lead: 'Встав кабель <b>USB-C</b> у Desky і в комп\'ютер. Програма знайде плату сама, нічого обирати не треба.',
|
|
1280
|
+
stage: [face, h('<div class="cap">Чекаю на плату…</div>')], body: rows,
|
|
1281
|
+
scene: { shot: 'front', run: c => c.state(connected ? 'wake' : 'sleep', true) }, cap: 'Чекаю на плату…',
|
|
1282
|
+
foot: [back('hello'), spacer(), next],
|
|
1283
|
+
});
|
|
1284
|
+
const cap = $('wizBody').querySelector('.cap') || $('wizBody').querySelector('.cap3');
|
|
1285
|
+
let woke = false;
|
|
1286
|
+
W.onTick = () => {
|
|
1287
|
+
const set = (k, cls, text) => { const r = rows.querySelector(`[data-k="${k}"]`); r.className = 'ck ' + cls; r.querySelector('small').textContent = text;
|
|
1288
|
+
r.querySelector('.ic').innerHTML = cls === 'ok' ? IC_OK : cls === 'bad' ? IC_BAD : ''; };
|
|
1289
|
+
set('app', up ? 'ok' : 'bad', up ? 'працює на цьому комп\'ютері' : 'не відповідає: відкрий застосунок Desky ще раз');
|
|
1290
|
+
set('board', connected ? 'ok' : up ? 'wait' : '', connected ? 'на зв\'язку · ' + port : 'шукаю… перевір кабель (потрібен кабель з даними, не лише для заряджання)');
|
|
1291
|
+
const limp = beat && /отпущены/.test(beat);
|
|
1292
|
+
set('servo', beat ? 'ok' : connected ? 'wait' : '', beat ? (limp ? 'відпущені — натисну «тримати»' : 'тримають позу') : connected ? 'чекаю відповіді плати…' : '—');
|
|
1293
|
+
next.disabled = !connected;
|
|
1294
|
+
const say3 = t => { cap.lastChild.textContent = t; };
|
|
1295
|
+
if (connected && !woke) { woke = true; drawFace(face, 'idle'); say3('Плата на зв\'язку!'); C3 && C3.state('wake'); send('on'); }
|
|
1296
|
+
if (!connected && woke) { woke = false; drawFace(face, 'sleep'); say3('Чекаю на плату…'); C3 && C3.state('sleep'); }
|
|
1297
|
+
};
|
|
1298
|
+
W.onTick();
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
// ---- 3. which Desky is this: his colour
|
|
1302
|
+
function stColor() {
|
|
1303
|
+
const sw = swatches(h('<div class="swatches" role="radiogroup" aria-label="Колір Desky"></div>'));
|
|
1304
|
+
frame({
|
|
1305
|
+
kick: 'Колір', title: 'Якого кольору твій Desky?',
|
|
1306
|
+
lead: 'Обери колір корпусу. Під нього підлаштується застосунок, а Desky одразу перефарбує обличчя на своєму екрані.',
|
|
1307
|
+
stage: [bigFace('idle')], scene: { shot: 'hero', run: c => c.state('wake', true) }, cap: 'покрути його мишкою',
|
|
1308
|
+
body: [sw, h('<p class="hint">Колір можна змінити будь-коли в «Налаштуваннях».</p>')],
|
|
1309
|
+
foot: [back('connect'), spacer(), btn('Далі', 'pri lg', () => go('check'))],
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
// ---- 4. is everything fine already? (Desky leaves the factory calibrated)
|
|
1314
|
+
function stCheck() {
|
|
1315
|
+
const [f1, s1] = fig('0 0 160 120', 'в обличчя');
|
|
1316
|
+
W.stop = animate([P => drawFront(s1, P)], HOME, [0, 0, 150, 65]);
|
|
1317
|
+
const watch = h('<div class="watch"><span class="pulse"></span><span>Подивись на Desky: він помахає й стане рівно.</span></div>');
|
|
1318
|
+
const replay = btn('Показати ще раз', 'ghost', () => busy(replay, demo));
|
|
1319
|
+
const ok = btn('Так, усе рівно', 'pri', () => go('done'));
|
|
1320
|
+
const fix = btn('Ні, налаштуймо', '', () => go('wires'));
|
|
1321
|
+
frame({
|
|
1322
|
+
kick: 'Перевірка', title: 'Усе на своїх місцях?',
|
|
1323
|
+
lead: 'Desky калібрують ще на виробництві, тож зазвичай усе вже гаразд. Перевір: <b>голова дивиться прямо</b>, не нахилена, <b>руки висять рівно</b>, а помах був плавний.',
|
|
1324
|
+
stage: views(f1), body: [watch, h('<div class="row"></div>')],
|
|
1325
|
+
scene: { shot: 'front' }, cap: 'так має бути',
|
|
1326
|
+
foot: [back('color'), spacer(), fix, ok],
|
|
1327
|
+
});
|
|
1328
|
+
$('wizBody').querySelector('.slot .row').appendChild(replay);
|
|
1329
|
+
async function demo() { C3 && C3.state('wave', true); await send('on'); await send('home'); await send('wave'); await wait(3500); await send('home'); }
|
|
1330
|
+
busy(replay, demo);
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
// ---- 4. yaw and pitch on each other's pins? (calibrate.py, check_swap)
|
|
1334
|
+
function stWires() {
|
|
1335
|
+
const [fa, sa] = fig('0 0 160 120'), [fb, sb] = fig('0 0 240 170');
|
|
1336
|
+
const ca = btn('', 'choice yes', () => answer(true)), cb = btn('', 'choice', () => answer(false));
|
|
1337
|
+
ca.append(fa.firstChild, document.createTextNode('Повернув голову вбік'));
|
|
1338
|
+
cb.append(fb.firstChild, document.createTextNode('Кивнув уперед'));
|
|
1339
|
+
const stopA = animate([P => drawFront(sa, P)], HOME, [22, 0, 65, 65]);
|
|
1340
|
+
const stopB = animate([P => drawSide(sb, P, 1)], HOME, [0, 14, 65, 65]);
|
|
1341
|
+
const [ft, st] = fig('0 0 160 170', 'згори: має бути так');
|
|
1342
|
+
const stopT = animate([P => drawTop(st, P[0])], HOME, [22, 0, 65, 65]);
|
|
1343
|
+
W.stop = () => { stopA(); stopB(); stopT(); };
|
|
1344
|
+
const note = h('<div class="note" hidden></div>');
|
|
1345
|
+
const replay = btn('Показати ще раз', 'ghost', () => busy(replay, show));
|
|
1346
|
+
frame({
|
|
1347
|
+
kick: 'Калібрування · проводи', title: 'Поворот чи кивок?',
|
|
1348
|
+
lead: 'Desky спробує <b>повернути голову вбік</b>. Якщо серво поворота й нахилу під\'єднані навпаки, замість цього він кивне. Що він зробив?',
|
|
1349
|
+
stage: views(ft), body: [h('<div class="choices"></div>'), note, replay],
|
|
1350
|
+
scene: { shot: 'yaw', glow: 0, run: c => c.loop(HOME, [22, 0, 65, 65]) }, cap: 'має бути так: поворот убік',
|
|
1351
|
+
foot: [back('check'), spacer(), btn('Пропустити крок', 'ghost', () => go('screen'))],
|
|
1352
|
+
});
|
|
1353
|
+
const ch = $('wizBody').querySelector('.choices'); ch.append(ca, cb);
|
|
1354
|
+
async function show() { await send('on'); await send('home'); await send('j1 10'); await wait(1600); await send('home'); }
|
|
1355
|
+
async function answer(ok) {
|
|
1356
|
+
if (ok) { go('screen'); return; }
|
|
1357
|
+
if (W.retried) { note.hidden = false; note.className = 'note bad';
|
|
1358
|
+
note.textContent = 'Голова не повертається й після перестановки. Перевір серво J1 і J2 та їхні роз\'єми, потім пройди майстер ще раз.'; return; }
|
|
1359
|
+
W.retried = true;
|
|
1360
|
+
await busy(ca, async () => { await send('swap'); note.hidden = false; note.className = 'note'; note.textContent = 'Поміняв поворот і нахил місцями й зберіг. Дивись ще раз!'; await show(); });
|
|
1361
|
+
}
|
|
1362
|
+
busy(replay, show);
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
// ---- 5. the screen upside down? (calibrate.py, check_flip)
|
|
1366
|
+
function stScreen() {
|
|
1367
|
+
const P = PALETTE[COLOR];
|
|
1368
|
+
const up = (cls, d) => `<svg viewBox="0 0 64 40" class="${cls}"><rect width="64" height="40" rx="4" fill="${P.body}"/><g fill="${P.eye}">${
|
|
1369
|
+
[16, 48].map(x => [0, 1, 2, 3, 4, 5].map(i => `<rect x="${x - 6 + i}" y="${d ? 22 - i : 16 + i}" width="2" height="2"/><rect x="${x + i}" y="${d ? 17 + i : 21 - i}" width="2" height="2"/>`).join('')).join('')}</g></svg>`;
|
|
1370
|
+
const ca = btn(up('', true) + 'Кутиками вгору «^ ^»', 'choice yes', () => answer(true));
|
|
1371
|
+
const cb = btn(up('', false) + 'Кутиками вниз «v v»', 'choice', () => answer(false));
|
|
1372
|
+
const note = h('<div class="note" hidden></div>');
|
|
1373
|
+
frame({
|
|
1374
|
+
kick: 'Калібрування · екран', title: 'Подивись на екран',
|
|
1375
|
+
lead: 'Зараз на екрані Desky <b>усміхнені очі-галочки</b>. Якщо вони перевернуті, екран стоїть догори дриґом. Як вони виглядають?',
|
|
1376
|
+
stage: [bigFace('happy'), h('<div class="cap">так має бути</div>')], body: [h('<div class="choices"></div>'), note],
|
|
1377
|
+
scene: { shot: 'face', run: c => { c.pose(HOME); c.face('HAPPY'); } }, cap: 'так має бути',
|
|
1378
|
+
foot: [back('wires'), spacer(), btn('Пропустити крок', 'ghost', () => { send('face eyes'); go('j0'); })],
|
|
1379
|
+
});
|
|
1380
|
+
$('wizBody').querySelector('.choices').append(ca, cb);
|
|
1381
|
+
send('face happy');
|
|
1382
|
+
async function answer(ok) {
|
|
1383
|
+
if (ok) { await send('face eyes'); go('j0'); return; }
|
|
1384
|
+
if (W.retried) { note.hidden = false; note.className = 'note bad'; note.textContent = 'Екран і досі перевернутий? Перевір, чи на ньому взагалі щось видно, і спробуй ще раз.'; return; }
|
|
1385
|
+
W.retried = true;
|
|
1386
|
+
await busy(ca, async () => { await send('flip'); await send('face happy'); note.hidden = false; note.className = 'note'; note.textContent = 'Перевернув екран і зберіг. А тепер?'; });
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
// ---- 6. a joint's direction (calibrate.py, direction)
|
|
1391
|
+
function stDir(j) {
|
|
1392
|
+
const jj = J[j], A = HOME, B = poseWith(j, jj.base + jj.plus);
|
|
1393
|
+
const [f1, s1] = fig('0 0 160 120', 'в обличчя');
|
|
1394
|
+
const [f2, s2] = j === 0 ? fig('0 0 160 170', 'згори') : fig('0 0 240 170', 'збоку');
|
|
1395
|
+
W.stop = animate([P => drawFront(s1, P, j), P => j === 0 ? drawTop(s2, P[0]) : drawSide(s2, P, j)], A, B);
|
|
1396
|
+
const note = h('<div class="note" hidden></div>');
|
|
1397
|
+
const replay = btn('Показати ще раз', 'ghost', () => busy(replay, show));
|
|
1398
|
+
const yes = btn('Так, саме так', 'choice yes', () => answer(true)), no = btn('Ні, в інший бік', 'choice', () => answer(false));
|
|
1399
|
+
frame({
|
|
1400
|
+
kick: `Калібрування · ${jj.short} · напрямок`, title: `${jj.name}: куди рухається?`,
|
|
1401
|
+
lead: `Desky зробить невеликий рух, як на малюнку. ${jj.plusText}`,
|
|
1402
|
+
stage: views(f1, f2), body: [h('<div class="choices"></div>'), note, replay],
|
|
1403
|
+
scene: { shot: SHOT3[j], glow: j, run: c => c.loop(A, B) }, cap: 'має бути так',
|
|
1404
|
+
foot: [back(j === 0 ? 'screen' : 'j' + (j - 1)), spacer(), btn('Пропустити суглоб', 'ghost', () => go(j < 3 ? 'j' + (j + 1) : 'done'))],
|
|
1405
|
+
});
|
|
1406
|
+
$('wizBody').querySelector('.choices').append(yes, no);
|
|
1407
|
+
async function show() { await send('on'); await send('home'); await send('j' + jj.n + ' ' + (jj.base + jj.plus)); await wait(1500); await send('home'); }
|
|
1408
|
+
async function answer(ok) {
|
|
1409
|
+
if (ok) { await send('home'); go('j' + j, 'centre'); return; }
|
|
1410
|
+
if (W.retried) { note.hidden = false; note.className = 'note bad';
|
|
1411
|
+
note.textContent = `${jj.name} і після розвороту рухається не туди. Можливо, рухається не той суглоб: перевір роз'єми серво.`; return; }
|
|
1412
|
+
W.retried = true;
|
|
1413
|
+
await busy(yes, async () => { await send('inv j' + jj.n); calDirty(true); note.hidden = false; note.className = 'note'; note.textContent = 'Розвернув напрямок. Дивись ще раз!'; await show(); });
|
|
1414
|
+
}
|
|
1415
|
+
busy(replay, show);
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
// ---- 7. a joint's centre, live on a dial
|
|
1419
|
+
function stCentre(j) {
|
|
1420
|
+
const jj = J[j];
|
|
1421
|
+
const [f1, s1] = fig('0 0 160 120', 'в обличчя: має бути так');
|
|
1422
|
+
const [f2, s2] = j === 0 ? fig('0 0 160 170', 'згори') : fig('0 0 240 170', 'збоку');
|
|
1423
|
+
const ref = poseWith(j, jj.ref);
|
|
1424
|
+
drawFront(s1, ref, j); j === 0 ? drawTop(s2, 0) : drawSide(s2, ref, j);
|
|
1425
|
+
W.orig = CAL[j].trim;
|
|
1426
|
+
const dial = makeDial(j);
|
|
1427
|
+
const done = btn('Рівно, далі', 'pri lg', async () => {
|
|
1428
|
+
await busy(done, async () => { await send('save'); calDirty(false); W.orig = null; await send('home'); });
|
|
1429
|
+
go(j < 3 ? 'j' + (j + 1) : 'done');
|
|
1430
|
+
});
|
|
1431
|
+
frame({
|
|
1432
|
+
kick: `Калібрування · ${jj.short} · центр`, title: 'Виставимо нуль',
|
|
1433
|
+
lead: `Desky став у нульове положення. Тягни повзунок, поки ${jj.refText}. Desky рухається разом із повзунком.`,
|
|
1434
|
+
stage: views(f1, f2), body: [dial],
|
|
1435
|
+
scene: { shot: j === 0 ? 'front' : SHOT3[j], glow: j, run: c => c.pose(ref) }, cap: 'нуль: має бути так',
|
|
1436
|
+
foot: [back('j' + j), spacer(), done],
|
|
1437
|
+
});
|
|
1438
|
+
W.onCal = k => { if (k === j) dial.sync(); };
|
|
1439
|
+
(async () => { await send('on'); await send('home'); if (jj.ref !== jj.base) await send('pose ' + ref.join(' ')); await send('cal', true); })();
|
|
1440
|
+
setTimeout(() => dial.querySelector('input').focus(), 80);
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
// ---- 8. done
|
|
1444
|
+
function stDone() {
|
|
1445
|
+
const face = bigFace('happy');
|
|
1446
|
+
const conf = document.createElement('div'); conf.className = 'confetti';
|
|
1447
|
+
const colors = [PALETTE[COLOR].body, css('--clawd'), '#F2B48F', '#3C8A55', '#9FC6F0', '#E6C15A'];
|
|
1448
|
+
for (let i = 0; i < 46; i++) { const c = document.createElement('i'); c.style.left = Math.random() * 100 + '%'; c.style.background = colors[i % colors.length];
|
|
1449
|
+
c.style.animationDelay = Math.random() * .8 + 's'; c.style.transform = `rotate(${Math.random() * 180}deg)`; conf.appendChild(c); }
|
|
1450
|
+
const s = frame({
|
|
1451
|
+
kick: 'Готово', title: 'Desky готовий до роботи!',
|
|
1452
|
+
lead: 'Усе збережено в платі. Тепер просто працюй у <b>Claude Code</b>, а Desky показуватиме, що відбувається: працює, читає, чекає на тебе.<br><br>Майстер завжди можна відкрити знову в боковій панелі.',
|
|
1453
|
+
stage: [face], scene: { shot: 'hero', run: c => c.state('done', true) }, cap: 'Desky радіє',
|
|
1454
|
+
foot: [spacer(), btn('Відкрити пульт', 'pri lg', () => wizClose(true))],
|
|
1455
|
+
});
|
|
1456
|
+
s.querySelector('.stage').style.position = 'relative'; s.querySelector('.stage').appendChild(conf);
|
|
1457
|
+
if (connected) (async () => { if (dirty) await send('save'); calDirty(false); await send('home'); await send('happy'); await send('sound done', true); })();
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
let tab = 'home';
|
|
1461
|
+
try { tab = localStorage.getItem('clawd.tab') || 'home'; } catch (e) {}
|
|
1462
|
+
if (location.hash) tab = location.hash.slice(1);
|
|
1463
|
+
showTab(document.querySelector('[data-page="' + tab + '"]') ? tab : 'home');
|
|
1464
|
+
['face', 'logo', 'bigface'].forEach(id => drawFace($(id), 'idle'));
|
|
1465
|
+
buildJoints(); calDirty(false); showMode(); refresh(); pollStatus(); pollLines();
|
|
1466
|
+
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => { applyColor(COLOR); refresh(); buildJoints(); });
|
|
1467
|
+
})();
|
|
1468
|
+
</script>
|
|
1469
|
+
</body>
|
|
1470
|
+
</html>
|