@backbay/glia-agent 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,25 @@
1
+ import {
2
+ CognitionController,
3
+ CognitionSnapshotSchema,
4
+ CognitionStateSchema,
5
+ MODE_TRANSITION_MAP,
6
+ clamp01,
7
+ createInitialCognitionState,
8
+ reduceDecay,
9
+ reduceEvent,
10
+ useCognition,
11
+ validateCognitionSnapshot
12
+ } from "./chunk-LLOGBVQT.js";
13
+ export {
14
+ CognitionController,
15
+ CognitionSnapshotSchema,
16
+ CognitionStateSchema,
17
+ MODE_TRANSITION_MAP,
18
+ clamp01,
19
+ createInitialCognitionState,
20
+ reduceDecay,
21
+ reduceEvent,
22
+ useCognition,
23
+ validateCognitionSnapshot
24
+ };
25
+ //# sourceMappingURL=cognition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,288 @@
1
+ import { b as AnchorState, A as AVO, M as MicroExpressionConfig, L as LegacyGlyphState, V as VisualState, E as EasingFunction, T as TransitionOptions, c as EmotionEvent } from './types-B0jyNVTH.js';
2
+ export { a as AVODimensions } from './types-B0jyNVTH.js';
3
+
4
+ /**
5
+ * Validate AVO dimensions are in valid range
6
+ */
7
+ declare function isValidAVO(avo: AVO): boolean;
8
+ /**
9
+ * Clamp AVO dimensions to valid range
10
+ */
11
+ declare function clampAVO(avo: Partial<AVO>): AVO;
12
+ /**
13
+ * Named anchor states with AVO coordinates
14
+ */
15
+ declare const ANCHOR_STATES: Record<AnchorState, AVO>;
16
+ /**
17
+ * Map legacy GlyphState to anchor states
18
+ */
19
+ declare const LEGACY_STATE_MAP: Record<LegacyGlyphState, AnchorState>;
20
+ /**
21
+ * Default micro-expression configuration
22
+ */
23
+ declare const DEFAULT_MICRO_CONFIG: MicroExpressionConfig;
24
+ /**
25
+ * Default transition durations by type (ms)
26
+ */
27
+ declare const DEFAULT_TRANSITION_DURATIONS: {
28
+ readonly micro: 150;
29
+ readonly standard: 400;
30
+ readonly mood: 800;
31
+ readonly major: 1200;
32
+ };
33
+ /**
34
+ * Default AVO state (idle equivalent)
35
+ */
36
+ declare const DEFAULT_AVO: AVO;
37
+
38
+ /**
39
+ * Linear interpolation
40
+ */
41
+ declare function lerp(a: number, b: number, t: number): number;
42
+ /**
43
+ * Map Arousal (0-1) to temporal visual properties
44
+ */
45
+ declare function mapArousal(a: number): {
46
+ breathingRate: number;
47
+ breathingAmplitude: number;
48
+ ringRotationSpeed: number;
49
+ particleVelocity: number;
50
+ particleCount: number;
51
+ glowPulseRate: number;
52
+ };
53
+ /**
54
+ * Map Valence (0-1) to qualitative visual properties
55
+ */
56
+ declare function mapValence(v: number): {
57
+ coreHue: number;
58
+ coreSaturation: number;
59
+ motionNoise: number;
60
+ scaleFactor: number;
61
+ emissiveIntensity: number;
62
+ };
63
+ /**
64
+ * Map Openness (0-1) to spatial visual properties
65
+ */
66
+ declare function mapOpenness(o: number): {
67
+ particleFlowDirection: number;
68
+ particleSpreadAngle: number;
69
+ breathingPhaseBias: number;
70
+ ringTilt: number;
71
+ auraExpansion: number;
72
+ };
73
+ /**
74
+ * Compute complete visual state from AVO dimensions
75
+ */
76
+ declare function computeVisualState(avo: AVO): VisualState;
77
+ /**
78
+ * Compute Euclidean distance between two AVO states
79
+ */
80
+ declare function avoDistance(a: AVO, b: AVO): number;
81
+ /**
82
+ * Blend between two AVO states
83
+ */
84
+ declare function blendAVO(from: AVO, to: AVO, t: number): AVO;
85
+ /**
86
+ * Calculate animation weights for all legacy states based on distance to current AVO.
87
+ * Uses inverse distance weighting with falloff - states closer in AVO space get higher weights.
88
+ * Weights are normalized to sum to 1.0 (or all zero if no state is close enough).
89
+ */
90
+ declare function getAnimationWeights(currentAVO: AVO): Record<LegacyGlyphState, number>;
91
+
92
+ /**
93
+ * Apply easing function to progress value (clamped 0-1)
94
+ */
95
+ declare function ease(fn: EasingFunction, t: number): number;
96
+ /**
97
+ * Calculate appropriate transition duration based on AVO change
98
+ * Returns duration in milliseconds
99
+ * - Urgent (200ms) for sudden negative changes (e.g., error states)
100
+ * - Recovery uses longer duration with distance factor
101
+ * - Default: proportional to AVO distance
102
+ */
103
+ declare function getTransitionDuration(from: AVO, to: AVO): number;
104
+ /**
105
+ * Get recommended easing for a transition based on emotional context
106
+ * - Urgent negative: fast out (easeOut)
107
+ * - Recovery: springy for natural bounce-back
108
+ * - Default: smooth in-out
109
+ */
110
+ declare function getTransitionEasing(from: AVO, to: AVO): EasingFunction;
111
+ /**
112
+ * Get complete transition config with duration, easing, and onComplete callback
113
+ */
114
+ declare function getTransitionConfig(from: AVO, to: AVO): Required<TransitionOptions>;
115
+
116
+ /**
117
+ * Create a smooth noise generator (Perlin-like)
118
+ * Returns values between -1 and 1
119
+ */
120
+ declare function createNoiseGenerator(seed?: number): (t: number) => number;
121
+ /**
122
+ * Apply micro-expression variations to base AVO state
123
+ */
124
+ declare function applyMicroExpression(base: AVO, config: MicroExpressionConfig, time: number): AVO;
125
+ /**
126
+ * Create a micro-expression animator that tracks time internally
127
+ */
128
+ declare function createMicroExpressionAnimator(config: MicroExpressionConfig): {
129
+ tick(deltaMs: number): void;
130
+ apply(base: AVO): AVO;
131
+ reset(): void;
132
+ };
133
+
134
+ type EventHandler<T> = (data: T) => void;
135
+ interface EmotionControllerEvents {
136
+ change: AVO;
137
+ transitionStart: {
138
+ from: AVO;
139
+ to: AVO;
140
+ };
141
+ transitionEnd: AVO;
142
+ anchorReached: AnchorState;
143
+ }
144
+ interface EmotionControllerOptions {
145
+ initial?: Partial<AVO>;
146
+ initialAnchor?: AnchorState;
147
+ microExpressions?: boolean | MicroExpressionConfig;
148
+ }
149
+ /**
150
+ * EmotionController manages the emotional state lifecycle for the Glyph character.
151
+ *
152
+ * It handles:
153
+ * - AVO dimension state (Arousal, Valence, Openness)
154
+ * - Smooth transitions between states with configurable easing
155
+ * - Micro-expression overlays for natural movement
156
+ * - Event-driven state changes from agent behaviors
157
+ * - Visual state computation for rendering
158
+ */
159
+ declare class EmotionController {
160
+ private _dimensions;
161
+ private _transition;
162
+ private _microConfig;
163
+ private _time;
164
+ private _listeners;
165
+ private _disposed;
166
+ constructor(options?: EmotionControllerOptions);
167
+ /**
168
+ * Get current base dimensions (without micro-expressions)
169
+ */
170
+ getDimensions(): AVO;
171
+ /**
172
+ * Get current dimensions with micro-expressions applied
173
+ */
174
+ getAnimatedDimensions(): AVO;
175
+ /**
176
+ * Get computed visual state for rendering
177
+ */
178
+ getVisualState(): VisualState;
179
+ /**
180
+ * Set dimensions immediately (no transition)
181
+ * Values are clamped to valid 0-1 range
182
+ */
183
+ setDimensions(dims: Partial<AVO>): void;
184
+ /**
185
+ * Transition to target dimensions over time
186
+ * Auto-calculates duration and easing if not specified
187
+ */
188
+ transitionTo(target: Partial<AVO>, options?: TransitionOptions): void;
189
+ /**
190
+ * Transition to a named anchor state
191
+ * Emits anchorReached when transition completes
192
+ */
193
+ transitionToAnchor(anchor: AnchorState, options?: TransitionOptions): void;
194
+ /**
195
+ * Handle emotion events from agent behaviors
196
+ * Maps event types to appropriate anchor transitions
197
+ */
198
+ handleEvent(event: EmotionEvent): void;
199
+ /**
200
+ * Blend toward target dimensions by a factor (0-1)
201
+ * Useful for continuous input-driven changes
202
+ */
203
+ blendToward(target: Partial<AVO>, factor: number): void;
204
+ /**
205
+ * Check if currently transitioning
206
+ */
207
+ isTransitioning(): boolean;
208
+ /**
209
+ * Cancel current transition, keeping current position
210
+ */
211
+ cancelTransition(): void;
212
+ /**
213
+ * Subscribe to controller events
214
+ * Returns unsubscribe function
215
+ */
216
+ on<K extends keyof EmotionControllerEvents>(event: K, handler: EventHandler<EmotionControllerEvents[K]>): () => void;
217
+ /**
218
+ * Update tick - call each frame with delta time in milliseconds
219
+ * Advances transitions and micro-expression time
220
+ */
221
+ tick(deltaMs: number): void;
222
+ /**
223
+ * Dispose controller and clean up resources
224
+ */
225
+ dispose(): void;
226
+ private _emit;
227
+ }
228
+
229
+ interface UseEmotionOptions {
230
+ /** Initial dimensions */
231
+ initial?: Partial<AVO>;
232
+ /** Initial anchor state (overrides initial) */
233
+ initialAnchor?: AnchorState;
234
+ /** Enable micro-expressions (boolean or config object) */
235
+ microExpressions?: boolean | MicroExpressionConfig;
236
+ /** Callback on dimension change */
237
+ onChange?: (dimensions: AVO) => void;
238
+ /** Auto-tick with requestAnimationFrame (default: true) */
239
+ autoTick?: boolean;
240
+ }
241
+ interface UseEmotionResult {
242
+ /** Current dimensions (with micro-expressions if enabled) */
243
+ dimensions: AVO;
244
+ /** Base dimensions (without micro-expressions) */
245
+ baseDimensions: AVO;
246
+ /** Computed visual properties */
247
+ visualState: VisualState;
248
+ /** Set dimensions instantly */
249
+ set: (dimensions: Partial<AVO>) => void;
250
+ /** Transition to dimensions */
251
+ transition: (dimensions: Partial<AVO>, options?: TransitionOptions) => void;
252
+ /** Transition to anchor state */
253
+ goTo: (anchor: AnchorState, options?: TransitionOptions) => void;
254
+ /** Handle emotion event */
255
+ emit: (event: EmotionEvent) => void;
256
+ /** Currently transitioning */
257
+ isTransitioning: boolean;
258
+ /** Manual tick (if autoTick disabled) */
259
+ tick: (deltaMs: number) => void;
260
+ }
261
+ /**
262
+ * React hook for managing Glyph emotion state.
263
+ *
264
+ * Creates an EmotionController and provides reactive state updates.
265
+ * Automatically handles RAF-based animation when autoTick is true (default).
266
+ *
267
+ * @example
268
+ * ```tsx
269
+ * const { dimensions, visualState, goTo, emit } = useEmotion({
270
+ * initialAnchor: 'idle',
271
+ * onChange: (dims) => console.log('Emotion changed:', dims),
272
+ * });
273
+ *
274
+ * // Transition to a named state
275
+ * goTo('thinking');
276
+ *
277
+ * // Handle agent events
278
+ * emit({ type: 'processing_complete' });
279
+ *
280
+ * // Apply visual state to rendering
281
+ * <mesh scale={visualState.scaleFactor}>
282
+ * <meshStandardMaterial color={`hsl(${visualState.coreHue}, 80%, 50%)`} />
283
+ * </mesh>
284
+ * ```
285
+ */
286
+ declare function useEmotion(options?: UseEmotionOptions): UseEmotionResult;
287
+
288
+ export { ANCHOR_STATES, AVO, AnchorState, DEFAULT_AVO, DEFAULT_MICRO_CONFIG, DEFAULT_TRANSITION_DURATIONS, EasingFunction, EmotionController, type EmotionControllerOptions, EmotionEvent, LEGACY_STATE_MAP, LegacyGlyphState, MicroExpressionConfig, TransitionOptions, type UseEmotionOptions, type UseEmotionResult, VisualState, applyMicroExpression, avoDistance, blendAVO, clampAVO, computeVisualState, createMicroExpressionAnimator, createNoiseGenerator, ease, getAnimationWeights, getTransitionConfig, getTransitionDuration, getTransitionEasing, isValidAVO, lerp, mapArousal, mapOpenness, mapValence, useEmotion };
@@ -0,0 +1,53 @@
1
+ import {
2
+ ANCHOR_STATES,
3
+ DEFAULT_AVO,
4
+ DEFAULT_MICRO_CONFIG,
5
+ DEFAULT_TRANSITION_DURATIONS,
6
+ EmotionController,
7
+ LEGACY_STATE_MAP,
8
+ applyMicroExpression,
9
+ avoDistance,
10
+ blendAVO,
11
+ clampAVO,
12
+ computeVisualState,
13
+ createMicroExpressionAnimator,
14
+ createNoiseGenerator,
15
+ ease,
16
+ getAnimationWeights,
17
+ getTransitionConfig,
18
+ getTransitionDuration,
19
+ getTransitionEasing,
20
+ isValidAVO,
21
+ lerp,
22
+ mapArousal,
23
+ mapOpenness,
24
+ mapValence,
25
+ useEmotion
26
+ } from "./chunk-VU2XK2NI.js";
27
+ export {
28
+ ANCHOR_STATES,
29
+ DEFAULT_AVO,
30
+ DEFAULT_MICRO_CONFIG,
31
+ DEFAULT_TRANSITION_DURATIONS,
32
+ EmotionController,
33
+ LEGACY_STATE_MAP,
34
+ applyMicroExpression,
35
+ avoDistance,
36
+ blendAVO,
37
+ clampAVO,
38
+ computeVisualState,
39
+ createMicroExpressionAnimator,
40
+ createNoiseGenerator,
41
+ ease,
42
+ getAnimationWeights,
43
+ getTransitionConfig,
44
+ getTransitionDuration,
45
+ getTransitionEasing,
46
+ isValidAVO,
47
+ lerp,
48
+ mapArousal,
49
+ mapOpenness,
50
+ mapValence,
51
+ useEmotion
52
+ };
53
+ //# sourceMappingURL=emotion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}