desky-agent 0.0.0-stage → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +56 -2
  3. package/assets/clawd.ico +0 -0
  4. package/assets/clawd.png +0 -0
  5. package/bin/cli.js +216 -0
  6. package/electron/icons.js +79 -0
  7. package/electron/main.js +244 -0
  8. package/firmware/boot_app0.bin +0 -0
  9. package/firmware/bootloader.bin +0 -0
  10. package/firmware/firmware.bin +0 -0
  11. package/firmware/manifest.json +33 -0
  12. package/firmware/partitions.bin +0 -0
  13. package/package.json +41 -6
  14. package/src/autostart.js +106 -0
  15. package/src/board.js +69 -0
  16. package/src/core.js +193 -0
  17. package/src/daemon.js +522 -0
  18. package/src/firmware.js +207 -0
  19. package/src/flasher.js +113 -0
  20. package/src/hook.js +92 -0
  21. package/src/install.js +418 -0
  22. package/src/link.js +207 -0
  23. package/src/paths.js +44 -0
  24. package/src/release.js +131 -0
  25. package/src/selfupdate.js +58 -0
  26. package/src/updater.js +138 -0
  27. package/src/webserial.js +130 -0
  28. package/ui/app.html +1519 -0
  29. package/ui/clawd3d.js +377 -0
  30. package/ui/models/A04_cap_J2.stl +0 -0
  31. package/ui/models/A04_cap_J3.stl +0 -0
  32. package/ui/models/A04_cap_J4.stl +0 -0
  33. package/ui/models/B0_base.stl +0 -0
  34. package/ui/models/B1_body.stl +0 -0
  35. package/ui/models/B2_face_plate.stl +0 -0
  36. package/ui/models/B3_side_left.stl +0 -0
  37. package/ui/models/B4_side_right.stl +0 -0
  38. package/ui/models/C1_column.stl +0 -0
  39. package/ui/models/C2_column_lid.stl +0 -0
  40. package/ui/models/D1_desk_frame.stl +0 -0
  41. package/ui/models/D2_desk_top.stl +0 -0
  42. package/ui/models/L1_laptop.stl +0 -0
  43. package/ui/models/P1_mug.stl +0 -0
  44. package/ui/models/P2_plant.stl +0 -0
  45. package/ui/models/R1_arm_left.stl +0 -0
  46. package/ui/models/R2_arm_right.stl +0 -0
  47. package/ui/models/S1_seat.stl +0 -0
  48. package/ui/models/S2_spacer.stl +0 -0
  49. package/ui/vendor/OrbitControls.js +1532 -0
  50. package/ui/vendor/RoomEnvironment.js +144 -0
  51. package/ui/vendor/STLLoader.js +410 -0
  52. package/ui/vendor/three.LICENSE +21 -0
  53. package/ui/vendor/three.module.min.js +6 -0
