dsh-quay-bot 1.0.2 → 1.0.4

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 (59) hide show
  1. package/README.md +28 -105
  2. package/botscreen/requirements.txt +1 -1
  3. package/client.js +3 -2
  4. package/cordis.patch.yml +1 -1
  5. package/host/api.js +4 -0
  6. package/host/remote.js +285 -8
  7. package/host/screen.js +22 -86
  8. package/package.json +35 -32
  9. package/remote/bin/dsh-remote.mjs +435 -0
  10. package/remote/package.json +27 -0
  11. package/remote/src/config.mjs +183 -0
  12. package/remote/src/crypto.mjs +220 -0
  13. package/remote/src/keys.mjs +226 -0
  14. package/remote/src/proxy.mjs +1028 -0
  15. package/remote/src/sessions.mjs +163 -0
  16. package/remote/src/shim.js +838 -0
  17. package/remote/src/supervisor.mjs +207 -0
  18. package/remote/src/tunnel.mjs +533 -0
  19. package/remote/src/upstream.mjs +403 -0
  20. package/remote/src/util.mjs +149 -0
  21. package/remote/src/ws.mjs +313 -0
  22. package/LICENSE +0 -21
  23. package/avatar/build.mjs +0 -81
  24. package/avatar/gallery/droid.json +0 -14
  25. package/avatar/gallery/ghost.json +0 -14
  26. package/avatar/gallery/grok-pod.json +0 -14
  27. package/avatar/gallery/guardian.json +0 -14
  28. package/avatar/gallery/mecha.json +0 -14
  29. package/avatar/gallery/mochi.json +0 -14
  30. package/avatar/gallery/neko.json +0 -14
  31. package/avatar/gallery/orbiter.json +0 -14
  32. package/avatar/gallery/relay.json +0 -14
  33. package/avatar/gallery/spark.json +0 -14
  34. package/avatar/src/bot/clay.ts +0 -135
  35. package/avatar/src/bot/effects.ts +0 -100
  36. package/avatar/src/bot/grok-bot.ts +0 -626
  37. package/avatar/src/bot/index.ts +0 -15
  38. package/avatar/src/bot/palettes.ts +0 -62
  39. package/avatar/src/bot/ring.ts +0 -219
  40. package/avatar/src/bot/scheduler.ts +0 -239
  41. package/avatar/src/bot/shapes.ts +0 -277
  42. package/avatar/src/bot/spring.ts +0 -196
  43. package/avatar/src/core/color.ts +0 -92
  44. package/avatar/src/core/eyes.ts +0 -297
  45. package/avatar/src/core/field.ts +0 -482
  46. package/avatar/src/core/frame.ts +0 -655
  47. package/avatar/src/core/fx.ts +0 -375
  48. package/avatar/src/core/index.ts +0 -49
  49. package/avatar/src/core/paint.ts +0 -331
  50. package/avatar/src/core/path.ts +0 -495
  51. package/avatar/src/core/pose.ts +0 -581
  52. package/avatar/src/core/svg.ts +0 -98
  53. package/avatar/src/core/types.ts +0 -153
  54. package/avatar/src/core/validate.ts +0 -296
  55. package/avatar/src/core/volume.ts +0 -681
  56. package/avatar/src/entry.ts +0 -260
  57. package/bin/doctor.mjs +0 -148
  58. package/botscreen/requirements-offline.txt +0 -11
  59. package/market/index.json +0 -41
