@shogo-ai/voice 1.4.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.
- package/LICENSE +21 -0
- package/README.md +30 -0
- package/dist/chunk-D2EVSUZX.js +27 -0
- package/dist/chunk-Q3TJAJ54.js +165 -0
- package/dist/chunk-QHDIEE7O.js +453 -0
- package/dist/chunk-S3S2RNO6.js +671 -0
- package/dist/chunk-ZGYHDC5G.js +423 -0
- package/dist/index.cjs +1316 -0
- package/dist/index.d.cts +432 -0
- package/dist/index.d.ts +432 -0
- package/dist/index.js +735 -0
- package/dist/native/index.cjs +1667 -0
- package/dist/native/index.d.cts +285 -0
- package/dist/native/index.d.ts +285 -0
- package/dist/native/index.js +949 -0
- package/dist/organicParticlesShaders-DIva0vBO.d.cts +693 -0
- package/dist/organicParticlesShaders-DIva0vBO.d.ts +693 -0
- package/dist/react/index.cjs +1670 -0
- package/dist/react/index.d.cts +423 -0
- package/dist/react/index.d.ts +423 -0
- package/dist/react/index.js +952 -0
- package/dist/route/agent.cjs +981 -0
- package/dist/route/agent.d.cts +20 -0
- package/dist/route/agent.d.ts +20 -0
- package/dist/route/agent.js +17 -0
- package/dist/route/audio-tags.cjs +975 -0
- package/dist/route/audio-tags.d.cts +16 -0
- package/dist/route/audio-tags.d.ts +16 -0
- package/dist/route/audio-tags.js +13 -0
- package/dist/route/index.cjs +987 -0
- package/dist/route/index.d.cts +115 -0
- package/dist/route/index.d.ts +115 -0
- package/dist/route/index.js +12 -0
- package/dist/route/signed-url.cjs +975 -0
- package/dist/route/signed-url.d.cts +12 -0
- package/dist/route/signed-url.d.ts +12 -0
- package/dist/route/signed-url.js +13 -0
- package/dist/route/tts-preview.cjs +975 -0
- package/dist/route/tts-preview.d.cts +17 -0
- package/dist/route/tts-preview.d.ts +17 -0
- package/dist/route/tts-preview.js +13 -0
- package/dist/server.cjs +999 -0
- package/dist/server.d.cts +88 -0
- package/dist/server.d.ts +88 -0
- package/dist/server.js +11 -0
- package/dist/types-BKJtOUbE.d.cts +352 -0
- package/dist/types-BKJtOUbE.d.ts +352 -0
- package/package.json +148 -0
|
@@ -0,0 +1,671 @@
|
|
|
1
|
+
import {
|
|
2
|
+
stripAudioTags
|
|
3
|
+
} from "./chunk-Q3TJAJ54.js";
|
|
4
|
+
|
|
5
|
+
// src/react/shaders/organicSphereShaders.ts
|
|
6
|
+
var PERLIN_4D = (
|
|
7
|
+
/* glsl */
|
|
8
|
+
`
|
|
9
|
+
vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}
|
|
10
|
+
vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}
|
|
11
|
+
vec4 fade(vec4 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}
|
|
12
|
+
|
|
13
|
+
float perlin4d(vec4 P){
|
|
14
|
+
vec4 Pi0 = floor(P);
|
|
15
|
+
vec4 Pi1 = Pi0 + 1.0;
|
|
16
|
+
Pi0 = mod(Pi0, 289.0);
|
|
17
|
+
Pi1 = mod(Pi1, 289.0);
|
|
18
|
+
vec4 Pf0 = fract(P);
|
|
19
|
+
vec4 Pf1 = Pf0 - 1.0;
|
|
20
|
+
vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
|
|
21
|
+
vec4 iy = vec4(Pi0.yy, Pi1.yy);
|
|
22
|
+
vec4 iz0 = vec4(Pi0.zzzz);
|
|
23
|
+
vec4 iz1 = vec4(Pi1.zzzz);
|
|
24
|
+
vec4 iw0 = vec4(Pi0.wwww);
|
|
25
|
+
vec4 iw1 = vec4(Pi1.wwww);
|
|
26
|
+
|
|
27
|
+
vec4 ixy = permute(permute(ix) + iy);
|
|
28
|
+
vec4 ixy0 = permute(ixy + iz0);
|
|
29
|
+
vec4 ixy1 = permute(ixy + iz1);
|
|
30
|
+
vec4 ixy00 = permute(ixy0 + iw0);
|
|
31
|
+
vec4 ixy01 = permute(ixy0 + iw1);
|
|
32
|
+
vec4 ixy10 = permute(ixy1 + iw0);
|
|
33
|
+
vec4 ixy11 = permute(ixy1 + iw1);
|
|
34
|
+
|
|
35
|
+
vec4 gx00 = ixy00 / 7.0;
|
|
36
|
+
vec4 gy00 = floor(gx00) / 7.0;
|
|
37
|
+
vec4 gz00 = floor(gy00) / 6.0;
|
|
38
|
+
gx00 = fract(gx00) - 0.5;
|
|
39
|
+
gy00 = fract(gy00) - 0.5;
|
|
40
|
+
gz00 = fract(gz00) - 0.5;
|
|
41
|
+
vec4 gw00 = vec4(0.75) - abs(gx00) - abs(gy00) - abs(gz00);
|
|
42
|
+
vec4 sw00 = step(gw00, vec4(0.0));
|
|
43
|
+
gx00 -= sw00 * (step(0.0, gx00) - 0.5);
|
|
44
|
+
gy00 -= sw00 * (step(0.0, gy00) - 0.5);
|
|
45
|
+
|
|
46
|
+
vec4 gx01 = ixy01 / 7.0;
|
|
47
|
+
vec4 gy01 = floor(gx01) / 7.0;
|
|
48
|
+
vec4 gz01 = floor(gy01) / 6.0;
|
|
49
|
+
gx01 = fract(gx01) - 0.5;
|
|
50
|
+
gy01 = fract(gy01) - 0.5;
|
|
51
|
+
gz01 = fract(gz01) - 0.5;
|
|
52
|
+
vec4 gw01 = vec4(0.75) - abs(gx01) - abs(gy01) - abs(gz01);
|
|
53
|
+
vec4 sw01 = step(gw01, vec4(0.0));
|
|
54
|
+
gx01 -= sw01 * (step(0.0, gx01) - 0.5);
|
|
55
|
+
gy01 -= sw01 * (step(0.0, gy01) - 0.5);
|
|
56
|
+
|
|
57
|
+
vec4 gx10 = ixy10 / 7.0;
|
|
58
|
+
vec4 gy10 = floor(gx10) / 7.0;
|
|
59
|
+
vec4 gz10 = floor(gy10) / 6.0;
|
|
60
|
+
gx10 = fract(gx10) - 0.5;
|
|
61
|
+
gy10 = fract(gy10) - 0.5;
|
|
62
|
+
gz10 = fract(gz10) - 0.5;
|
|
63
|
+
vec4 gw10 = vec4(0.75) - abs(gx10) - abs(gy10) - abs(gz10);
|
|
64
|
+
vec4 sw10 = step(gw10, vec4(0.0));
|
|
65
|
+
gx10 -= sw10 * (step(0.0, gx10) - 0.5);
|
|
66
|
+
gy10 -= sw10 * (step(0.0, gy10) - 0.5);
|
|
67
|
+
|
|
68
|
+
vec4 gx11 = ixy11 / 7.0;
|
|
69
|
+
vec4 gy11 = floor(gx11) / 7.0;
|
|
70
|
+
vec4 gz11 = floor(gy11) / 6.0;
|
|
71
|
+
gx11 = fract(gx11) - 0.5;
|
|
72
|
+
gy11 = fract(gy11) - 0.5;
|
|
73
|
+
gz11 = fract(gz11) - 0.5;
|
|
74
|
+
vec4 gw11 = vec4(0.75) - abs(gx11) - abs(gy11) - abs(gz11);
|
|
75
|
+
vec4 sw11 = step(gw11, vec4(0.0));
|
|
76
|
+
gx11 -= sw11 * (step(0.0, gx11) - 0.5);
|
|
77
|
+
gy11 -= sw11 * (step(0.0, gy11) - 0.5);
|
|
78
|
+
|
|
79
|
+
vec4 g0000 = vec4(gx00.x,gy00.x,gz00.x,gw00.x);
|
|
80
|
+
vec4 g1000 = vec4(gx00.y,gy00.y,gz00.y,gw00.y);
|
|
81
|
+
vec4 g0100 = vec4(gx00.z,gy00.z,gz00.z,gw00.z);
|
|
82
|
+
vec4 g1100 = vec4(gx00.w,gy00.w,gz00.w,gw00.w);
|
|
83
|
+
vec4 g0010 = vec4(gx10.x,gy10.x,gz10.x,gw10.x);
|
|
84
|
+
vec4 g1010 = vec4(gx10.y,gy10.y,gz10.y,gw10.y);
|
|
85
|
+
vec4 g0110 = vec4(gx10.z,gy10.z,gz10.z,gw10.z);
|
|
86
|
+
vec4 g1110 = vec4(gx10.w,gy10.w,gz10.w,gw10.w);
|
|
87
|
+
vec4 g0001 = vec4(gx01.x,gy01.x,gz01.x,gw01.x);
|
|
88
|
+
vec4 g1001 = vec4(gx01.y,gy01.y,gz01.y,gw01.y);
|
|
89
|
+
vec4 g0101 = vec4(gx01.z,gy01.z,gz01.z,gw01.z);
|
|
90
|
+
vec4 g1101 = vec4(gx01.w,gy01.w,gz01.w,gw01.w);
|
|
91
|
+
vec4 g0011 = vec4(gx11.x,gy11.x,gz11.x,gw11.x);
|
|
92
|
+
vec4 g1011 = vec4(gx11.y,gy11.y,gz11.y,gw11.y);
|
|
93
|
+
vec4 g0111 = vec4(gx11.z,gy11.z,gz11.z,gw11.z);
|
|
94
|
+
vec4 g1111 = vec4(gx11.w,gy11.w,gz11.w,gw11.w);
|
|
95
|
+
|
|
96
|
+
vec4 norm00 = taylorInvSqrt(vec4(dot(g0000, g0000), dot(g0100, g0100), dot(g1000, g1000), dot(g1100, g1100)));
|
|
97
|
+
g0000 *= norm00.x; g0100 *= norm00.y; g1000 *= norm00.z; g1100 *= norm00.w;
|
|
98
|
+
|
|
99
|
+
vec4 norm01 = taylorInvSqrt(vec4(dot(g0001, g0001), dot(g0101, g0101), dot(g1001, g1001), dot(g1101, g1101)));
|
|
100
|
+
g0001 *= norm01.x; g0101 *= norm01.y; g1001 *= norm01.z; g1101 *= norm01.w;
|
|
101
|
+
|
|
102
|
+
vec4 norm10 = taylorInvSqrt(vec4(dot(g0010, g0010), dot(g0110, g0110), dot(g1010, g1010), dot(g1110, g1110)));
|
|
103
|
+
g0010 *= norm10.x; g0110 *= norm10.y; g1010 *= norm10.z; g1110 *= norm10.w;
|
|
104
|
+
|
|
105
|
+
vec4 norm11 = taylorInvSqrt(vec4(dot(g0011, g0011), dot(g0111, g0111), dot(g1011, g1011), dot(g1111, g1111)));
|
|
106
|
+
g0011 *= norm11.x; g0111 *= norm11.y; g1011 *= norm11.z; g1111 *= norm11.w;
|
|
107
|
+
|
|
108
|
+
float n0000 = dot(g0000, Pf0);
|
|
109
|
+
float n1000 = dot(g1000, vec4(Pf1.x, Pf0.yzw));
|
|
110
|
+
float n0100 = dot(g0100, vec4(Pf0.x, Pf1.y, Pf0.zw));
|
|
111
|
+
float n1100 = dot(g1100, vec4(Pf1.xy, Pf0.zw));
|
|
112
|
+
float n0010 = dot(g0010, vec4(Pf0.xy, Pf1.z, Pf0.w));
|
|
113
|
+
float n1010 = dot(g1010, vec4(Pf1.x, Pf0.y, Pf1.z, Pf0.w));
|
|
114
|
+
float n0110 = dot(g0110, vec4(Pf0.x, Pf1.yz, Pf0.w));
|
|
115
|
+
float n1110 = dot(g1110, vec4(Pf1.xyz, Pf0.w));
|
|
116
|
+
float n0001 = dot(g0001, vec4(Pf0.xyz, Pf1.w));
|
|
117
|
+
float n1001 = dot(g1001, vec4(Pf1.x, Pf0.yz, Pf1.w));
|
|
118
|
+
float n0101 = dot(g0101, vec4(Pf0.x, Pf1.y, Pf0.z, Pf1.w));
|
|
119
|
+
float n1101 = dot(g1101, vec4(Pf1.xy, Pf0.z, Pf1.w));
|
|
120
|
+
float n0011 = dot(g0011, vec4(Pf0.xy, Pf1.zw));
|
|
121
|
+
float n1011 = dot(g1011, vec4(Pf1.x, Pf0.y, Pf1.zw));
|
|
122
|
+
float n0111 = dot(g0111, vec4(Pf0.x, Pf1.yzw));
|
|
123
|
+
float n1111 = dot(g1111, Pf1);
|
|
124
|
+
|
|
125
|
+
vec4 fade_xyzw = fade(Pf0);
|
|
126
|
+
vec4 n_0w = mix(vec4(n0000, n1000, n0100, n1100), vec4(n0001, n1001, n0101, n1101), fade_xyzw.w);
|
|
127
|
+
vec4 n_1w = mix(vec4(n0010, n1010, n0110, n1110), vec4(n0011, n1011, n0111, n1111), fade_xyzw.w);
|
|
128
|
+
vec4 n_zw = mix(n_0w, n_1w, fade_xyzw.z);
|
|
129
|
+
vec2 n_yzw = mix(n_zw.xy, n_zw.zw, fade_xyzw.y);
|
|
130
|
+
float n_xyzw = mix(n_yzw.x, n_yzw.y, fade_xyzw.x);
|
|
131
|
+
return 2.2 * n_xyzw;
|
|
132
|
+
}
|
|
133
|
+
`
|
|
134
|
+
);
|
|
135
|
+
var ORGANIC_SPHERE_VERTEX_SHADER = (
|
|
136
|
+
/* glsl */
|
|
137
|
+
`
|
|
138
|
+
#define M_PI 3.1415926535897932384626433832795
|
|
139
|
+
|
|
140
|
+
uniform vec3 uLightAColor;
|
|
141
|
+
uniform vec3 uLightAPosition;
|
|
142
|
+
uniform float uLightAIntensity;
|
|
143
|
+
uniform vec3 uLightBColor;
|
|
144
|
+
uniform vec3 uLightBPosition;
|
|
145
|
+
uniform float uLightBIntensity;
|
|
146
|
+
|
|
147
|
+
uniform vec2 uSubdivision;
|
|
148
|
+
|
|
149
|
+
uniform vec3 uOffset;
|
|
150
|
+
|
|
151
|
+
uniform float uDistortionFrequency;
|
|
152
|
+
uniform float uDistortionStrength;
|
|
153
|
+
uniform float uDisplacementFrequency;
|
|
154
|
+
uniform float uDisplacementStrength;
|
|
155
|
+
|
|
156
|
+
uniform float uFresnelOffset;
|
|
157
|
+
uniform float uFresnelMultiplier;
|
|
158
|
+
uniform float uFresnelPower;
|
|
159
|
+
|
|
160
|
+
uniform vec3 uRimColor;
|
|
161
|
+
uniform float uRimThreshold;
|
|
162
|
+
uniform float uRimPower;
|
|
163
|
+
|
|
164
|
+
uniform float uTime;
|
|
165
|
+
|
|
166
|
+
varying vec3 vColor;
|
|
167
|
+
|
|
168
|
+
${PERLIN_4D}
|
|
169
|
+
|
|
170
|
+
vec3 getDisplacedPosition(vec3 _position)
|
|
171
|
+
{
|
|
172
|
+
vec3 distoredPosition = _position;
|
|
173
|
+
distoredPosition += perlin4d(vec4(distoredPosition * uDistortionFrequency + uOffset, uTime)) * uDistortionStrength;
|
|
174
|
+
|
|
175
|
+
float perlinStrength = perlin4d(vec4(distoredPosition * uDisplacementFrequency + uOffset, uTime));
|
|
176
|
+
|
|
177
|
+
vec3 displacedPosition = _position;
|
|
178
|
+
displacedPosition += normalize(_position) * perlinStrength * uDisplacementStrength;
|
|
179
|
+
|
|
180
|
+
return displacedPosition;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
void main()
|
|
184
|
+
{
|
|
185
|
+
vec3 displacedPosition = getDisplacedPosition(position);
|
|
186
|
+
vec4 viewPosition = viewMatrix * vec4(displacedPosition, 1.0);
|
|
187
|
+
gl_Position = projectionMatrix * viewPosition;
|
|
188
|
+
|
|
189
|
+
float distanceA = (M_PI * 2.0) / uSubdivision.x;
|
|
190
|
+
float distanceB = M_PI / uSubdivision.x;
|
|
191
|
+
|
|
192
|
+
vec3 biTangent = cross(normal, tangent.xyz);
|
|
193
|
+
|
|
194
|
+
vec3 positionA = position + tangent.xyz * distanceA;
|
|
195
|
+
vec3 displacedPositionA = getDisplacedPosition(positionA);
|
|
196
|
+
|
|
197
|
+
vec3 positionB = position + biTangent.xyz * distanceB;
|
|
198
|
+
vec3 displacedPositionB = getDisplacedPosition(positionB);
|
|
199
|
+
|
|
200
|
+
vec3 computedNormal = cross(displacedPositionA - displacedPosition.xyz, displacedPositionB - displacedPosition.xyz);
|
|
201
|
+
computedNormal = normalize(computedNormal);
|
|
202
|
+
|
|
203
|
+
vec3 viewDirection = normalize(displacedPosition.xyz - cameraPosition);
|
|
204
|
+
float fresnel = uFresnelOffset + (1.0 + dot(viewDirection, computedNormal)) * uFresnelMultiplier;
|
|
205
|
+
fresnel = pow(max(0.0, fresnel), uFresnelPower);
|
|
206
|
+
|
|
207
|
+
float lightAIntensity = max(0.0, - dot(computedNormal.xyz, normalize(- uLightAPosition))) * uLightAIntensity;
|
|
208
|
+
float lightBIntensity = max(0.0, - dot(computedNormal.xyz, normalize(- uLightBPosition))) * uLightBIntensity;
|
|
209
|
+
|
|
210
|
+
// Clamp mix factors to [0, 1] so a high lightIntensity*fresnel (common on
|
|
211
|
+
// displacement peaks and loud audio) cannot extrapolate past the orange
|
|
212
|
+
// light color and saturate R, producing yellow-white hotspots.
|
|
213
|
+
vec3 color = vec3(0.0);
|
|
214
|
+
color = mix(color, uLightAColor, clamp(lightAIntensity * fresnel, 0.0, 1.0));
|
|
215
|
+
color = mix(color, uLightBColor, clamp(lightBIntensity * fresnel, 0.0, 1.0));
|
|
216
|
+
color = mix(color, uRimColor, clamp(pow(max(0.0, fresnel - uRimThreshold), uRimPower), 0.0, 1.0));
|
|
217
|
+
|
|
218
|
+
vColor = color;
|
|
219
|
+
}
|
|
220
|
+
`
|
|
221
|
+
);
|
|
222
|
+
var ORGANIC_SPHERE_FRAGMENT_SHADER = (
|
|
223
|
+
/* glsl */
|
|
224
|
+
`
|
|
225
|
+
varying vec3 vColor;
|
|
226
|
+
|
|
227
|
+
void main()
|
|
228
|
+
{
|
|
229
|
+
gl_FragColor = vec4(vColor, 1.0);
|
|
230
|
+
}
|
|
231
|
+
`
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
// src/react/sphereConfig.ts
|
|
235
|
+
var DEFAULT_ORGANIC_SPHERE_CONFIG = {
|
|
236
|
+
// Lighting & rim
|
|
237
|
+
lightAColor: "#c2410c",
|
|
238
|
+
lightBColor: "#fb923c",
|
|
239
|
+
lightAIntensity: 2.13,
|
|
240
|
+
lightBIntensity: 1.61,
|
|
241
|
+
rimColor: null,
|
|
242
|
+
rimThreshold: 0.92,
|
|
243
|
+
rimPower: 5,
|
|
244
|
+
// Static shape
|
|
245
|
+
distortionFrequency: 1.5,
|
|
246
|
+
displacementFrequency: 2.12,
|
|
247
|
+
fresnelOffset: -1.609,
|
|
248
|
+
fresnelPower: 1.793,
|
|
249
|
+
// Audio reactivity
|
|
250
|
+
volume: {
|
|
251
|
+
idle: 0.152,
|
|
252
|
+
gain: 0.3,
|
|
253
|
+
floor: 0,
|
|
254
|
+
attack: 0.03,
|
|
255
|
+
decay: 2e-3
|
|
256
|
+
},
|
|
257
|
+
medium: {
|
|
258
|
+
idle: 3.587,
|
|
259
|
+
gain: 2,
|
|
260
|
+
floor: 3.587,
|
|
261
|
+
attack: 8e-3,
|
|
262
|
+
decay: 4e-3
|
|
263
|
+
},
|
|
264
|
+
high: {
|
|
265
|
+
idle: 0.65,
|
|
266
|
+
gain: 5,
|
|
267
|
+
floor: 0.5,
|
|
268
|
+
attack: 0.02,
|
|
269
|
+
decay: 1e-3
|
|
270
|
+
},
|
|
271
|
+
low: {
|
|
272
|
+
idle: 3e-4,
|
|
273
|
+
gain: 3e-3,
|
|
274
|
+
floor: 1e-4,
|
|
275
|
+
attack: 5e-3,
|
|
276
|
+
decay: 2e-3
|
|
277
|
+
},
|
|
278
|
+
// Camera
|
|
279
|
+
cameraZ: 3.84,
|
|
280
|
+
fov: 35,
|
|
281
|
+
// Determinism
|
|
282
|
+
seed: 0,
|
|
283
|
+
// Init-only
|
|
284
|
+
subdivisions: 512,
|
|
285
|
+
maxPixelRatio: null,
|
|
286
|
+
backgroundColor: null
|
|
287
|
+
};
|
|
288
|
+
function resolveOrganicSphereConfig(partial) {
|
|
289
|
+
const base = DEFAULT_ORGANIC_SPHERE_CONFIG;
|
|
290
|
+
if (!partial) return { ...base, volume: { ...base.volume }, medium: { ...base.medium }, high: { ...base.high }, low: { ...base.low } };
|
|
291
|
+
return {
|
|
292
|
+
...base,
|
|
293
|
+
...partial,
|
|
294
|
+
volume: { ...base.volume, ...partial.volume ?? {} },
|
|
295
|
+
medium: { ...base.medium, ...partial.medium ?? {} },
|
|
296
|
+
high: { ...base.high, ...partial.high ?? {} },
|
|
297
|
+
low: { ...base.low, ...partial.low ?? {} }
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// src/react/shaders/organicParticlesShaders.ts
|
|
302
|
+
var ORGANIC_PARTICLES_VERTEX_SHADER = (
|
|
303
|
+
/* glsl */
|
|
304
|
+
`
|
|
305
|
+
${PERLIN_4D}
|
|
306
|
+
|
|
307
|
+
attribute vec3 aBasePosition;
|
|
308
|
+
attribute float aSeed;
|
|
309
|
+
|
|
310
|
+
uniform float uTime;
|
|
311
|
+
uniform float uNoiseFrequency;
|
|
312
|
+
uniform float uNoiseStrength;
|
|
313
|
+
uniform float uDisplacement;
|
|
314
|
+
uniform float uSwirl;
|
|
315
|
+
uniform float uSwirlTimeRate;
|
|
316
|
+
uniform float uSizeBase;
|
|
317
|
+
uniform float uSizeAudio;
|
|
318
|
+
uniform float uPixelRatio;
|
|
319
|
+
|
|
320
|
+
varying float vHeat;
|
|
321
|
+
varying float vSeed;
|
|
322
|
+
|
|
323
|
+
void main() {
|
|
324
|
+
vec3 pos = aBasePosition;
|
|
325
|
+
|
|
326
|
+
// 4D Perlin sampled in particle space. The 4th axis is time so the
|
|
327
|
+
// cloud evolves over time without tiling.
|
|
328
|
+
float n = perlin4d(vec4(pos * uNoiseFrequency, uTime));
|
|
329
|
+
|
|
330
|
+
// Per-particle phase so the cloud doesn't breathe in lockstep.
|
|
331
|
+
float phaseShift = (aSeed - 0.5) * 0.5;
|
|
332
|
+
float breath = sin(uTime * 0.0008 + aSeed * 6.2831) * 0.5 + 0.5;
|
|
333
|
+
|
|
334
|
+
// Outward push: noise + audio-driven displacement, scaled by seed so
|
|
335
|
+
// some particles dart further than others on the same beat.
|
|
336
|
+
vec3 radial = normalize(pos);
|
|
337
|
+
float push = n * uNoiseStrength + uDisplacement * (0.6 + aSeed * 0.8) + breath * 0.05;
|
|
338
|
+
pos += radial * push;
|
|
339
|
+
|
|
340
|
+
// Twist around Y. Amount scales with height so the cloud spirals
|
|
341
|
+
// rather than rigid-rotating. uSwirlTimeRate is 0 by default so the
|
|
342
|
+
// swirl is driven by audio (uSwirl) alone; crank it for a constant
|
|
343
|
+
// drift.
|
|
344
|
+
float swirlAngle = pos.y * uSwirl + uTime * uSwirlTimeRate + phaseShift;
|
|
345
|
+
float c = cos(swirlAngle);
|
|
346
|
+
float s = sin(swirlAngle);
|
|
347
|
+
pos.xz = mat2(c, -s, s, c) * pos.xz;
|
|
348
|
+
|
|
349
|
+
vec4 mvPos = modelViewMatrix * vec4(pos, 1.0);
|
|
350
|
+
gl_Position = projectionMatrix * mvPos;
|
|
351
|
+
|
|
352
|
+
// Point size: base + audio boost, gently perspective-attenuated. At
|
|
353
|
+
// the default camera (z ~= 3.84) a uSizeBase of 1 renders roughly one
|
|
354
|
+
// device pixel \u2014 intentionally tiny so 40k+ additively-blended points
|
|
355
|
+
// read as fine dust rather than a solid blob.
|
|
356
|
+
float size = uSizeBase + uSizeAudio * (0.5 + aSeed);
|
|
357
|
+
gl_PointSize = max(1.0, size * uPixelRatio * (2.0 / max(0.1, -mvPos.z)));
|
|
358
|
+
|
|
359
|
+
// Heat: 0 at core, 1 at fringe. Used by the fragment to lerp color.
|
|
360
|
+
vHeat = clamp((length(pos) - 0.4) / 1.4, 0.0, 1.0);
|
|
361
|
+
vSeed = aSeed;
|
|
362
|
+
}
|
|
363
|
+
`
|
|
364
|
+
);
|
|
365
|
+
var ORGANIC_PARTICLES_FRAGMENT_SHADER = (
|
|
366
|
+
/* glsl */
|
|
367
|
+
`
|
|
368
|
+
precision mediump float;
|
|
369
|
+
|
|
370
|
+
uniform vec3 uColorCool;
|
|
371
|
+
uniform vec3 uColorHot;
|
|
372
|
+
uniform float uOpacity;
|
|
373
|
+
uniform float uSoftness;
|
|
374
|
+
|
|
375
|
+
varying float vHeat;
|
|
376
|
+
varying float vSeed;
|
|
377
|
+
|
|
378
|
+
void main() {
|
|
379
|
+
vec2 centered = gl_PointCoord - vec2(0.5);
|
|
380
|
+
float distSq = dot(centered, centered);
|
|
381
|
+
if (distSq > 0.25) discard;
|
|
382
|
+
|
|
383
|
+
// Soft circular falloff. uSoftness in [0.5, 1] controls how hard the
|
|
384
|
+
// edge is: 0.5 = sharp disc, 1 = feathered blob.
|
|
385
|
+
float innerR = 0.25 * (1.0 - uSoftness);
|
|
386
|
+
float alpha = smoothstep(0.25, innerR, distSq);
|
|
387
|
+
|
|
388
|
+
// Warm/cool gradient, with a tiny seed-based tint wobble so the cloud
|
|
389
|
+
// doesn't look banded.
|
|
390
|
+
float wobble = (vSeed - 0.5) * 0.15;
|
|
391
|
+
vec3 color = mix(uColorCool, uColorHot, clamp(vHeat + wobble, 0.0, 1.0));
|
|
392
|
+
|
|
393
|
+
gl_FragColor = vec4(color, alpha * uOpacity);
|
|
394
|
+
}
|
|
395
|
+
`
|
|
396
|
+
);
|
|
397
|
+
|
|
398
|
+
// src/react/particlesConfig.ts
|
|
399
|
+
var DEFAULT_ORGANIC_PARTICLES_CONFIG = {
|
|
400
|
+
// Cloud shape
|
|
401
|
+
count: 4e4,
|
|
402
|
+
innerRadius: 0.6,
|
|
403
|
+
outerRadius: 1.1,
|
|
404
|
+
// Motion. Constant rotation / swirl drift default to 0 so the cloud
|
|
405
|
+
// only spins in response to audio — but `idleNoiseRate` keeps the
|
|
406
|
+
// Perlin field shimmering slightly so the cloud doesn't look frozen
|
|
407
|
+
// while paused.
|
|
408
|
+
noiseFrequency: 1.4,
|
|
409
|
+
noiseStrength: 0.22,
|
|
410
|
+
rotationBias: 0,
|
|
411
|
+
swirlTimeRate: 0,
|
|
412
|
+
idleNoiseRate: 1e-4,
|
|
413
|
+
// Rendering. Additive blending stacks contributions, so keep opacity
|
|
414
|
+
// low (<0.3) or 40k particles will saturate to white. sizeBase ~1
|
|
415
|
+
// renders as tiny dust; crank it higher for softer plasma look.
|
|
416
|
+
sizeBase: 1,
|
|
417
|
+
softness: 0.55,
|
|
418
|
+
opacity: 0.18,
|
|
419
|
+
// Color
|
|
420
|
+
colorCool: "#c2410c",
|
|
421
|
+
colorHot: "#fb923c",
|
|
422
|
+
// Audio reactivity
|
|
423
|
+
volume: {
|
|
424
|
+
idle: 0.02,
|
|
425
|
+
gain: 0.4,
|
|
426
|
+
floor: 0,
|
|
427
|
+
attack: 0.03,
|
|
428
|
+
decay: 25e-4
|
|
429
|
+
},
|
|
430
|
+
medium: {
|
|
431
|
+
idle: 0,
|
|
432
|
+
gain: 4,
|
|
433
|
+
floor: 0,
|
|
434
|
+
attack: 0.01,
|
|
435
|
+
decay: 4e-3
|
|
436
|
+
},
|
|
437
|
+
high: {
|
|
438
|
+
idle: 0.2,
|
|
439
|
+
gain: 1.2,
|
|
440
|
+
floor: 0.15,
|
|
441
|
+
attack: 0.015,
|
|
442
|
+
decay: 2e-3
|
|
443
|
+
},
|
|
444
|
+
low: {
|
|
445
|
+
idle: 4e-4,
|
|
446
|
+
gain: 4e-3,
|
|
447
|
+
floor: 1e-4,
|
|
448
|
+
attack: 5e-3,
|
|
449
|
+
decay: 2e-3
|
|
450
|
+
},
|
|
451
|
+
// Camera
|
|
452
|
+
cameraZ: 3.84,
|
|
453
|
+
fov: 35,
|
|
454
|
+
// Determinism
|
|
455
|
+
seed: 0,
|
|
456
|
+
// Init-only
|
|
457
|
+
maxPixelRatio: null,
|
|
458
|
+
backgroundColor: null
|
|
459
|
+
};
|
|
460
|
+
function resolveOrganicParticlesConfig(partial) {
|
|
461
|
+
const base = DEFAULT_ORGANIC_PARTICLES_CONFIG;
|
|
462
|
+
if (!partial) {
|
|
463
|
+
return {
|
|
464
|
+
...base,
|
|
465
|
+
volume: { ...base.volume },
|
|
466
|
+
medium: { ...base.medium },
|
|
467
|
+
high: { ...base.high },
|
|
468
|
+
low: { ...base.low }
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
return {
|
|
472
|
+
...base,
|
|
473
|
+
...partial,
|
|
474
|
+
volume: { ...base.volume, ...partial.volume ?? {} },
|
|
475
|
+
medium: { ...base.medium, ...partial.medium ?? {} },
|
|
476
|
+
high: { ...base.high, ...partial.high ?? {} },
|
|
477
|
+
low: { ...base.low, ...partial.low ?? {} }
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
// src/shared/postJson.ts
|
|
482
|
+
function createPostJson({
|
|
483
|
+
authHeaders,
|
|
484
|
+
fetchCredentials
|
|
485
|
+
}) {
|
|
486
|
+
return async function postJson(path, body) {
|
|
487
|
+
return fetch(path, {
|
|
488
|
+
method: "POST",
|
|
489
|
+
headers: { "content-type": "application/json", ...authHeaders() },
|
|
490
|
+
credentials: fetchCredentials,
|
|
491
|
+
body: JSON.stringify(body)
|
|
492
|
+
});
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// src/shared/memory.ts
|
|
497
|
+
function createMemoryAddTool({
|
|
498
|
+
postJson,
|
|
499
|
+
memoryAddPath
|
|
500
|
+
}) {
|
|
501
|
+
return async (params) => {
|
|
502
|
+
const fact = typeof params.fact === "string" ? params.fact : "";
|
|
503
|
+
if (!fact.trim()) return "Memory save failed: empty fact.";
|
|
504
|
+
try {
|
|
505
|
+
const res = await postJson(memoryAddPath, { fact });
|
|
506
|
+
if (!res.ok) return "Failed to save memory.";
|
|
507
|
+
return "Memory saved.";
|
|
508
|
+
} catch {
|
|
509
|
+
return "Memory save failed.";
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
function createMemoryContextInjector({
|
|
514
|
+
postJson,
|
|
515
|
+
memoryRetrievePath,
|
|
516
|
+
conversationRef,
|
|
517
|
+
enabled,
|
|
518
|
+
lastInjectedRef
|
|
519
|
+
}) {
|
|
520
|
+
return async function inject(userText) {
|
|
521
|
+
if (!enabled) return;
|
|
522
|
+
try {
|
|
523
|
+
const res = await postJson(memoryRetrievePath, { query: userText, limit: 4 });
|
|
524
|
+
if (!res.ok) return;
|
|
525
|
+
const data = await res.json();
|
|
526
|
+
const results = data.results ?? [];
|
|
527
|
+
if (!results.length) return;
|
|
528
|
+
const lines = results.map((r) => `- ${r.chunk.trim().replace(/\s+/g, " ").slice(0, 200)}`).join("\n");
|
|
529
|
+
if (lines === lastInjectedRef.current) return;
|
|
530
|
+
lastInjectedRef.current = lines;
|
|
531
|
+
const payload = `Relevant memory about this user:
|
|
532
|
+
${lines}`;
|
|
533
|
+
conversationRef.current?.sendContextualUpdate(payload);
|
|
534
|
+
} catch {
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// src/shared/transcript.ts
|
|
540
|
+
function createTranscriptDisconnectHandler({
|
|
541
|
+
isRestartingRef,
|
|
542
|
+
weStartedSessionRef,
|
|
543
|
+
transcriptRef,
|
|
544
|
+
onTranscript,
|
|
545
|
+
transcriptIngestPath,
|
|
546
|
+
postJson
|
|
547
|
+
}) {
|
|
548
|
+
return function handleTranscriptOnDisconnect() {
|
|
549
|
+
if (isRestartingRef.current) {
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
if (!weStartedSessionRef.current) {
|
|
553
|
+
transcriptRef.current = [];
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
weStartedSessionRef.current = false;
|
|
557
|
+
const transcript = transcriptRef.current.join("\n");
|
|
558
|
+
transcriptRef.current = [];
|
|
559
|
+
if (onTranscript) {
|
|
560
|
+
void onTranscript(transcript);
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
const trimmed = transcript.trim();
|
|
564
|
+
if (trimmed.length < 20) return;
|
|
565
|
+
void postJson(transcriptIngestPath, { transcript: trimmed }).catch(() => {
|
|
566
|
+
});
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
function appendTranscriptLine(msg, { transcriptRef, weStartedSessionRef }) {
|
|
570
|
+
if (!msg?.message || !msg?.source) return;
|
|
571
|
+
if (!weStartedSessionRef.current) return;
|
|
572
|
+
const speaker = msg.source === "user" ? "User" : "Agent";
|
|
573
|
+
const cleaned = msg.source === "user" ? msg.message : stripAudioTags(msg.message);
|
|
574
|
+
if (!cleaned) return;
|
|
575
|
+
transcriptRef.current.push(`${speaker}: ${cleaned}`);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
// src/shared/sessionPayload.ts
|
|
579
|
+
function sanitizeDynamicVariables(raw) {
|
|
580
|
+
if (raw == null) return {};
|
|
581
|
+
const out = {};
|
|
582
|
+
for (const [k, v] of Object.entries(raw)) {
|
|
583
|
+
if (v == null) continue;
|
|
584
|
+
out[k] = typeof v === "string" ? v : String(v);
|
|
585
|
+
}
|
|
586
|
+
return out;
|
|
587
|
+
}
|
|
588
|
+
function buildSessionPayload(opts) {
|
|
589
|
+
const dynamicVariables = {
|
|
590
|
+
...sanitizeDynamicVariables(opts.dynamicVariables),
|
|
591
|
+
character_name: opts.characterName,
|
|
592
|
+
user_context: opts.userContext
|
|
593
|
+
};
|
|
594
|
+
if (typeof opts.conversationId === "string" && opts.conversationId.length > 0) {
|
|
595
|
+
dynamicVariables.conversation_id = opts.conversationId;
|
|
596
|
+
}
|
|
597
|
+
const payload = {
|
|
598
|
+
signedUrl: opts.signedUrl,
|
|
599
|
+
dynamicVariables
|
|
600
|
+
};
|
|
601
|
+
const agentOverrides = {};
|
|
602
|
+
if (opts.suppressFirstMessage) {
|
|
603
|
+
agentOverrides.firstMessage = "";
|
|
604
|
+
}
|
|
605
|
+
if (typeof opts.agentPromptOverride === "string" && opts.agentPromptOverride.length > 0) {
|
|
606
|
+
agentOverrides.prompt = { prompt: opts.agentPromptOverride };
|
|
607
|
+
}
|
|
608
|
+
if (Object.keys(agentOverrides).length > 0) {
|
|
609
|
+
payload.overrides = { agent: agentOverrides };
|
|
610
|
+
}
|
|
611
|
+
return payload;
|
|
612
|
+
}
|
|
613
|
+
async function fetchSignedUrl({
|
|
614
|
+
path,
|
|
615
|
+
fetchCredentials,
|
|
616
|
+
authHeaders
|
|
617
|
+
}) {
|
|
618
|
+
const res = await fetch(path, {
|
|
619
|
+
credentials: fetchCredentials,
|
|
620
|
+
headers: authHeaders()
|
|
621
|
+
});
|
|
622
|
+
if (!res.ok) throw new Error(`Signed URL request failed: ${res.status}`);
|
|
623
|
+
return await res.json();
|
|
624
|
+
}
|
|
625
|
+
function withProjectQuery(signedUrlPath, params) {
|
|
626
|
+
const tail = [];
|
|
627
|
+
if (typeof params.projectId === "string" && params.projectId.length > 0) {
|
|
628
|
+
tail.push(`projectId=${encodeURIComponent(params.projectId)}`);
|
|
629
|
+
}
|
|
630
|
+
if (typeof params.agentName === "string" && params.agentName.length > 0) {
|
|
631
|
+
tail.push(`agentName=${encodeURIComponent(params.agentName)}`);
|
|
632
|
+
}
|
|
633
|
+
if (tail.length === 0) return signedUrlPath;
|
|
634
|
+
const sep = signedUrlPath.includes("?") ? "&" : "?";
|
|
635
|
+
return `${signedUrlPath}${sep}${tail.join("&")}`;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
// src/shared/chatUrl.ts
|
|
639
|
+
function appendChatQuery(basePath, params) {
|
|
640
|
+
const tail = [];
|
|
641
|
+
for (const [k, v] of Object.entries(params)) {
|
|
642
|
+
if (typeof v === "string" && v.length > 0) {
|
|
643
|
+
tail.push(`${k}=${encodeURIComponent(v)}`);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
if (tail.length === 0) return basePath;
|
|
647
|
+
const sep = basePath.includes("?") ? "&" : "?";
|
|
648
|
+
return `${basePath}${sep}${tail.join("&")}`;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
export {
|
|
652
|
+
createPostJson,
|
|
653
|
+
createMemoryAddTool,
|
|
654
|
+
createMemoryContextInjector,
|
|
655
|
+
createTranscriptDisconnectHandler,
|
|
656
|
+
appendTranscriptLine,
|
|
657
|
+
buildSessionPayload,
|
|
658
|
+
fetchSignedUrl,
|
|
659
|
+
withProjectQuery,
|
|
660
|
+
appendChatQuery,
|
|
661
|
+
PERLIN_4D,
|
|
662
|
+
ORGANIC_SPHERE_VERTEX_SHADER,
|
|
663
|
+
ORGANIC_SPHERE_FRAGMENT_SHADER,
|
|
664
|
+
DEFAULT_ORGANIC_SPHERE_CONFIG,
|
|
665
|
+
resolveOrganicSphereConfig,
|
|
666
|
+
ORGANIC_PARTICLES_VERTEX_SHADER,
|
|
667
|
+
ORGANIC_PARTICLES_FRAGMENT_SHADER,
|
|
668
|
+
DEFAULT_ORGANIC_PARTICLES_CONFIG,
|
|
669
|
+
resolveOrganicParticlesConfig
|
|
670
|
+
};
|
|
671
|
+
//# sourceMappingURL=chunk-S3S2RNO6.js.map
|