@@ -0,0 +1,144 @@
1
+ /**
2
+ * https://github.com/google/model-viewer/blob/master/packages/model-viewer/src/three-components/EnvironmentScene.ts
3
+ */
4
+
5
+ import {
6
+ BackSide,
7
+ BoxGeometry,
8
+ Mesh,
9
+ MeshBasicMaterial,
10
+ MeshStandardMaterial,
11
+ PointLight,
12
+ Scene,
13
+ } from 'three';
14
+
15
+ class RoomEnvironment extends Scene {
16
+
17
+ constructor( renderer = null ) {
18
+
19
+ super();
20
+
21
+ const geometry = new BoxGeometry();
22
+ geometry.deleteAttribute( 'uv' );
23
+
24
+ const roomMaterial = new MeshStandardMaterial( { side: BackSide } );
25
+ const boxMaterial = new MeshStandardMaterial();
26
+
27
+ const mainLight = new PointLight( 0xffffff, 900, 28, 2 );
28
+ mainLight.position.set( 0.418, 16.199, 0.300 );
29
+ this.add( mainLight );
30
+
31
+ const room = new Mesh( geometry, roomMaterial );
32
+ room.position.set( - 0.757, 13.219, 0.717 );
33
+ room.scale.set( 31.713, 28.305, 28.591 );
34
+ this.add( room );
35
+
36
+ const box1 = new Mesh( geometry, boxMaterial );
37
+ box1.position.set( - 10.906, 2.009, 1.846 );
38
+ box1.rotation.set( 0, - 0.195, 0 );
39
+ box1.scale.set( 2.328, 7.905, 4.651 );
40
+ this.add( box1 );
41
+
42
+ const box2 = new Mesh( geometry, boxMaterial );
43
+ box2.position.set( - 5.607, - 0.754, - 0.758 );
44
+ box2.rotation.set( 0, 0.994, 0 );
45
+ box2.scale.set( 1.970, 1.534, 3.955 );
46
+ this.add( box2 );
47
+
48
+ const box3 = new Mesh( geometry, boxMaterial );
49
+ box3.position.set( 6.167, 0.857, 7.803 );
50
+ box3.rotation.set( 0, 0.561, 0 );
51
+ box3.scale.set( 3.927, 6.285, 3.687 );
52
+ this.add( box3 );
53
+
54
+ const box4 = new Mesh( geometry, boxMaterial );
55
+ box4.position.set( - 2.017, 0.018, 6.124 );
56
+ box4.rotation.set( 0, 0.333, 0 );
57
+ box4.scale.set( 2.002, 4.566, 2.064 );
58
+ this.add( box4 );
59
+
60
+ const box5 = new Mesh( geometry, boxMaterial );
61
+ box5.position.set( 2.291, - 0.756, - 2.621 );
62
+ box5.rotation.set( 0, - 0.286, 0 );
63
+ box5.scale.set( 1.546, 1.552, 1.496 );
64
+ this.add( box5 );
65
+
66
+ const box6 = new Mesh( geometry, boxMaterial );
67
+ box6.position.set( - 2.193, - 0.369, - 5.547 );
68
+ box6.rotation.set( 0, 0.516, 0 );
69
+ box6.scale.set( 3.875, 3.487, 2.986 );
70
+ this.add( box6 );
71
+
72
+
73
+ // -x right
74
+ const light1 = new Mesh( geometry, createAreaLightMaterial( 50 ) );
75
+ light1.position.set( - 16.116, 14.37, 8.208 );
76
+ light1.scale.set( 0.1, 2.428, 2.739 );
77
+ this.add( light1 );
78
+
79
+ // -x left
80
+ const light2 = new Mesh( geometry, createAreaLightMaterial( 50 ) );
81
+ light2.position.set( - 16.109, 18.021, - 8.207 );
82
+ light2.scale.set( 0.1, 2.425, 2.751 );
83
+ this.add( light2 );
84
+
85
+ // +x
86
+ const light3 = new Mesh( geometry, createAreaLightMaterial( 17 ) );
87
+ light3.position.set( 14.904, 12.198, - 1.832 );
88
+ light3.scale.set( 0.15, 4.265, 6.331 );
89
+ this.add( light3 );
90
+
91
+ // +z
92
+ const light4 = new Mesh( geometry, createAreaLightMaterial( 43 ) );
93
+ light4.position.set( - 0.462, 8.89, 14.520 );
94
+ light4.scale.set( 4.38, 5.441, 0.088 );
95
+ this.add( light4 );
96
+
97
+ // -z
98
+ const light5 = new Mesh( geometry, createAreaLightMaterial( 20 ) );
99
+ light5.position.set( 3.235, 11.486, - 12.541 );
100
+ light5.scale.set( 2.5, 2.0, 0.1 );
101
+ this.add( light5 );
102
+
103
+ // +y
104
+ const light6 = new Mesh( geometry, createAreaLightMaterial( 100 ) );
105
+ light6.position.set( 0.0, 20.0, 0.0 );
106
+ light6.scale.set( 1.0, 0.1, 1.0 );
107
+ this.add( light6 );
108
+
109
+ }
110
+
111
+ dispose() {
112
+
113
+ const resources = new Set();
114
+
115
+ this.traverse( ( object ) => {
116
+
117
+ if ( object.isMesh ) {
118
+
119
+ resources.add( object.geometry );
120
+ resources.add( object.material );
121
+
122
+ }
123
+
124
+ } );
125
+
126
+ for ( const resource of resources ) {
127
+
128
+ resource.dispose();
129
+
130
+ }
131
+
132
+ }
133
+
134
+ }
135
+
136
+ function createAreaLightMaterial( intensity ) {
137
+
138
+ const material = new MeshBasicMaterial();
139
+ material.color.setScalar( intensity );
140
+ return material;
141
+
142
+ }
143
+
144
+ export { RoomEnvironment };
@@ -0,0 +1,410 @@
1
+ import {
2
+ BufferAttribute,
3
+ BufferGeometry,
4
+ Color,
5
+ FileLoader,
6
+ Float32BufferAttribute,
7
+ Loader,
8
+ Vector3
9
+ } from 'three';
10
+
11
+ /**
12
+ * Description: A THREE loader for STL ASCII files, as created by Solidworks and other CAD programs.
13
+ *
14
+ * Supports both binary and ASCII encoded files, with automatic detection of type.
15
+ *
16
+ * The loader returns a non-indexed buffer geometry.
17
+ *
18
+ * Limitations:
19
+ * Binary decoding supports "Magics" color format (http://en.wikipedia.org/wiki/STL_(file_format)#Color_in_binary_STL).
20
+ * There is perhaps some question as to how valid it is to always assume little-endian-ness.
21
+ * ASCII decoding assumes file is UTF-8.
22
+ *
23
+ * Usage:
24
+ * const loader = new STLLoader();
25
+ * loader.load( './models/stl/slotted_disk.stl', function ( geometry ) {
26
+ * scene.add( new THREE.Mesh( geometry ) );
27
+ * });
28
+ *
29
+ * For binary STLs geometry might contain colors for vertices. To use it:
30
+ * // use the same code to load STL as above
31
+ * if (geometry.hasColors) {
32
+ * material = new THREE.MeshPhongMaterial({ opacity: geometry.alpha, vertexColors: true });
33
+ * } else { .... }
34
+ * const mesh = new THREE.Mesh( geometry, material );
35
+ *
36
+ * For ASCII STLs containing multiple solids, each solid is assigned to a different group.
37
+ * Groups can be used to assign a different color by defining an array of materials with the same length of
38
+ * geometry.groups and passing it to the Mesh constructor:
39
+ *
40
+ * const mesh = new THREE.Mesh( geometry, material );
41
+ *
42
+ * For example:
43
+ *
44
+ * const materials = [];
45
+ * const nGeometryGroups = geometry.groups.length;
46
+ *
47
+ * const colorMap = ...; // Some logic to index colors.
48
+ *
49
+ * for (let i = 0; i < nGeometryGroups; i++) {
50
+ *
51
+ * const material = new THREE.MeshPhongMaterial({
52
+ * color: colorMap[i],
53
+ * wireframe: false
54
+ * });
55
+ *
56
+ * }
57
+ *
58
+ * materials.push(material);
59
+ * const mesh = new THREE.Mesh(geometry, materials);
60
+ */
61
+
62
+
63
+ class STLLoader extends Loader {
64
+
65
+ constructor( manager ) {
66
+
67
+ super( manager );
68
+
69
+ }
70
+
71
+ load( url, onLoad, onProgress, onError ) {
72
+
73
+ const scope = this;
74
+
75
+ const loader = new FileLoader( this.manager );
76
+ loader.setPath( this.path );
77
+ loader.setResponseType( 'arraybuffer' );
78
+ loader.setRequestHeader( this.requestHeader );
79
+ loader.setWithCredentials( this.withCredentials );
80
+
81
+ loader.load( url, function ( text ) {
82
+
83
+ try {
84
+
85
+ onLoad( scope.parse( text ) );
86
+
87
+ } catch ( e ) {
88
+
89
+ if ( onError ) {
90
+
91
+ onError( e );
92
+
93
+ } else {
94
+
95
+ console.error( e );
96
+
97
+ }
98
+
99
+ scope.manager.itemError( url );
100
+
101
+ }
102
+
103
+ }, onProgress, onError );
104
+
105
+ }
106
+
107
+ parse( data ) {
108
+
109
+ function isBinary( data ) {
110
+
111
+ const reader = new DataView( data );
112
+ const face_size = ( 32 / 8 * 3 ) + ( ( 32 / 8 * 3 ) * 3 ) + ( 16 / 8 );
113
+ const n_faces = reader.getUint32( 80, true );
114
+ const expect = 80 + ( 32 / 8 ) + ( n_faces * face_size );
115
+
116
+ if ( expect === reader.byteLength ) {
117
+
118
+ return true;
119
+
120
+ }
121
+
122
+ // An ASCII STL data must begin with 'solid ' as the first six bytes.
123
+ // However, ASCII STLs lacking the SPACE after the 'd' are known to be
124
+ // plentiful. So, check the first 5 bytes for 'solid'.
125
+
126
+ // Several encodings, such as UTF-8, precede the text with up to 5 bytes:
127
+ // https://en.wikipedia.org/wiki/Byte_order_mark#Byte_order_marks_by_encoding
128
+ // Search for "solid" to start anywhere after those prefixes.
129
+
130
+ // US-ASCII ordinal values for 's', 'o', 'l', 'i', 'd'
131
+
132
+ const solid = [ 115, 111, 108, 105, 100 ];
133
+
134
+ for ( let off = 0; off < 5; off ++ ) {
135
+
136
+ // If "solid" text is matched to the current offset, declare it to be an ASCII STL.
137
+
138
+ if ( matchDataViewAt( solid, reader, off ) ) return false;
139
+
140
+ }
141
+
142
+ // Couldn't find "solid" text at the beginning; it is binary STL.
143
+
144
+ return true;
145
+
146
+ }
147
+
148
+ function matchDataViewAt( query, reader, offset ) {
149
+
150
+ // Check if each byte in query matches the corresponding byte from the current offset
151
+
152
+ for ( let i = 0, il = query.length; i < il; i ++ ) {
153
+
154
+ if ( query[ i ] !== reader.getUint8( offset + i ) ) return false;
155
+
156
+ }
157
+
158
+ return true;
159
+
160
+ }
161
+
162
+ function parseBinary( data ) {
163
+
164
+ const reader = new DataView( data );
165
+ const faces = reader.getUint32( 80, true );
166
+
167
+ let r, g, b, hasColors = false, colors;
168
+ let defaultR, defaultG, defaultB, alpha;
169
+
170
+ // process STL header
171
+ // check for default color in header ("COLOR=rgba" sequence).
172
+
173
+ for ( let index = 0; index < 80 - 10; index ++ ) {
174
+
175
+ if ( ( reader.getUint32( index, false ) == 0x434F4C4F /*COLO*/ ) &&
176
+ ( reader.getUint8( index + 4 ) == 0x52 /*'R'*/ ) &&
177
+ ( reader.getUint8( index + 5 ) == 0x3D /*'='*/ ) ) {
178
+
179
+ hasColors = true;
180
+ colors = new Float32Array( faces * 3 * 3 );
181
+
182
+ defaultR = reader.getUint8( index + 6 ) / 255;
183
+ defaultG = reader.getUint8( index + 7 ) / 255;
184
+ defaultB = reader.getUint8( index + 8 ) / 255;
185
+ alpha = reader.getUint8( index + 9 ) / 255;
186
+
187
+ }
188
+
189
+ }
190
+
191
+ const dataOffset = 84;
192
+ const faceLength = 12 * 4 + 2;
193
+
194
+ const geometry = new BufferGeometry();
195
+
196
+ const vertices = new Float32Array( faces * 3 * 3 );
197
+ const normals = new Float32Array( faces * 3 * 3 );
198
+
199
+ const color = new Color();
200
+
201
+ for ( let face = 0; face < faces; face ++ ) {
202
+
203
+ const start = dataOffset + face * faceLength;
204
+ const normalX = reader.getFloat32( start, true );
205
+ const normalY = reader.getFloat32( start + 4, true );
206
+ const normalZ = reader.getFloat32( start + 8, true );
207
+
208
+ if ( hasColors ) {
209
+
210
+ const packedColor = reader.getUint16( start + 48, true );
211
+
212
+ if ( ( packedColor & 0x8000 ) === 0 ) {
213
+
214
+ // facet has its own unique color
215
+
216
+ r = ( packedColor & 0x1F ) / 31;
217
+ g = ( ( packedColor >> 5 ) & 0x1F ) / 31;
218
+ b = ( ( packedColor >> 10 ) & 0x1F ) / 31;
219
+
220
+ } else {
221
+
222
+ r = defaultR;
223
+ g = defaultG;
224
+ b = defaultB;
225
+
226
+ }
227
+
228
+ }
229
+
230
+ for ( let i = 1; i <= 3; i ++ ) {
231
+
232
+ const vertexstart = start + i * 12;
233
+ const componentIdx = ( face * 3 * 3 ) + ( ( i - 1 ) * 3 );
234
+
235
+ vertices[ componentIdx ] = reader.getFloat32( vertexstart, true );
236
+ vertices[ componentIdx + 1 ] = reader.getFloat32( vertexstart + 4, true );
237
+ vertices[ componentIdx + 2 ] = reader.getFloat32( vertexstart + 8, true );
238
+
239
+ normals[ componentIdx ] = normalX;
240
+ normals[ componentIdx + 1 ] = normalY;
241
+ normals[ componentIdx + 2 ] = normalZ;
242
+
243
+ if ( hasColors ) {
244
+
245
+ color.set( r, g, b ).convertSRGBToLinear();
246
+
247
+ colors[ componentIdx ] = color.r;
248
+ colors[ componentIdx + 1 ] = color.g;
249
+ colors[ componentIdx + 2 ] = color.b;
250
+
251
+ }
252
+
253
+ }
254
+
255
+ }
256
+
257
+ geometry.setAttribute( 'position', new BufferAttribute( vertices, 3 ) );
258
+ geometry.setAttribute( 'normal', new BufferAttribute( normals, 3 ) );
259
+
260
+ if ( hasColors ) {
261
+
262
+ geometry.setAttribute( 'color', new BufferAttribute( colors, 3 ) );
263
+ geometry.hasColors = true;
264
+ geometry.alpha = alpha;
265
+
266
+ }
267
+
268
+ return geometry;
269
+
270
+ }
271
+
272
+ function parseASCII( data ) {
273
+
274
+ const geometry = new BufferGeometry();
275
+ const patternSolid = /solid([\s\S]*?)endsolid/g;
276
+ const patternFace = /facet([\s\S]*?)endfacet/g;
277
+ const patternName = /solid\s(.+)/;
278
+ let faceCounter = 0;
279
+
280
+ const patternFloat = /[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source;
281
+ const patternVertex = new RegExp( 'vertex' + patternFloat + patternFloat + patternFloat, 'g' );
282
+ const patternNormal = new RegExp( 'normal' + patternFloat + patternFloat + patternFloat, 'g' );
283
+
284
+ const vertices = [];
285
+ const normals = [];
286
+ const groupNames = [];
287
+
288
+ const normal = new Vector3();
289
+
290
+ let result;
291
+
292
+ let groupCount = 0;
293
+ let startVertex = 0;
294
+ let endVertex = 0;
295
+
296
+ while ( ( result = patternSolid.exec( data ) ) !== null ) {
297
+
298
+ startVertex = endVertex;
299
+
300
+ const solid = result[ 0 ];
301
+
302
+ const name = ( result = patternName.exec( solid ) ) !== null ? result[ 1 ] : '';
303
+ groupNames.push( name );
304
+
305
+ while ( ( result = patternFace.exec( solid ) ) !== null ) {
306
+
307
+ let vertexCountPerFace = 0;
308
+ let normalCountPerFace = 0;
309
+
310
+ const text = result[ 0 ];
311
+
312
+ while ( ( result = patternNormal.exec( text ) ) !== null ) {
313
+
314
+ normal.x = parseFloat( result[ 1 ] );
315
+ normal.y = parseFloat( result[ 2 ] );
316
+ normal.z = parseFloat( result[ 3 ] );
317
+ normalCountPerFace ++;
318
+
319
+ }
320
+
321
+ while ( ( result = patternVertex.exec( text ) ) !== null ) {
322
+
323
+ vertices.push( parseFloat( result[ 1 ] ), parseFloat( result[ 2 ] ), parseFloat( result[ 3 ] ) );
324
+ normals.push( normal.x, normal.y, normal.z );
325
+ vertexCountPerFace ++;
326
+ endVertex ++;
327
+
328
+ }
329
+
330
+ // every face have to own ONE valid normal
331
+
332
+ if ( normalCountPerFace !== 1 ) {
333
+
334
+ console.error( 'THREE.STLLoader: Something isn\'t right with the normal of face number ' + faceCounter );
335
+
336
+ }
337
+
338
+ // each face have to own THREE valid vertices
339
+
340
+ if ( vertexCountPerFace !== 3 ) {
341
+
342
+ console.error( 'THREE.STLLoader: Something isn\'t right with the vertices of face number ' + faceCounter );
343
+
344
+ }
345
+
346
+ faceCounter ++;
347
+
348
+ }
349
+
350
+ const start = startVertex;
351
+ const count = endVertex - startVertex;
352
+
353
+ geometry.userData.groupNames = groupNames;
354
+
355
+ geometry.addGroup( start, count, groupCount );
356
+ groupCount ++;
357
+
358
+ }
359
+
360
+ geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
361
+ geometry.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
362
+
363
+ return geometry;
364
+
365
+ }
366
+
367
+ function ensureString( buffer ) {
368
+
369
+ if ( typeof buffer !== 'string' ) {
370
+
371
+ return new TextDecoder().decode( buffer );
372
+
373
+ }
374
+
375
+ return buffer;
376
+
377
+ }
378
+
379
+ function ensureBinary( buffer ) {
380
+
381
+ if ( typeof buffer === 'string' ) {
382
+
383
+ const array_buffer = new Uint8Array( buffer.length );
384
+ for ( let i = 0; i < buffer.length; i ++ ) {
385
+
386
+ array_buffer[ i ] = buffer.charCodeAt( i ) & 0xff; // implicitly assumes little-endian
387
+
388
+ }
389
+
390
+ return array_buffer.buffer || array_buffer;
391
+
392
+ } else {
393
+
394
+ return buffer;
395
+
396
+ }
397
+
398
+ }
399
+
400
+ // start
401
+
402
+ const binData = ensureBinary( data );
403
+
404
+ return isBinary( binData ) ? parseBinary( binData ) : parseASCII( ensureString( data ) );
405
+
406
+ }
407
+
408
+ }
409
+
410
+ export { STLLoader };
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright © 2010-2024 three.js authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.