@@ -1,135 +0,0 @@
1
- /**
2
- * 伪 3D 黏土质感渲染层(Canvas 2D 与 SVG 通用):
3
- * 1. 左上角高光(Highlight):在 (-0.25R, -0.25R) 处叠加柔和径向渐变;
4
- * 2. 右下角内阴影(Inner Shadow):使用离屏偏移纯阴影(不回绘黑色遮罩像素),
5
- * 避免抗锯齿边缘发黑,并随当前视角投影宽高自适应模糊与偏移量。
6
- */
7
-
8
- function hexToRgba(hex: string, alpha: number): string {
9
- const m = /^#([0-9a-f]{6})$/i.exec(hex);
10
- if (!m) return `rgba(0,0,0,${alpha})`;
11
- const n = parseInt(m[1], 16);
12
- const r = (n >> 16) & 255;
13
- const g = (n >> 8) & 255;
14
- const b = n & 255;
15
- return `rgba(${r},${g},${b},${alpha})`;
16
- }
17
-
18
- export interface ClayScratch {
19
- body: HTMLCanvasElement;
20
- bodyCtx: CanvasRenderingContext2D;
21
- mask: HTMLCanvasElement;
22
- maskCtx: CanvasRenderingContext2D;
23
- front: HTMLCanvasElement;
24
- frontCtx: CanvasRenderingContext2D;
25
- }
26
-
27
- export function createClayScratch(): ClayScratch | null {
28
- if (typeof document === 'undefined') return null;
29
- const body = document.createElement('canvas');
30
- const mask = document.createElement('canvas');
31
- const front = document.createElement('canvas');
32
- const bodyCtx = body.getContext('2d');
33
- const maskCtx = mask.getContext('2d');
34
- const frontCtx = front.getContext('2d');
35
- if (!bodyCtx || !maskCtx || !frontCtx) return null;
36
- return { body, bodyCtx, mask, maskCtx, front, frontCtx };
37
- }
38
-
39
- const SHADOW_SHIFT = 10000;
40
-
41
- /**
42
- * 对已经画在 `scratch.body` 上的完整单色身体切片施加黏土高光与内阴影。
43
- * `(cx, cy)` 与 `(rx, ry)` 为当前视角下实际投影在画布上的身体中心与半宽高(设备像素)。
44
- */
45
- export function applyClayToCanvas(
46
- scratch: ClayScratch,
47
- width: number,
48
- height: number,
49
- cx: number,
50
- cy: number,
51
- rx: number,
52
- ry: number,
53
- highlightHex: string,
54
- shadowHex: string,
55
- ): void {
56
- const { body, bodyCtx, mask, maskCtx } = scratch;
57
- const rLight = Math.max(rx, ry);
58
- const rRim = Math.max(2, Math.min(rx, ry));
59
- if (width <= 0 || height <= 0 || rLight <= 1) return;
60
-
61
- // 1. 左上角高光(Highlight):偏移 (-0.25R, -0.25R)
62
- bodyCtx.save();
63
- bodyCtx.setTransform(1, 0, 0, 1, 0, 0);
64
- bodyCtx.globalCompositeOperation = 'source-atop';
65
- const hx = cx - rx * 0.25;
66
- const hy = cy - ry * 0.25;
67
- const hiGrad = bodyCtx.createRadialGradient(hx, hy, rRim * 0.04, cx - rx * 0.08, cy - ry * 0.08, rLight * 1.15);
68
- hiGrad.addColorStop(0, hexToRgba(highlightHex, 0.46));
69
- hiGrad.addColorStop(0.45, hexToRgba(highlightHex, 0.16));
70
- hiGrad.addColorStop(1, hexToRgba(highlightHex, 0));
71
- bodyCtx.fillStyle = hiGrad;
72
- bodyCtx.fillRect(0, 0, width, height);
73
-
74
- // 2. 右下角内阴影(Inner Shadow):外扩安全边并用远距偏移只投射纯粹阴影,不污染抗锯齿边
75
- const blur = Math.max(2, rRim * 0.22);
76
- const off = rRim * 0.14;
77
- const pad = Math.ceil(blur + off + 4);
78
- const mw = width + pad * 2;
79
- const mh = height + pad * 2;
80
- const shift = Math.max(SHADOW_SHIFT, mw + mh + 1000);
81
- if (mask.width !== mw || mask.height !== mh) {
82
- mask.width = mw;
83
- mask.height = mh;
84
- }
85
-
86
- maskCtx.setTransform(1, 0, 0, 1, 0, 0);
87
- maskCtx.globalCompositeOperation = 'source-over';
88
- maskCtx.clearRect(0, 0, mw, mh);
89
- maskCtx.fillStyle = '#000';
90
- maskCtx.fillRect(0, 0, mw, mh);
91
- maskCtx.globalCompositeOperation = 'destination-out';
92
- maskCtx.drawImage(body, pad, pad);
93
-
94
- bodyCtx.shadowColor = hexToRgba(shadowHex, 0.52);
95
- bodyCtx.shadowBlur = blur;
96
- bodyCtx.shadowOffsetX = shift - off;
97
- bodyCtx.shadowOffsetY = shift - off;
98
- bodyCtx.drawImage(mask, -shift - pad, -shift - pad);
99
-
100
- // 柔和左上角高光边缘,让轮廓更 Q 弹
101
- const hiOff = rRim * 0.06;
102
- bodyCtx.shadowColor = hexToRgba(highlightHex, 0.28);
103
- bodyCtx.shadowBlur = Math.max(1.5, rRim * 0.12);
104
- bodyCtx.shadowOffsetX = shift + hiOff;
105
- bodyCtx.shadowOffsetY = shift + hiOff;
106
- bodyCtx.drawImage(mask, -shift - pad, -shift - pad);
107
-
108
- bodyCtx.restore();
109
- }
110
-
111
- /**
112
- * 为 SVG 渲染器生成黏土质感滤镜(高光 + 右下角内阴影)。
113
- * 完全纯矢量滤镜,支持无损缩放与 PNG 离屏导出。
114
- */
115
- export function svgClayFilter(id: string, highlightHex: string, shadowHex: string): string {
116
- return (
117
- `<filter id="${id}" x="-20%" y="-20%" width="140%" height="140%">` +
118
- `<feGaussianBlur in="SourceAlpha" stdDeviation="3.2" result="shBlur"/>` +
119
- `<feOffset in="shBlur" dx="-3.2" dy="-3.2" result="shOff"/>` +
120
- `<feComposite in="SourceAlpha" in2="shOff" operator="out" result="shMask"/>` +
121
- `<feFlood flood-color="${shadowHex}" flood-opacity="0.48" result="shColor"/>` +
122
- `<feComposite in="shColor" in2="shMask" operator="in" result="innerShadow"/>` +
123
- `<feGaussianBlur in="SourceAlpha" stdDeviation="2.6" result="hiBlur"/>` +
124
- `<feOffset in="hiBlur" dx="3.4" dy="3.4" result="hiOff"/>` +
125
- `<feComposite in="SourceAlpha" in2="hiOff" operator="out" result="hiMask"/>` +
126
- `<feFlood flood-color="${highlightHex}" flood-opacity="0.42" result="hiColor"/>` +
127
- `<feComposite in="hiColor" in2="hiMask" operator="in" result="innerHighlight"/>` +
128
- `<feMerge>` +
129
- `<feMergeNode in="SourceGraphic"/>` +
130
- `<feMergeNode in="innerShadow"/>` +
131
- `<feMergeNode in="innerHighlight"/>` +
132
- `</feMerge>` +
133
- `</filter>`
134
- );
135
- }
@@ -1,100 +0,0 @@
1
- /**
2
- * 外围独立图层动效:轨道粒子(Orbit)与通知角标(红/蓝点 Badge)。
3
- * 输出 viewBox 单位下的纯几何数据,由 frame.ts 统一参与前后景深度排序。
4
- */
5
- import type { AvatarState, BadgeKind } from '../core/types.ts';
6
- import type { Bounds } from '../core/path.ts';
7
- import { noise } from '../core/pose.ts';
8
- import type { Box, Rim } from '../core/fx.ts';
9
-
10
- const TAU = Math.PI * 2;
11
- const f = (n: number) => Math.round(n * 100) / 100;
12
-
13
- function circlePath(r: number): string {
14
- return `M${f(-r)} 0A${f(r)} ${f(r)} 0 1 1 ${f(r)} 0A${f(r)} ${f(r)} 0 1 1 ${f(-r)} 0Z`;
15
- }
16
-
17
- export interface OrbitPiece {
18
- d: string;
19
- box: Box;
20
- matrix: [number, number, number, number, number, number];
21
- fill: string;
22
- front: boolean;
23
- }
24
-
25
- /**
26
- * 环绕躯干运行的轨道粒子:两条倾斜椭圆轨道,支持前后景遮挡排序。
27
- */
28
- export function orbitPieces(
29
- rim: Rim,
30
- seed: number,
31
- time: number,
32
- state: AvatarState,
33
- palette: readonly string[],
34
- reducedMotion: boolean,
35
- ): OrbitPiece[] {
36
- const count = 6;
37
- const speed = state === 'working' ? 1.55 : state === 'thinking' ? 0.95 : state === 'alert' ? 1.8 : 0.65;
38
- const t = reducedMotion ? 0 : time * speed;
39
- const out: OrbitPiece[] = [];
40
- const baseRadius = rim.max + 5.5;
41
-
42
- for (let i = 0; i < count; i++) {
43
- const track = i % 2;
44
- const tilt = (track === 0 ? 0.34 : -0.42) + (noise(seed, 810 + track) - 0.5) * 0.12;
45
- const roll = (track === 0 ? -0.32 : 0.45) + (noise(seed, 820 + track) - 0.5) * 0.14;
46
- const radius = baseRadius + (track === 0 ? 0 : 2.8) + noise(seed, 830 + i) * 2.2;
47
- const phase = (i / count) * TAU + noise(seed, 840 + i) * 0.8;
48
- const theta = phase + t * (track === 0 ? 1 : -0.82);
49
-
50
- const x3 = radius * Math.cos(theta);
51
- const y3 = radius * Math.sin(theta) * Math.cos(tilt);
52
- const z3 = radius * Math.sin(theta) * Math.sin(tilt);
53
-
54
- const cosR = Math.cos(roll);
55
- const sinR = Math.sin(roll);
56
- const x = rim.cx + x3 * cosR - y3 * sinR;
57
- const y = rim.cy + y3 * cosR + x3 * sinR;
58
-
59
- const depthNorm = z3 / Math.max(1, radius);
60
- const r0 = 1.45 + (i % 3) * 0.48;
61
- const scale = 0.8 + 0.35 * depthNorm + (reducedMotion ? 0 : 0.08 * Math.sin(t * 2.2 + i));
62
- const fill = palette[i % palette.length];
63
-
64
- out.push({
65
- d: circlePath(r0),
66
- box: { x: -r0, y: -r0, w: 2 * r0, h: 2 * r0 },
67
- matrix: [scale, 0, 0, scale, x, y],
68
- fill,
69
- front: z3 >= 0,
70
- });
71
- }
72
- return out;
73
- }
74
-
75
- export interface BadgePiece {
76
- x: number;
77
- y: number;
78
- radius: number;
79
- fill: string;
80
- ringFill: string;
81
- pulse: number;
82
- }
83
-
84
- /**
85
- * 通知红/蓝点角标:锚定在躯干右上角外缘,附带浅色外环和轻微呼吸脉冲。
86
- */
87
- export function badgePiece(b: Bounds, badge: BadgeKind | undefined, time: number, reducedMotion: boolean): BadgePiece | null {
88
- if (!badge || badge === 'none') return null;
89
- const x = Math.min(91, b.maxX - 3);
90
- const y = Math.max(9, b.minY + 3);
91
- const pulse = reducedMotion ? 1 : 1 + 0.09 * Math.sin(time * 4.2);
92
- return {
93
- x,
94
- y,
95
- radius: 6.2,
96
- fill: badge === 'red' ? '#ef4444' : '#3b82f6',
97
- ringFill: '#fffcf7',
98
- pulse,
99
- };
100
- }