@shogo-ai/voice 1.9.13 → 2.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/README.md +89 -0
- package/dist/{chunk-S3S2RNO6.js → chunk-BI6SL35K.js} +1 -184
- package/dist/chunk-CLF25CZC.js +987 -0
- package/dist/chunk-KMSL5PWK.js +540 -0
- package/dist/chunk-ME3SIZZU.js +581 -0
- package/dist/chunk-TQOBJMEK.js +17 -0
- package/dist/{chunk-T3T4EBWY.js → chunk-UH75UVM2.js} +6 -2
- package/dist/chunk-UW7VQ3S6.js +148 -0
- package/dist/chunk-XE4LLC7Z.js +1067 -0
- package/dist/chunk-ZAW6F3YT.js +172 -0
- package/dist/index.cjs +735 -25
- package/dist/index.d.cts +373 -3
- package/dist/index.d.ts +373 -3
- package/dist/index.js +59 -3
- package/dist/live/client.cjs +173 -0
- package/dist/live/client.d.cts +132 -0
- package/dist/live/client.d.ts +132 -0
- package/dist/live/client.js +9 -0
- package/dist/native/index.d.cts +5 -2
- package/dist/native/index.d.ts +5 -2
- package/dist/native/index.js +15 -11
- package/dist/{organicParticlesShaders-DIva0vBO.d.ts → organicParticlesShaders-seZq7jYX.d.cts} +1 -421
- package/dist/{organicParticlesShaders-DIva0vBO.d.cts → organicParticlesShaders-seZq7jYX.d.ts} +1 -421
- package/dist/particlesConfig-0YbdPOdY.d.cts +223 -0
- package/dist/particlesConfig-0YbdPOdY.d.ts +223 -0
- package/dist/react/conversation.cjs +789 -0
- package/dist/react/conversation.d.cts +134 -0
- package/dist/react/conversation.d.ts +134 -0
- package/dist/react/conversation.js +13 -0
- package/dist/react/index.cjs +374 -36
- package/dist/react/index.d.cts +10 -141
- package/dist/react/index.d.ts +10 -141
- package/dist/react/index.js +23 -770
- package/dist/react/visuals.cjs +1048 -0
- package/dist/react/visuals.d.cts +70 -0
- package/dist/react/visuals.d.ts +70 -0
- package/dist/react/visuals.js +10 -0
- package/dist/route/agent.cjs +1038 -85
- package/dist/route/agent.js +3 -3
- package/dist/route/audio-tags.cjs +1038 -85
- package/dist/route/audio-tags.js +3 -3
- package/dist/route/index.cjs +1042 -85
- package/dist/route/index.d.cts +19 -3
- package/dist/route/index.d.ts +19 -3
- package/dist/route/index.js +3 -3
- package/dist/route/music.cjs +1038 -85
- package/dist/route/music.js +3 -3
- package/dist/route/op.cjs +2118 -0
- package/dist/route/op.d.cts +43 -0
- package/dist/route/op.d.ts +43 -0
- package/dist/route/op.js +27 -0
- package/dist/route/signed-url.cjs +1038 -85
- package/dist/route/signed-url.js +3 -3
- package/dist/route/tts-preview.cjs +1038 -85
- package/dist/route/tts-preview.d.cts +6 -4
- package/dist/route/tts-preview.d.ts +6 -4
- package/dist/route/tts-preview.js +3 -3
- package/dist/server.cjs +1038 -85
- package/dist/server.d.cts +40 -8
- package/dist/server.d.ts +40 -8
- package/dist/server.js +2 -2
- package/dist/types-Bfhu-aQH.d.cts +199 -0
- package/dist/types-Bfhu-aQH.d.ts +199 -0
- package/dist/{types-W9y6eMj3.d.ts → types-CadjTXNH.d.cts} +193 -12
- package/dist/{types-W9y6eMj3.d.cts → types-CadjTXNH.d.ts} +193 -12
- package/package.json +21 -1
- package/dist/chunk-B4JC3DK2.js +0 -529
- package/dist/chunk-O362EJQR.js +0 -524
package/dist/{organicParticlesShaders-DIva0vBO.d.cts → organicParticlesShaders-seZq7jYX.d.ts}
RENAMED
|
@@ -1,203 +1,5 @@
|
|
|
1
1
|
import { UIMessage } from 'ai';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Shared option / result types for `useVoiceConversation` across
|
|
5
|
-
* platforms. The web hook ([packages/sdk/src/voice/react]) and the
|
|
6
|
-
* native hook ([packages/sdk/src/voice/native]) both export their own
|
|
7
|
-
* `UseVoiceConversationOptions` / `UseVoiceConversationResult`
|
|
8
|
-
* types — typically by re-exporting `BaseVoiceConversationOptions` /
|
|
9
|
-
* `BaseVoiceConversationResult` from this module — so consumers can
|
|
10
|
-
* import them from whichever subpath they're using.
|
|
11
|
-
*/
|
|
12
|
-
interface BaseVoiceConversationOptions {
|
|
13
|
-
/** Name of the companion the user is talking to (passed as a dynamic variable). */
|
|
14
|
-
characterName: string;
|
|
15
|
-
/** Server path that mints an 11Labs signed URL for this user. Default: `/api/voice/signed-url`. */
|
|
16
|
-
signedUrlPath?: string;
|
|
17
|
-
/** Server path the built-in `add_memory` tool POSTs to. Default: `/api/memory/add`. */
|
|
18
|
-
memoryAddPath?: string;
|
|
19
|
-
/** Server path used to auto-inject memory context. Default: `/api/memory/retrieve`. */
|
|
20
|
-
memoryRetrievePath?: string;
|
|
21
|
-
/** Server path the transcript is POSTed to when the session ends. Default: `/api/memory/ingest`. */
|
|
22
|
-
transcriptIngestPath?: string;
|
|
23
|
-
/** Disable the built-in memory context auto-injection. Default: `true` (enabled). */
|
|
24
|
-
autoInjectMemory?: boolean;
|
|
25
|
-
/** Disable the built-in `add_memory` client tool. Default: `true` (enabled). */
|
|
26
|
-
includeMemoryTool?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Additional client tools merged onto `add_memory`. Tools defined here with
|
|
29
|
-
* the name `add_memory` override the built-in implementation.
|
|
30
|
-
*/
|
|
31
|
-
clientTools?: Record<string, (params: Record<string, unknown>) => Promise<string> | string>;
|
|
32
|
-
/**
|
|
33
|
-
* Called once per session with the accumulated transcript when the session
|
|
34
|
-
* disconnects. Defaults to POST `transcriptIngestPath`; set this to suppress
|
|
35
|
-
* or replace that behaviour.
|
|
36
|
-
*/
|
|
37
|
-
onTranscript?: (transcript: string) => void | Promise<void>;
|
|
38
|
-
/**
|
|
39
|
-
* Credentials mode for built-in fetch calls.
|
|
40
|
-
*
|
|
41
|
-
* - Defaults to `same-origin` in the legacy cookie path.
|
|
42
|
-
* - Defaults to `omit` when `shogoApiKey` is provided (bearer auth is
|
|
43
|
-
* self-contained and you don't want browsers to attach unrelated
|
|
44
|
-
* third-party cookies cross-origin).
|
|
45
|
-
* - Explicit values always win — pass `'include'` to carry both a cookie
|
|
46
|
-
* and the bearer in a hybrid same-origin app.
|
|
47
|
-
*/
|
|
48
|
-
fetchCredentials?: RequestCredentials;
|
|
49
|
-
/**
|
|
50
|
-
* Shogo API key (`shogo_sk_*`) used to authenticate voice routes. When
|
|
51
|
-
* provided, the hook attaches `Authorization: Bearer <key>` to the
|
|
52
|
-
* signed-URL fetch and memory fetches, and appends `?projectId=` to
|
|
53
|
-
* the signed-URL path. Either `shogoApiKey` or a session cookie must
|
|
54
|
-
* be resolvable by the server — both may be passed; the server's
|
|
55
|
-
* `apiKeyOrSession` middleware picks bearer first.
|
|
56
|
-
*/
|
|
57
|
-
shogoApiKey?: string;
|
|
58
|
-
/**
|
|
59
|
-
* Project id (Shogo's `projectId`). Required alongside `shogoApiKey`
|
|
60
|
-
* for Mode B voice. The server uses it to look up / provision the
|
|
61
|
-
* project's ElevenLabs agent and resolve the workspace.
|
|
62
|
-
*/
|
|
63
|
-
projectId?: string;
|
|
64
|
-
/**
|
|
65
|
-
* Optional named agent to talk to. Forwarded as `?agentName=` on
|
|
66
|
-
* the signed-URL fetch and resolved server-side to a project-scoped
|
|
67
|
-
* `ProjectAgent` row (created via `shogo deploy`). When omitted,
|
|
68
|
-
* the server resolves the project's `default` agent.
|
|
69
|
-
*
|
|
70
|
-
* The same `agentName` reaches the same persona via
|
|
71
|
-
* `useChatConversation({ agentName })` — voice and chat are two
|
|
72
|
-
* transports for one agent record.
|
|
73
|
-
*/
|
|
74
|
-
agentName?: string;
|
|
75
|
-
/** Called on connection errors. */
|
|
76
|
-
onError?: (error: unknown) => void;
|
|
77
|
-
/** Called on each message (user or agent) for debugging / custom UI. */
|
|
78
|
-
onMessage?: (message: {
|
|
79
|
-
source: string;
|
|
80
|
-
message: string;
|
|
81
|
-
}) => void;
|
|
82
|
-
/**
|
|
83
|
-
* Stable conversation id used to correlate this voice session with
|
|
84
|
-
* a sibling text thread (see `BaseChatConversationOptions.conversationId`).
|
|
85
|
-
*
|
|
86
|
-
* When set, forwarded to ElevenLabs as a `conversation_id` dynamic
|
|
87
|
-
* variable so the agent's prompt can reference it (`{{conversation_id}}`),
|
|
88
|
-
* and surfaced on `BaseVoiceConversationResult.conversationId` so a
|
|
89
|
-
* single bridge component can read the same value from either hook.
|
|
90
|
-
*
|
|
91
|
-
* Independent of the convai-side conversation id — see
|
|
92
|
-
* `BaseVoiceConversationResult.convaiConversationId` for that. The
|
|
93
|
-
* caller-supplied value wins on `result.conversationId` so consumers
|
|
94
|
-
* who keep their own thread store don't have to special-case the
|
|
95
|
-
* default. Optional; when omitted, `result.conversationId` mirrors
|
|
96
|
-
* the convai conversation id once the session connects.
|
|
97
|
-
*/
|
|
98
|
-
conversationId?: string;
|
|
99
|
-
/**
|
|
100
|
-
* Extra dynamic variables forwarded to ElevenLabs at session start.
|
|
101
|
-
* Merged on top of the SDK's built-in variables — `character_name`,
|
|
102
|
-
* `user_context`, and `conversation_id` (when supplied) always win
|
|
103
|
-
* on collision so consumers can't accidentally override them.
|
|
104
|
-
*
|
|
105
|
-
* Typical use: surface per-user fields from the consumer's own
|
|
106
|
-
* `Companion` row (display name, relationship stage, custom greeting
|
|
107
|
-
* tokens) so the agent's prompt can reference them via
|
|
108
|
-
* `{{var_name}}`. Variables also need to be declared in the agent's
|
|
109
|
-
* `dynamic_variable_placeholders` (set at deploy time) for EL to
|
|
110
|
-
* pick up the value.
|
|
111
|
-
*
|
|
112
|
-
* Non-string values are coerced via `String(...)` before being
|
|
113
|
-
* forwarded; `null` / `undefined` values are silently dropped.
|
|
114
|
-
*/
|
|
115
|
-
dynamicVariables?: Record<string, unknown> | null;
|
|
116
|
-
}
|
|
117
|
-
interface BaseVoiceConversationResult {
|
|
118
|
-
/**
|
|
119
|
-
* Begin a new session. Requests microphone permission and fetches a
|
|
120
|
-
* signed URL.
|
|
121
|
-
*
|
|
122
|
-
* `suppressFirstMessage` mirrors the option on `restart()` — when
|
|
123
|
-
* `true`, the new session is opened with `overrides.agent.firstMessage = ''`
|
|
124
|
-
* so the agent skips its opening greeting. Useful when the consumer
|
|
125
|
-
* is programmatically reconnecting (e.g. to deliver a one-shot spoken
|
|
126
|
-
* summary) and does not want to hear the configured intro.
|
|
127
|
-
*/
|
|
128
|
-
start: (options?: {
|
|
129
|
-
suppressFirstMessage?: boolean;
|
|
130
|
-
}) => Promise<void>;
|
|
131
|
-
/** End the current session (if any). */
|
|
132
|
-
end: () => void;
|
|
133
|
-
/**
|
|
134
|
-
* Tear down the active session and immediately reconnect. Primarily
|
|
135
|
-
* used as a programmatic barge-in: ElevenLabs doesn't expose a public
|
|
136
|
-
* `interrupt()` on `useConversation`, so stopping the agent mid-
|
|
137
|
-
* utterance requires a fast disconnect + reconnect. When
|
|
138
|
-
* `suppressFirstMessage` is `true` (the default), the new session is
|
|
139
|
-
* started with `overrides.agent.firstMessage = ''` so the agent does
|
|
140
|
-
* not replay its intro. The accumulated transcript is preserved
|
|
141
|
-
* across the reconnect gap.
|
|
142
|
-
*/
|
|
143
|
-
restart: (options?: {
|
|
144
|
-
suppressFirstMessage?: boolean;
|
|
145
|
-
}) => Promise<void>;
|
|
146
|
-
/** `'disconnected' | 'connecting' | 'connected'`. */
|
|
147
|
-
status: 'disconnected' | 'connecting' | 'connected';
|
|
148
|
-
/** Whether the agent is currently speaking. */
|
|
149
|
-
isSpeaking: boolean;
|
|
150
|
-
/** Whether the agent is currently listening. */
|
|
151
|
-
isListening: boolean;
|
|
152
|
-
/** Whether the microphone is currently muted (input audio is gated off). */
|
|
153
|
-
isMuted: boolean;
|
|
154
|
-
/**
|
|
155
|
-
* Toggle the microphone mute state without tearing down the session.
|
|
156
|
-
* Wraps `@elevenlabs/react` (or `@elevenlabs/react-native`)'s
|
|
157
|
-
* `setMuted`, which in turn calls `conversation.setMicMuted()`.
|
|
158
|
-
* Muting does not end the WebSocket or release the underlying media
|
|
159
|
-
* stream; it simply stops input audio from being forwarded to the
|
|
160
|
-
* server.
|
|
161
|
-
*/
|
|
162
|
-
setMuted: (isMuted: boolean) => void;
|
|
163
|
-
/** For consumers who want to drive their own visualisation / lipsync. */
|
|
164
|
-
getOutputByteFrequencyData: () => Uint8Array | null;
|
|
165
|
-
/** Imperatively send a contextual update (e.g. "user navigated to X"). */
|
|
166
|
-
sendContextualUpdate: (text: string) => void;
|
|
167
|
-
/**
|
|
168
|
-
* Imperatively inject a user-role message, forcing the agent to take
|
|
169
|
-
* its next turn immediately (rather than waiting for the human to
|
|
170
|
-
* speak). Useful for out-of-band prompts like "please summarise what
|
|
171
|
-
* just happened". The injected text is *not* spoken aloud — the agent
|
|
172
|
-
* treats it as if the user said it.
|
|
173
|
-
*/
|
|
174
|
-
sendUserMessage: (text: string) => void;
|
|
175
|
-
/**
|
|
176
|
-
* Low-level signal that the user is active (typing, clicking) so the
|
|
177
|
-
* agent doesn't try to fill silence. Used as a fallback nudge when we
|
|
178
|
-
* want to keep the session "warm" without forcing a full turn.
|
|
179
|
-
*/
|
|
180
|
-
sendUserActivity: () => void;
|
|
181
|
-
/**
|
|
182
|
-
* Stable conversation id for cross-transport correlation. Returns the
|
|
183
|
-
* caller-supplied `BaseVoiceConversationOptions.conversationId` when
|
|
184
|
-
* one was provided; otherwise mirrors the convai conversation id once
|
|
185
|
-
* the session connects (and is `null` while disconnected).
|
|
186
|
-
*
|
|
187
|
-
* Pass this same value to `useChatConversation({ conversationId })`
|
|
188
|
-
* to stitch a text thread onto the same logical conversation.
|
|
189
|
-
*/
|
|
190
|
-
conversationId: string | null;
|
|
191
|
-
/**
|
|
192
|
-
* The convai-side conversation id reported by ElevenLabs on connect.
|
|
193
|
-
* Always reflects the underlying transport id (or `null` while
|
|
194
|
-
* disconnected) regardless of whether the consumer supplied an id.
|
|
195
|
-
* Useful for log correlation against ElevenLabs dashboards even
|
|
196
|
-
* when the consumer is using their own ids on `conversationId`.
|
|
197
|
-
*/
|
|
198
|
-
convaiConversationId: string | null;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
3
|
/**
|
|
202
4
|
* Shared option / result types for `useChatConversation` across
|
|
203
5
|
* platforms.
|
|
@@ -413,228 +215,6 @@ interface BaseChatConversationResult {
|
|
|
413
215
|
conversationId: string | null;
|
|
414
216
|
}
|
|
415
217
|
|
|
416
|
-
/**
|
|
417
|
-
* Configuration surface for the `OrganicSphere` audio-reactive
|
|
418
|
-
* visualization. All values are plain numbers / strings / null so the
|
|
419
|
-
* whole object is JSON-serializable — save it, transport it, paste it
|
|
420
|
-
* into a preset library.
|
|
421
|
-
*
|
|
422
|
-
* The sphere renders four eased "variations" driven by frequency bands:
|
|
423
|
-
*
|
|
424
|
-
* low → modulates time-evolution speed (drift + noise phase)
|
|
425
|
-
* volume → drives `uDisplacementStrength` (how far each vertex pushes
|
|
426
|
-
* out from the sphere surface)
|
|
427
|
-
* medium → drives `uFresnelMultiplier` (how bright the lighting pass
|
|
428
|
-
* gets near silhouette edges)
|
|
429
|
-
* high → drives `uDistortionStrength` (large-scale warping of the
|
|
430
|
-
* underlying position field before displacement)
|
|
431
|
-
*
|
|
432
|
-
* Each variation has a resting `idle` value used when audio is off, a
|
|
433
|
-
* `gain` multiplier applied to the band level, a `floor` minimum while
|
|
434
|
-
* audio is playing, and separate attack / decay easing rates.
|
|
435
|
-
*
|
|
436
|
-
* Use `resolveOrganicSphereConfig(partial)` to merge a partial override
|
|
437
|
-
* into the defaults; `OrganicSphere` does this internally so consumers
|
|
438
|
-
* can pass any subset.
|
|
439
|
-
*/
|
|
440
|
-
interface BandReactivity {
|
|
441
|
-
/** Resting target used when no audio source is connected. */
|
|
442
|
-
idle: number;
|
|
443
|
-
/** Multiplier applied to the normalized band level (0–1) while audio plays. */
|
|
444
|
-
gain: number;
|
|
445
|
-
/** Minimum target while audio is playing, before easing. */
|
|
446
|
-
floor: number;
|
|
447
|
-
/**
|
|
448
|
-
* Easing rate when the target rises above `current` (snappier attack
|
|
449
|
-
* at higher values; per-ms-of-frame delta, not per-frame).
|
|
450
|
-
*/
|
|
451
|
-
attack: number;
|
|
452
|
-
/** Easing rate when the target falls below `current` (per-ms). */
|
|
453
|
-
decay: number;
|
|
454
|
-
}
|
|
455
|
-
interface OrganicSphereConfig {
|
|
456
|
-
/** Color of light A (default is a deep Shogo burnt orange). */
|
|
457
|
-
lightAColor: string;
|
|
458
|
-
/** Color of light B (default is a warm Shogo amber). */
|
|
459
|
-
lightBColor: string;
|
|
460
|
-
/** Intensity multiplier for light A. Higher = brighter contribution. */
|
|
461
|
-
lightAIntensity: number;
|
|
462
|
-
/** Intensity multiplier for light B. */
|
|
463
|
-
lightBIntensity: number;
|
|
464
|
-
/**
|
|
465
|
-
* Rim-highlight color. `null` falls back to `lightBColor`, which keeps
|
|
466
|
-
* the silhouette monochromatic and impossible to wash out to white.
|
|
467
|
-
*/
|
|
468
|
-
rimColor: string | null;
|
|
469
|
-
/**
|
|
470
|
-
* Fresnel value above which the rim starts contributing. Higher →
|
|
471
|
-
* tighter rim; lower → rim bleeds across more of the surface.
|
|
472
|
-
*/
|
|
473
|
-
rimThreshold: number;
|
|
474
|
-
/** Exponent on the rim falloff curve. Higher → sharper edge. */
|
|
475
|
-
rimPower: number;
|
|
476
|
-
/** Spatial frequency of the distortion noise (`uDistortionFrequency`). */
|
|
477
|
-
distortionFrequency: number;
|
|
478
|
-
/** Spatial frequency of the displacement noise (`uDisplacementFrequency`). */
|
|
479
|
-
displacementFrequency: number;
|
|
480
|
-
/** Fresnel offset — shifts where the rim and lighting gradient peak. */
|
|
481
|
-
fresnelOffset: number;
|
|
482
|
-
/** Fresnel power — steepens or softens the lighting gradient. */
|
|
483
|
-
fresnelPower: number;
|
|
484
|
-
/**
|
|
485
|
-
* Volume variation → `uDisplacementStrength`. Driven by the loudest
|
|
486
|
-
* of the first three bands (`max(l0, l1, l2)`).
|
|
487
|
-
*/
|
|
488
|
-
volume: BandReactivity;
|
|
489
|
-
/** Mid-band variation → `uFresnelMultiplier`. Driven by `l1`. */
|
|
490
|
-
medium: BandReactivity;
|
|
491
|
-
/** High-band variation → `uDistortionStrength`. Driven by `l2`. */
|
|
492
|
-
high: BandReactivity;
|
|
493
|
-
/**
|
|
494
|
-
* Low-band variation → time evolution speed (how fast the noise
|
|
495
|
-
* offset scrolls). Driven by `l0`.
|
|
496
|
-
*/
|
|
497
|
-
low: BandReactivity;
|
|
498
|
-
/** Camera z-position. Larger = more zoomed out. */
|
|
499
|
-
cameraZ: number;
|
|
500
|
-
/** Vertical field-of-view in degrees. */
|
|
501
|
-
fov: number;
|
|
502
|
-
/**
|
|
503
|
-
* Seed used to derive the initial "wander" offset phase, so identical
|
|
504
|
-
* audio produces identical visuals across playbacks. Any integer is
|
|
505
|
-
* fine; change it to roll a different starting pose. When `active`
|
|
506
|
-
* flips from `false` → `true`, the sphere resets to this phase.
|
|
507
|
-
*/
|
|
508
|
-
seed: number;
|
|
509
|
-
/**
|
|
510
|
-
* Sphere mesh subdivisions. Higher = smoother displacement, more GPU
|
|
511
|
-
* cost. Changing at runtime triggers a scene rebuild.
|
|
512
|
-
*/
|
|
513
|
-
subdivisions: number;
|
|
514
|
-
/**
|
|
515
|
-
* Device-pixel-ratio cap. `null` picks `min(devicePixelRatio, 2)`.
|
|
516
|
-
* Set to `1` for lower-end devices.
|
|
517
|
-
*/
|
|
518
|
-
maxPixelRatio: number | null;
|
|
519
|
-
/**
|
|
520
|
-
* Scene clear color. `null` keeps the canvas fully transparent so the
|
|
521
|
-
* sphere blends into the host UI.
|
|
522
|
-
*/
|
|
523
|
-
backgroundColor: string | null;
|
|
524
|
-
}
|
|
525
|
-
/**
|
|
526
|
-
* Preset tuned for Shogo's Voice Mode hero — warm Shogo orange palette,
|
|
527
|
-
* rim tied to `lightBColor`, camera zoomed back so the sphere reads
|
|
528
|
-
* "contained" rather than "looming", reactivity values copied from
|
|
529
|
-
* Bruno Simon's upstream `organic-sphere` demo so silhouettes animate
|
|
530
|
-
* faithfully.
|
|
531
|
-
*/
|
|
532
|
-
declare const DEFAULT_ORGANIC_SPHERE_CONFIG: OrganicSphereConfig;
|
|
533
|
-
/**
|
|
534
|
-
* Merge a partial override into `DEFAULT_ORGANIC_SPHERE_CONFIG`, doing a
|
|
535
|
-
* shallow merge on the root + per-band merge on `volume/medium/high/low`
|
|
536
|
-
* so consumers only need to specify what they want to change.
|
|
537
|
-
*/
|
|
538
|
-
declare function resolveOrganicSphereConfig(partial?: Partial<OrganicSphereConfig>): OrganicSphereConfig;
|
|
539
|
-
|
|
540
|
-
/**
|
|
541
|
-
* Configuration surface for the `OrganicParticles` audio-reactive
|
|
542
|
-
* visualization — a particle-cloud sibling of `OrganicSphere`.
|
|
543
|
-
*
|
|
544
|
-
* Shares the same `BandReactivity` shape and four-band model
|
|
545
|
-
* (volume / medium / high / low) as the sphere, so audio-tuning muscle
|
|
546
|
-
* memory carries over. What changes is the cloud-specific fields:
|
|
547
|
-
*
|
|
548
|
-
* volume → radial displacement (how far the cloud bursts outward)
|
|
549
|
-
* medium → particle size boost (how puffy each point renders)
|
|
550
|
-
* high → swirl strength (how much the cloud twists)
|
|
551
|
-
* low → time evolution speed (noise phase drift)
|
|
552
|
-
*
|
|
553
|
-
* Like `OrganicSphereConfig`, everything is JSON-serializable.
|
|
554
|
-
*/
|
|
555
|
-
|
|
556
|
-
interface OrganicParticlesConfig {
|
|
557
|
-
/**
|
|
558
|
-
* Number of particles. Changing this rebuilds the scene. Sweet spot
|
|
559
|
-
* for visual density without frame-drop is 20k–80k on a modern GPU.
|
|
560
|
-
*/
|
|
561
|
-
count: number;
|
|
562
|
-
/**
|
|
563
|
-
* Inner / outer radius of the seeded spawn shell. Particles are
|
|
564
|
-
* uniformly distributed between these two radii so the cloud has
|
|
565
|
-
* perceptible thickness rather than sitting on a single sphere.
|
|
566
|
-
*/
|
|
567
|
-
innerRadius: number;
|
|
568
|
-
outerRadius: number;
|
|
569
|
-
/** Spatial frequency of the Perlin noise warp. */
|
|
570
|
-
noiseFrequency: number;
|
|
571
|
-
/** Strength of the noise warp. */
|
|
572
|
-
noiseStrength: number;
|
|
573
|
-
/**
|
|
574
|
-
* Constant per-ms Y-axis rotation applied to the whole cloud,
|
|
575
|
-
* independent of audio. `0` (default) means the cloud is perfectly
|
|
576
|
-
* still when no audio plays. Positive = spin right, negative = left.
|
|
577
|
-
*/
|
|
578
|
-
rotationBias: number;
|
|
579
|
-
/**
|
|
580
|
-
* Rate (per ms) at which `uTime` advances the per-particle swirl
|
|
581
|
-
* angle in the shader, independent of audio. `0` (default) = swirl
|
|
582
|
-
* only responds to audio high-band + particle height.
|
|
583
|
-
*/
|
|
584
|
-
swirlTimeRate: number;
|
|
585
|
-
/**
|
|
586
|
-
* Rate (per ms) at which `uTime` advances while the cloud is idle
|
|
587
|
-
* (i.e. `active === false`). Lets the Perlin noise field keep
|
|
588
|
-
* shimmering subtly when nothing is playing so the cloud doesn't feel
|
|
589
|
-
* dead. `0` = fully frozen when paused. Default `0.0001` ≈ one full
|
|
590
|
-
* noise period every ~10 s — perceptible but not distracting.
|
|
591
|
-
*/
|
|
592
|
-
idleNoiseRate: number;
|
|
593
|
-
/** Base particle size (before audio boost / perspective scaling). */
|
|
594
|
-
sizeBase: number;
|
|
595
|
-
/**
|
|
596
|
-
* Edge softness of each particle sprite, in [0, 1]. `0` = hard disc,
|
|
597
|
-
* `1` = heavy feather/plasma. ~0.6 reads as "nebula".
|
|
598
|
-
*/
|
|
599
|
-
softness: number;
|
|
600
|
-
/** Overall opacity multiplier. */
|
|
601
|
-
opacity: number;
|
|
602
|
-
/** Color at the cloud core (low `vHeat`). */
|
|
603
|
-
colorCool: string;
|
|
604
|
-
/** Color at the cloud fringe (high `vHeat`). */
|
|
605
|
-
colorHot: string;
|
|
606
|
-
/** volume → radial displacement push. */
|
|
607
|
-
volume: BandReactivity;
|
|
608
|
-
/** medium → per-particle size boost. */
|
|
609
|
-
medium: BandReactivity;
|
|
610
|
-
/** high → swirl / twist amount. */
|
|
611
|
-
high: BandReactivity;
|
|
612
|
-
/** low → time evolution speed. */
|
|
613
|
-
low: BandReactivity;
|
|
614
|
-
cameraZ: number;
|
|
615
|
-
fov: number;
|
|
616
|
-
/**
|
|
617
|
-
* Seed used to generate the initial particle positions AND the wander
|
|
618
|
-
* phase. Same seed + same audio → same visual across playbacks.
|
|
619
|
-
*/
|
|
620
|
-
seed: number;
|
|
621
|
-
/** `null` picks `min(devicePixelRatio, 2)`. */
|
|
622
|
-
maxPixelRatio: number | null;
|
|
623
|
-
/** Scene clear color. `null` = transparent. */
|
|
624
|
-
backgroundColor: string | null;
|
|
625
|
-
}
|
|
626
|
-
/**
|
|
627
|
-
* Preset tuned to match the Shogo warm-orange palette used by
|
|
628
|
-
* `DEFAULT_ORGANIC_SPHERE_CONFIG`, so the two modes read as siblings.
|
|
629
|
-
* Count/size defaults target 60fps on mid-tier GPUs.
|
|
630
|
-
*/
|
|
631
|
-
declare const DEFAULT_ORGANIC_PARTICLES_CONFIG: OrganicParticlesConfig;
|
|
632
|
-
/**
|
|
633
|
-
* Merge a partial override into `DEFAULT_ORGANIC_PARTICLES_CONFIG`,
|
|
634
|
-
* with per-band shallow merges for `volume/medium/high/low`.
|
|
635
|
-
*/
|
|
636
|
-
declare function resolveOrganicParticlesConfig(partial?: Partial<OrganicParticlesConfig>): OrganicParticlesConfig;
|
|
637
|
-
|
|
638
218
|
/**
|
|
639
219
|
* GLSL shaders for the `OrganicSphere` audio-reactive visualization.
|
|
640
220
|
*
|
|
@@ -690,4 +270,4 @@ declare const ORGANIC_PARTICLES_VERTEX_SHADER = "\n\nvec4 permute(vec4 x){return
|
|
|
690
270
|
*/
|
|
691
271
|
declare const ORGANIC_PARTICLES_FRAGMENT_SHADER = "\nprecision mediump float;\n\nuniform vec3 uColorCool;\nuniform vec3 uColorHot;\nuniform float uOpacity;\nuniform float uSoftness;\n\nvarying float vHeat;\nvarying float vSeed;\n\nvoid main() {\n vec2 centered = gl_PointCoord - vec2(0.5);\n float distSq = dot(centered, centered);\n if (distSq > 0.25) discard;\n\n // Soft circular falloff. uSoftness in [0.5, 1] controls how hard the\n // edge is: 0.5 = sharp disc, 1 = feathered blob.\n float innerR = 0.25 * (1.0 - uSoftness);\n float alpha = smoothstep(0.25, innerR, distSq);\n\n // Warm/cool gradient, with a tiny seed-based tint wobble so the cloud\n // doesn't look banded.\n float wobble = (vSeed - 0.5) * 0.15;\n vec3 color = mix(uColorCool, uColorHot, clamp(vHeat + wobble, 0.0, 1.0));\n\n gl_FragColor = vec4(color, alpha * uOpacity);\n}\n";
|
|
692
272
|
|
|
693
|
-
export { type
|
|
273
|
+
export { type BaseChatConversationOptions as B, type ChatClientToolFn as C, ORGANIC_PARTICLES_FRAGMENT_SHADER as O, PERLIN_4D as P, type BaseChatConversationResult as a, type ChatConversationStatus as b, type ChatToolDescriptor as c, ORGANIC_PARTICLES_VERTEX_SHADER as d, ORGANIC_SPHERE_FRAGMENT_SHADER as e, ORGANIC_SPHERE_VERTEX_SHADER as f };
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration surface for the `OrganicSphere` audio-reactive
|
|
3
|
+
* visualization. All values are plain numbers / strings / null so the
|
|
4
|
+
* whole object is JSON-serializable — save it, transport it, paste it
|
|
5
|
+
* into a preset library.
|
|
6
|
+
*
|
|
7
|
+
* The sphere renders four eased "variations" driven by frequency bands:
|
|
8
|
+
*
|
|
9
|
+
* low → modulates time-evolution speed (drift + noise phase)
|
|
10
|
+
* volume → drives `uDisplacementStrength` (how far each vertex pushes
|
|
11
|
+
* out from the sphere surface)
|
|
12
|
+
* medium → drives `uFresnelMultiplier` (how bright the lighting pass
|
|
13
|
+
* gets near silhouette edges)
|
|
14
|
+
* high → drives `uDistortionStrength` (large-scale warping of the
|
|
15
|
+
* underlying position field before displacement)
|
|
16
|
+
*
|
|
17
|
+
* Each variation has a resting `idle` value used when audio is off, a
|
|
18
|
+
* `gain` multiplier applied to the band level, a `floor` minimum while
|
|
19
|
+
* audio is playing, and separate attack / decay easing rates.
|
|
20
|
+
*
|
|
21
|
+
* Use `resolveOrganicSphereConfig(partial)` to merge a partial override
|
|
22
|
+
* into the defaults; `OrganicSphere` does this internally so consumers
|
|
23
|
+
* can pass any subset.
|
|
24
|
+
*/
|
|
25
|
+
interface BandReactivity {
|
|
26
|
+
/** Resting target used when no audio source is connected. */
|
|
27
|
+
idle: number;
|
|
28
|
+
/** Multiplier applied to the normalized band level (0–1) while audio plays. */
|
|
29
|
+
gain: number;
|
|
30
|
+
/** Minimum target while audio is playing, before easing. */
|
|
31
|
+
floor: number;
|
|
32
|
+
/**
|
|
33
|
+
* Easing rate when the target rises above `current` (snappier attack
|
|
34
|
+
* at higher values; per-ms-of-frame delta, not per-frame).
|
|
35
|
+
*/
|
|
36
|
+
attack: number;
|
|
37
|
+
/** Easing rate when the target falls below `current` (per-ms). */
|
|
38
|
+
decay: number;
|
|
39
|
+
}
|
|
40
|
+
interface OrganicSphereConfig {
|
|
41
|
+
/** Color of light A (default is a deep Shogo burnt orange). */
|
|
42
|
+
lightAColor: string;
|
|
43
|
+
/** Color of light B (default is a warm Shogo amber). */
|
|
44
|
+
lightBColor: string;
|
|
45
|
+
/** Intensity multiplier for light A. Higher = brighter contribution. */
|
|
46
|
+
lightAIntensity: number;
|
|
47
|
+
/** Intensity multiplier for light B. */
|
|
48
|
+
lightBIntensity: number;
|
|
49
|
+
/**
|
|
50
|
+
* Rim-highlight color. `null` falls back to `lightBColor`, which keeps
|
|
51
|
+
* the silhouette monochromatic and impossible to wash out to white.
|
|
52
|
+
*/
|
|
53
|
+
rimColor: string | null;
|
|
54
|
+
/**
|
|
55
|
+
* Fresnel value above which the rim starts contributing. Higher →
|
|
56
|
+
* tighter rim; lower → rim bleeds across more of the surface.
|
|
57
|
+
*/
|
|
58
|
+
rimThreshold: number;
|
|
59
|
+
/** Exponent on the rim falloff curve. Higher → sharper edge. */
|
|
60
|
+
rimPower: number;
|
|
61
|
+
/** Spatial frequency of the distortion noise (`uDistortionFrequency`). */
|
|
62
|
+
distortionFrequency: number;
|
|
63
|
+
/** Spatial frequency of the displacement noise (`uDisplacementFrequency`). */
|
|
64
|
+
displacementFrequency: number;
|
|
65
|
+
/** Fresnel offset — shifts where the rim and lighting gradient peak. */
|
|
66
|
+
fresnelOffset: number;
|
|
67
|
+
/** Fresnel power — steepens or softens the lighting gradient. */
|
|
68
|
+
fresnelPower: number;
|
|
69
|
+
/**
|
|
70
|
+
* Volume variation → `uDisplacementStrength`. Driven by the loudest
|
|
71
|
+
* of the first three bands (`max(l0, l1, l2)`).
|
|
72
|
+
*/
|
|
73
|
+
volume: BandReactivity;
|
|
74
|
+
/** Mid-band variation → `uFresnelMultiplier`. Driven by `l1`. */
|
|
75
|
+
medium: BandReactivity;
|
|
76
|
+
/** High-band variation → `uDistortionStrength`. Driven by `l2`. */
|
|
77
|
+
high: BandReactivity;
|
|
78
|
+
/**
|
|
79
|
+
* Low-band variation → time evolution speed (how fast the noise
|
|
80
|
+
* offset scrolls). Driven by `l0`.
|
|
81
|
+
*/
|
|
82
|
+
low: BandReactivity;
|
|
83
|
+
/** Camera z-position. Larger = more zoomed out. */
|
|
84
|
+
cameraZ: number;
|
|
85
|
+
/** Vertical field-of-view in degrees. */
|
|
86
|
+
fov: number;
|
|
87
|
+
/**
|
|
88
|
+
* Seed used to derive the initial "wander" offset phase, so identical
|
|
89
|
+
* audio produces identical visuals across playbacks. Any integer is
|
|
90
|
+
* fine; change it to roll a different starting pose. When `active`
|
|
91
|
+
* flips from `false` → `true`, the sphere resets to this phase.
|
|
92
|
+
*/
|
|
93
|
+
seed: number;
|
|
94
|
+
/**
|
|
95
|
+
* Sphere mesh subdivisions. Higher = smoother displacement, more GPU
|
|
96
|
+
* cost. Changing at runtime triggers a scene rebuild.
|
|
97
|
+
*/
|
|
98
|
+
subdivisions: number;
|
|
99
|
+
/**
|
|
100
|
+
* Device-pixel-ratio cap. `null` picks `min(devicePixelRatio, 2)`.
|
|
101
|
+
* Set to `1` for lower-end devices.
|
|
102
|
+
*/
|
|
103
|
+
maxPixelRatio: number | null;
|
|
104
|
+
/**
|
|
105
|
+
* Scene clear color. `null` keeps the canvas fully transparent so the
|
|
106
|
+
* sphere blends into the host UI.
|
|
107
|
+
*/
|
|
108
|
+
backgroundColor: string | null;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Preset tuned for Shogo's Voice Mode hero — warm Shogo orange palette,
|
|
112
|
+
* rim tied to `lightBColor`, camera zoomed back so the sphere reads
|
|
113
|
+
* "contained" rather than "looming", reactivity values copied from
|
|
114
|
+
* Bruno Simon's upstream `organic-sphere` demo so silhouettes animate
|
|
115
|
+
* faithfully.
|
|
116
|
+
*/
|
|
117
|
+
declare const DEFAULT_ORGANIC_SPHERE_CONFIG: OrganicSphereConfig;
|
|
118
|
+
/**
|
|
119
|
+
* Merge a partial override into `DEFAULT_ORGANIC_SPHERE_CONFIG`, doing a
|
|
120
|
+
* shallow merge on the root + per-band merge on `volume/medium/high/low`
|
|
121
|
+
* so consumers only need to specify what they want to change.
|
|
122
|
+
*/
|
|
123
|
+
declare function resolveOrganicSphereConfig(partial?: Partial<OrganicSphereConfig>): OrganicSphereConfig;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Configuration surface for the `OrganicParticles` audio-reactive
|
|
127
|
+
* visualization — a particle-cloud sibling of `OrganicSphere`.
|
|
128
|
+
*
|
|
129
|
+
* Shares the same `BandReactivity` shape and four-band model
|
|
130
|
+
* (volume / medium / high / low) as the sphere, so audio-tuning muscle
|
|
131
|
+
* memory carries over. What changes is the cloud-specific fields:
|
|
132
|
+
*
|
|
133
|
+
* volume → radial displacement (how far the cloud bursts outward)
|
|
134
|
+
* medium → particle size boost (how puffy each point renders)
|
|
135
|
+
* high → swirl strength (how much the cloud twists)
|
|
136
|
+
* low → time evolution speed (noise phase drift)
|
|
137
|
+
*
|
|
138
|
+
* Like `OrganicSphereConfig`, everything is JSON-serializable.
|
|
139
|
+
*/
|
|
140
|
+
|
|
141
|
+
interface OrganicParticlesConfig {
|
|
142
|
+
/**
|
|
143
|
+
* Number of particles. Changing this rebuilds the scene. Sweet spot
|
|
144
|
+
* for visual density without frame-drop is 20k–80k on a modern GPU.
|
|
145
|
+
*/
|
|
146
|
+
count: number;
|
|
147
|
+
/**
|
|
148
|
+
* Inner / outer radius of the seeded spawn shell. Particles are
|
|
149
|
+
* uniformly distributed between these two radii so the cloud has
|
|
150
|
+
* perceptible thickness rather than sitting on a single sphere.
|
|
151
|
+
*/
|
|
152
|
+
innerRadius: number;
|
|
153
|
+
outerRadius: number;
|
|
154
|
+
/** Spatial frequency of the Perlin noise warp. */
|
|
155
|
+
noiseFrequency: number;
|
|
156
|
+
/** Strength of the noise warp. */
|
|
157
|
+
noiseStrength: number;
|
|
158
|
+
/**
|
|
159
|
+
* Constant per-ms Y-axis rotation applied to the whole cloud,
|
|
160
|
+
* independent of audio. `0` (default) means the cloud is perfectly
|
|
161
|
+
* still when no audio plays. Positive = spin right, negative = left.
|
|
162
|
+
*/
|
|
163
|
+
rotationBias: number;
|
|
164
|
+
/**
|
|
165
|
+
* Rate (per ms) at which `uTime` advances the per-particle swirl
|
|
166
|
+
* angle in the shader, independent of audio. `0` (default) = swirl
|
|
167
|
+
* only responds to audio high-band + particle height.
|
|
168
|
+
*/
|
|
169
|
+
swirlTimeRate: number;
|
|
170
|
+
/**
|
|
171
|
+
* Rate (per ms) at which `uTime` advances while the cloud is idle
|
|
172
|
+
* (i.e. `active === false`). Lets the Perlin noise field keep
|
|
173
|
+
* shimmering subtly when nothing is playing so the cloud doesn't feel
|
|
174
|
+
* dead. `0` = fully frozen when paused. Default `0.0001` ≈ one full
|
|
175
|
+
* noise period every ~10 s — perceptible but not distracting.
|
|
176
|
+
*/
|
|
177
|
+
idleNoiseRate: number;
|
|
178
|
+
/** Base particle size (before audio boost / perspective scaling). */
|
|
179
|
+
sizeBase: number;
|
|
180
|
+
/**
|
|
181
|
+
* Edge softness of each particle sprite, in [0, 1]. `0` = hard disc,
|
|
182
|
+
* `1` = heavy feather/plasma. ~0.6 reads as "nebula".
|
|
183
|
+
*/
|
|
184
|
+
softness: number;
|
|
185
|
+
/** Overall opacity multiplier. */
|
|
186
|
+
opacity: number;
|
|
187
|
+
/** Color at the cloud core (low `vHeat`). */
|
|
188
|
+
colorCool: string;
|
|
189
|
+
/** Color at the cloud fringe (high `vHeat`). */
|
|
190
|
+
colorHot: string;
|
|
191
|
+
/** volume → radial displacement push. */
|
|
192
|
+
volume: BandReactivity;
|
|
193
|
+
/** medium → per-particle size boost. */
|
|
194
|
+
medium: BandReactivity;
|
|
195
|
+
/** high → swirl / twist amount. */
|
|
196
|
+
high: BandReactivity;
|
|
197
|
+
/** low → time evolution speed. */
|
|
198
|
+
low: BandReactivity;
|
|
199
|
+
cameraZ: number;
|
|
200
|
+
fov: number;
|
|
201
|
+
/**
|
|
202
|
+
* Seed used to generate the initial particle positions AND the wander
|
|
203
|
+
* phase. Same seed + same audio → same visual across playbacks.
|
|
204
|
+
*/
|
|
205
|
+
seed: number;
|
|
206
|
+
/** `null` picks `min(devicePixelRatio, 2)`. */
|
|
207
|
+
maxPixelRatio: number | null;
|
|
208
|
+
/** Scene clear color. `null` = transparent. */
|
|
209
|
+
backgroundColor: string | null;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Preset tuned to match the Shogo warm-orange palette used by
|
|
213
|
+
* `DEFAULT_ORGANIC_SPHERE_CONFIG`, so the two modes read as siblings.
|
|
214
|
+
* Count/size defaults target 60fps on mid-tier GPUs.
|
|
215
|
+
*/
|
|
216
|
+
declare const DEFAULT_ORGANIC_PARTICLES_CONFIG: OrganicParticlesConfig;
|
|
217
|
+
/**
|
|
218
|
+
* Merge a partial override into `DEFAULT_ORGANIC_PARTICLES_CONFIG`,
|
|
219
|
+
* with per-band shallow merges for `volume/medium/high/low`.
|
|
220
|
+
*/
|
|
221
|
+
declare function resolveOrganicParticlesConfig(partial?: Partial<OrganicParticlesConfig>): OrganicParticlesConfig;
|
|
222
|
+
|
|
223
|
+
export { type BandReactivity as B, DEFAULT_ORGANIC_PARTICLES_CONFIG as D, type OrganicParticlesConfig as O, DEFAULT_ORGANIC_SPHERE_CONFIG as a, type OrganicSphereConfig as b, resolveOrganicSphereConfig as c, resolveOrganicParticlesConfig as r };
|