@affectively/aeon-pages-runtime 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.
- package/dist/cache.d.ts +94 -0
- package/dist/durable-object.d.ts +79 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +9497 -0
- package/dist/navigation.d.ts +124 -0
- package/dist/predictor.d.ts +121 -0
- package/dist/registry.d.ts +79 -0
- package/dist/router/context-extractor.d.ts +31 -0
- package/dist/router/esi-control-react.d.ts +248 -0
- package/dist/router/esi-control.d.ts +161 -0
- package/dist/router/esi-react.d.ts +198 -0
- package/dist/router/esi.d.ts +44 -0
- package/dist/router/heuristic-adapter.d.ts +57 -0
- package/dist/router/index.d.ts +24 -0
- package/dist/router/index.js +3515 -0
- package/dist/router/speculation.d.ts +91 -0
- package/dist/router/types.d.ts +305 -0
- package/dist/router.d.ts +56 -0
- package/dist/server.d.ts +25 -0
- package/dist/server.js +8065 -0
- package/dist/service-worker.d.ts +12 -0
- package/dist/storage.d.ts +354 -0
- package/dist/types.d.ts +161 -0
- package/package.json +63 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESI Control Language
|
|
3
|
+
*
|
|
4
|
+
* Adds conditional display and structured output validation to ESI.
|
|
5
|
+
* Uses Zod for schema validation to ensure trusted, typed results.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* // Conditional display based on inference
|
|
10
|
+
* <ESI.If
|
|
11
|
+
* prompt="Is this user likely to churn?"
|
|
12
|
+
* schema={z.object({ likelihood: z.number(), reason: z.string() })}
|
|
13
|
+
* when={(result) => result.likelihood > 0.7}
|
|
14
|
+
* >
|
|
15
|
+
* <RetentionOffer />
|
|
16
|
+
* </ESI.If>
|
|
17
|
+
*
|
|
18
|
+
* // Structured output with Zod
|
|
19
|
+
* <ESI.Infer
|
|
20
|
+
* schema={z.object({
|
|
21
|
+
* sentiment: z.enum(['positive', 'negative', 'neutral']),
|
|
22
|
+
* confidence: z.number(),
|
|
23
|
+
* topics: z.array(z.string()),
|
|
24
|
+
* })}
|
|
25
|
+
* >
|
|
26
|
+
* Analyze this text: {userInput}
|
|
27
|
+
* </ESI.Infer>
|
|
28
|
+
*
|
|
29
|
+
* // Switch/match on inference result
|
|
30
|
+
* <ESI.Match
|
|
31
|
+
* prompt="Classify user intent"
|
|
32
|
+
* schema={z.object({ intent: z.enum(['browse', 'buy', 'support', 'leave']) })}
|
|
33
|
+
* >
|
|
34
|
+
* <ESI.Case match={(r) => r.intent === 'buy'}><CheckoutCTA /></ESI.Case>
|
|
35
|
+
* <ESI.Case match={(r) => r.intent === 'support'}><HelpWidget /></ESI.Case>
|
|
36
|
+
* <ESI.Default><BrowsePrompt /></ESI.Default>
|
|
37
|
+
* </ESI.Match>
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
import type { ZodType, ZodTypeDef } from 'zod';
|
|
41
|
+
import type { ESIDirective, ESIParams, ESIResult, UserContext } from './types';
|
|
42
|
+
/**
|
|
43
|
+
* ESI with Zod schema for validated, typed output
|
|
44
|
+
*/
|
|
45
|
+
export interface ESISchemaParams<T> extends Omit<ESIParams, 'model'> {
|
|
46
|
+
/** Zod schema for output validation */
|
|
47
|
+
schema: ZodType<T, ZodTypeDef, unknown>;
|
|
48
|
+
/** Model defaults to 'llm' for structured output */
|
|
49
|
+
model?: 'llm';
|
|
50
|
+
/** Retry on validation failure */
|
|
51
|
+
retryOnValidationError?: boolean;
|
|
52
|
+
/** Max retries */
|
|
53
|
+
maxRetries?: number;
|
|
54
|
+
}
|
|
55
|
+
export interface ESISchemaResult<T> extends Omit<ESIResult, 'output'> {
|
|
56
|
+
/** Validated, typed output */
|
|
57
|
+
data?: T;
|
|
58
|
+
/** Raw output before validation */
|
|
59
|
+
rawOutput?: string;
|
|
60
|
+
/** Validation errors if any */
|
|
61
|
+
validationErrors?: string[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Condition function type
|
|
65
|
+
*/
|
|
66
|
+
export type ESICondition<T> = (result: T, context: UserContext) => boolean;
|
|
67
|
+
/**
|
|
68
|
+
* ESI.If directive - conditional rendering based on inference
|
|
69
|
+
*/
|
|
70
|
+
export interface ESIIfDirective<T> {
|
|
71
|
+
/** Unique ID */
|
|
72
|
+
id: string;
|
|
73
|
+
/** Prompt to evaluate */
|
|
74
|
+
prompt: string;
|
|
75
|
+
/** Schema for structured output */
|
|
76
|
+
schema: ZodType<T, ZodTypeDef, unknown>;
|
|
77
|
+
/** Condition to check */
|
|
78
|
+
when: ESICondition<T>;
|
|
79
|
+
/** Inference params */
|
|
80
|
+
params?: Partial<ESIParams>;
|
|
81
|
+
/** Cache the condition result */
|
|
82
|
+
cacheCondition?: boolean;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* ESI.Match directive - switch/case based on inference
|
|
86
|
+
*/
|
|
87
|
+
export interface ESIMatchDirective<T> {
|
|
88
|
+
/** Unique ID */
|
|
89
|
+
id: string;
|
|
90
|
+
/** Prompt to evaluate */
|
|
91
|
+
prompt: string;
|
|
92
|
+
/** Schema for structured output */
|
|
93
|
+
schema: ZodType<T, ZodTypeDef, unknown>;
|
|
94
|
+
/** Cases to match */
|
|
95
|
+
cases: Array<{
|
|
96
|
+
match: ESICondition<T>;
|
|
97
|
+
id: string;
|
|
98
|
+
}>;
|
|
99
|
+
/** Default case ID if no match */
|
|
100
|
+
defaultCase?: string;
|
|
101
|
+
/** Inference params */
|
|
102
|
+
params?: Partial<ESIParams>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Result of control flow evaluation
|
|
106
|
+
*/
|
|
107
|
+
export interface ESIControlResult<T> {
|
|
108
|
+
/** The directive ID */
|
|
109
|
+
id: string;
|
|
110
|
+
/** Whether condition was met (for If) */
|
|
111
|
+
conditionMet?: boolean;
|
|
112
|
+
/** Matched case ID (for Match) */
|
|
113
|
+
matchedCase?: string;
|
|
114
|
+
/** The validated data */
|
|
115
|
+
data?: T;
|
|
116
|
+
/** Inference result */
|
|
117
|
+
inferenceResult: ESISchemaResult<T>;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Generate a JSON schema prompt suffix for structured output
|
|
121
|
+
*/
|
|
122
|
+
export declare function generateSchemaPrompt<T>(schema: ZodType<T, ZodTypeDef, unknown>): string;
|
|
123
|
+
/**
|
|
124
|
+
* Parse and validate LLM output against a Zod schema
|
|
125
|
+
*/
|
|
126
|
+
export declare function parseWithSchema<T>(output: string, schema: ZodType<T, ZodTypeDef, unknown>): {
|
|
127
|
+
success: true;
|
|
128
|
+
data: T;
|
|
129
|
+
} | {
|
|
130
|
+
success: false;
|
|
131
|
+
errors: string[];
|
|
132
|
+
};
|
|
133
|
+
export interface ESIControlProcessor {
|
|
134
|
+
/**
|
|
135
|
+
* Process an ESI.If directive
|
|
136
|
+
*/
|
|
137
|
+
processIf<T>(directive: ESIIfDirective<T>, context: UserContext): Promise<ESIControlResult<T>>;
|
|
138
|
+
/**
|
|
139
|
+
* Process an ESI.Match directive
|
|
140
|
+
*/
|
|
141
|
+
processMatch<T>(directive: ESIMatchDirective<T>, context: UserContext): Promise<ESIControlResult<T>>;
|
|
142
|
+
/**
|
|
143
|
+
* Process an ESI directive with schema validation
|
|
144
|
+
*/
|
|
145
|
+
processWithSchema<T>(prompt: string, schema: ZodType<T, ZodTypeDef, unknown>, params: Partial<ESIParams>, context: UserContext): Promise<ESISchemaResult<T>>;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Create a control processor that wraps an ESI processor
|
|
149
|
+
*/
|
|
150
|
+
export declare function createControlProcessor(processESI: (directive: ESIDirective, context: UserContext) => Promise<ESIResult>): ESIControlProcessor;
|
|
151
|
+
/**
|
|
152
|
+
* Create an ESI.If directive
|
|
153
|
+
*/
|
|
154
|
+
export declare function esiIf<T>(prompt: string, schema: ZodType<T, ZodTypeDef, unknown>, when: ESICondition<T>, options?: Partial<ESIParams>): ESIIfDirective<T>;
|
|
155
|
+
/**
|
|
156
|
+
* Create an ESI.Match directive
|
|
157
|
+
*/
|
|
158
|
+
export declare function esiMatch<T>(prompt: string, schema: ZodType<T, ZodTypeDef, unknown>, cases: Array<{
|
|
159
|
+
match: ESICondition<T>;
|
|
160
|
+
id: string;
|
|
161
|
+
}>, defaultCase?: string, options?: Partial<ESIParams>): ESIMatchDirective<T>;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESI React Components
|
|
3
|
+
*
|
|
4
|
+
* Bring AI to templates with declarative components.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* import { ESI } from '@affectively/aeon-flux/esi';
|
|
9
|
+
*
|
|
10
|
+
* function PersonalizedGreeting() {
|
|
11
|
+
* return (
|
|
12
|
+
* <ESI.Infer
|
|
13
|
+
* model="llm"
|
|
14
|
+
* contextAware
|
|
15
|
+
* signals={['emotion', 'time']}
|
|
16
|
+
* >
|
|
17
|
+
* Generate a warm greeting for the user
|
|
18
|
+
* </ESI.Infer>
|
|
19
|
+
* );
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* function EmotionAwareContent({ content }) {
|
|
23
|
+
* return (
|
|
24
|
+
* <ESI.Infer
|
|
25
|
+
* model="llm"
|
|
26
|
+
* temperature={0.7}
|
|
27
|
+
* fallback="Here's today's content..."
|
|
28
|
+
* >
|
|
29
|
+
* {`Adapt this content to be emotionally supportive: ${content}`}
|
|
30
|
+
* </ESI.Infer>
|
|
31
|
+
* );
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
import { type ReactNode, type FC } from 'react';
|
|
36
|
+
import type { ESIConfig, ESIDirective, ESIModel, ESIProcessor, ESIResult, UserContext } from './types';
|
|
37
|
+
interface ESIContextValue {
|
|
38
|
+
processor: ESIProcessor;
|
|
39
|
+
userContext: UserContext | null;
|
|
40
|
+
enabled: boolean;
|
|
41
|
+
process: (directive: ESIDirective) => Promise<ESIResult>;
|
|
42
|
+
processWithStream: (directive: ESIDirective, onChunk: (chunk: string) => void) => Promise<ESIResult>;
|
|
43
|
+
}
|
|
44
|
+
export interface ESIProviderProps {
|
|
45
|
+
children: ReactNode;
|
|
46
|
+
config?: Partial<ESIConfig>;
|
|
47
|
+
userContext?: UserContext;
|
|
48
|
+
processor?: ESIProcessor;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* ESI Provider - enables ESI components in the tree
|
|
52
|
+
*/
|
|
53
|
+
export declare const ESIProvider: FC<ESIProviderProps>;
|
|
54
|
+
/**
|
|
55
|
+
* Hook to access ESI context
|
|
56
|
+
*/
|
|
57
|
+
export declare function useESI(): ESIContextValue;
|
|
58
|
+
export interface ESIInferProps {
|
|
59
|
+
/** The prompt - can be children or explicit prop */
|
|
60
|
+
children?: ReactNode;
|
|
61
|
+
prompt?: string;
|
|
62
|
+
/** Model to use */
|
|
63
|
+
model?: ESIModel;
|
|
64
|
+
/** Model variant */
|
|
65
|
+
variant?: string;
|
|
66
|
+
/** Temperature for generation */
|
|
67
|
+
temperature?: number;
|
|
68
|
+
/** Maximum tokens */
|
|
69
|
+
maxTokens?: number;
|
|
70
|
+
/** System prompt */
|
|
71
|
+
system?: string;
|
|
72
|
+
/** Enable streaming */
|
|
73
|
+
stream?: boolean;
|
|
74
|
+
/** Fallback content if inference fails */
|
|
75
|
+
fallback?: ReactNode;
|
|
76
|
+
/** Loading content */
|
|
77
|
+
loading?: ReactNode;
|
|
78
|
+
/** Inject user context */
|
|
79
|
+
contextAware?: boolean;
|
|
80
|
+
/** Context signals to include */
|
|
81
|
+
signals?: Array<'emotion' | 'preferences' | 'history' | 'time' | 'device'>;
|
|
82
|
+
/** Cache TTL in seconds */
|
|
83
|
+
cacheTtl?: number;
|
|
84
|
+
/** Custom render function */
|
|
85
|
+
render?: (result: ESIResult) => ReactNode;
|
|
86
|
+
/** Class name for wrapper */
|
|
87
|
+
className?: string;
|
|
88
|
+
/** Callback when inference completes */
|
|
89
|
+
onComplete?: (result: ESIResult) => void;
|
|
90
|
+
/** Callback on error */
|
|
91
|
+
onError?: (error: string) => void;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* ESI Inference Component
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```tsx
|
|
98
|
+
* <ESI.Infer model="llm" temperature={0.7}>
|
|
99
|
+
* Write a haiku about React
|
|
100
|
+
* </ESI.Infer>
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare const ESIInfer: FC<ESIInferProps>;
|
|
104
|
+
export interface ESIEmbedProps {
|
|
105
|
+
children: ReactNode;
|
|
106
|
+
onComplete?: (embedding: number[]) => void;
|
|
107
|
+
onError?: (error: string) => void;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* ESI Embed Component - generates embeddings
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```tsx
|
|
114
|
+
* <ESI.Embed onComplete={(embedding) => console.log(embedding)}>
|
|
115
|
+
* Text to embed
|
|
116
|
+
* </ESI.Embed>
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare const ESIEmbed: FC<ESIEmbedProps>;
|
|
120
|
+
export interface ESIEmotionProps {
|
|
121
|
+
children: ReactNode;
|
|
122
|
+
contextAware?: boolean;
|
|
123
|
+
onComplete?: (result: {
|
|
124
|
+
emotion: string;
|
|
125
|
+
confidence: number;
|
|
126
|
+
}) => void;
|
|
127
|
+
onError?: (error: string) => void;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* ESI Emotion Component - detects emotion from text
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```tsx
|
|
134
|
+
* <ESI.Emotion onComplete={({ emotion }) => setMood(emotion)}>
|
|
135
|
+
* {userInput}
|
|
136
|
+
* </ESI.Emotion>
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
export declare const ESIEmotion: FC<ESIEmotionProps>;
|
|
140
|
+
export interface ESIVisionProps {
|
|
141
|
+
src: string;
|
|
142
|
+
prompt: string;
|
|
143
|
+
fallback?: ReactNode;
|
|
144
|
+
loading?: ReactNode;
|
|
145
|
+
className?: string;
|
|
146
|
+
onComplete?: (result: ESIResult) => void;
|
|
147
|
+
onError?: (error: string) => void;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* ESI Vision Component - analyzes images
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```tsx
|
|
154
|
+
* <ESI.Vision
|
|
155
|
+
* src={base64Image}
|
|
156
|
+
* prompt="Describe what you see"
|
|
157
|
+
* fallback="Unable to analyze image"
|
|
158
|
+
* />
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
export declare const ESIVision: FC<ESIVisionProps>;
|
|
162
|
+
export interface UseESIInferOptions extends Omit<ESIInferProps, 'children' | 'loading' | 'fallback' | 'render' | 'className'> {
|
|
163
|
+
autoRun?: boolean;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Hook for programmatic ESI inference
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```tsx
|
|
170
|
+
* function MyComponent() {
|
|
171
|
+
* const { run, result, isLoading, error } = useESIInfer({
|
|
172
|
+
* model: 'llm',
|
|
173
|
+
* contextAware: true,
|
|
174
|
+
* });
|
|
175
|
+
*
|
|
176
|
+
* return (
|
|
177
|
+
* <button onClick={() => run('Generate a greeting')}>
|
|
178
|
+
* {isLoading ? 'Generating...' : result?.output || 'Click to generate'}
|
|
179
|
+
* </button>
|
|
180
|
+
* );
|
|
181
|
+
* }
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
export declare function useESIInfer(options?: UseESIInferOptions): {
|
|
185
|
+
run: (prompt: string) => Promise<ESIResult | null>;
|
|
186
|
+
result: ESIResult | null;
|
|
187
|
+
isLoading: boolean;
|
|
188
|
+
error: string | null;
|
|
189
|
+
reset: () => void;
|
|
190
|
+
};
|
|
191
|
+
export declare const ESI: {
|
|
192
|
+
Provider: FC<ESIProviderProps>;
|
|
193
|
+
Infer: FC<ESIInferProps>;
|
|
194
|
+
Embed: FC<ESIEmbedProps>;
|
|
195
|
+
Emotion: FC<ESIEmotionProps>;
|
|
196
|
+
Vision: FC<ESIVisionProps>;
|
|
197
|
+
};
|
|
198
|
+
export default ESI;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edge Side Inference (ESI) Processor
|
|
3
|
+
*
|
|
4
|
+
* Like Varnish ESI but for AI - brings inference to the edge at render time.
|
|
5
|
+
* Components can embed AI directly in templates for dynamic, personalized content.
|
|
6
|
+
*/
|
|
7
|
+
import type { ESIConfig, ESIDirective, ESIModel, ESIParams, ESIProcessor, ESIResult, UserContext } from './types';
|
|
8
|
+
export declare class EdgeWorkersESIProcessor implements ESIProcessor {
|
|
9
|
+
name: string;
|
|
10
|
+
private config;
|
|
11
|
+
private warmupPromise?;
|
|
12
|
+
constructor(config?: Partial<ESIConfig>);
|
|
13
|
+
warmup(): Promise<void>;
|
|
14
|
+
isModelAvailable(model: ESIModel): boolean;
|
|
15
|
+
process(directive: ESIDirective, context: UserContext): Promise<ESIResult>;
|
|
16
|
+
processBatch(directives: ESIDirective[], context: UserContext): Promise<ESIResult[]>;
|
|
17
|
+
stream(directive: ESIDirective, context: UserContext, onChunk: (chunk: string) => void): Promise<ESIResult>;
|
|
18
|
+
private callEdgeWorkers;
|
|
19
|
+
private getEndpointForModel;
|
|
20
|
+
private buildRequestBody;
|
|
21
|
+
private parseResponse;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Create an ESI directive for LLM inference
|
|
25
|
+
*/
|
|
26
|
+
export declare function esiInfer(prompt: string, options?: Partial<ESIParams>): ESIDirective;
|
|
27
|
+
/**
|
|
28
|
+
* Create an ESI directive for embeddings
|
|
29
|
+
*/
|
|
30
|
+
export declare function esiEmbed(text: string): ESIDirective;
|
|
31
|
+
/**
|
|
32
|
+
* Create an ESI directive for emotion detection
|
|
33
|
+
*/
|
|
34
|
+
export declare function esiEmotion(text: string, contextAware?: boolean): ESIDirective;
|
|
35
|
+
/**
|
|
36
|
+
* Create an ESI directive for vision (image analysis)
|
|
37
|
+
*/
|
|
38
|
+
export declare function esiVision(base64Image: string, prompt: string, options?: Partial<ESIParams>): ESIDirective;
|
|
39
|
+
/**
|
|
40
|
+
* Create a context-aware ESI directive
|
|
41
|
+
* Automatically injects user context into the prompt
|
|
42
|
+
*/
|
|
43
|
+
export declare function esiWithContext(prompt: string, signals?: ESIDirective['signals'], options?: Partial<ESIParams>): ESIDirective;
|
|
44
|
+
export { ESIConfig, ESIDirective, ESIResult, ESIProcessor, ESIModel };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Heuristic Router Adapter
|
|
3
|
+
*
|
|
4
|
+
* Zero-latency personalized routing using pure heuristics.
|
|
5
|
+
* No external API calls - all decisions made locally via WASM-compatible logic.
|
|
6
|
+
*
|
|
7
|
+
* Signals used:
|
|
8
|
+
* - User tier → feature gating
|
|
9
|
+
* - Viewport → responsive layout selection, density
|
|
10
|
+
* - Custom signals → theme/accent derivation (configurable)
|
|
11
|
+
* - Navigation history → component ordering, speculation
|
|
12
|
+
* - Time of day → theme suggestion
|
|
13
|
+
* - Connection speed → prefetch depth
|
|
14
|
+
*/
|
|
15
|
+
import type { ComponentNode, ComponentTree, EmotionState, RouteDecision, RouterAdapter, ThemeMode, UserContext, UserTier } from './types';
|
|
16
|
+
/**
|
|
17
|
+
* Feature flags configuration by tier
|
|
18
|
+
*/
|
|
19
|
+
export type TierFeatures = Record<UserTier, Record<string, boolean>>;
|
|
20
|
+
/**
|
|
21
|
+
* Custom signal processor for deriving values from user context
|
|
22
|
+
*/
|
|
23
|
+
export interface SignalProcessor {
|
|
24
|
+
/** Derive accent color from context */
|
|
25
|
+
deriveAccent?: (context: UserContext) => string;
|
|
26
|
+
/** Derive theme from context */
|
|
27
|
+
deriveTheme?: (context: UserContext) => ThemeMode;
|
|
28
|
+
/** Custom component relevance scoring */
|
|
29
|
+
scoreRelevance?: (node: ComponentNode, context: UserContext) => number;
|
|
30
|
+
/** Custom navigation prediction */
|
|
31
|
+
predictNavigation?: (currentPath: string, context: UserContext) => string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Heuristic adapter configuration
|
|
35
|
+
*/
|
|
36
|
+
export interface HeuristicAdapterConfig {
|
|
37
|
+
/** Feature flags by tier (optional - defaults to all features enabled) */
|
|
38
|
+
tierFeatures?: TierFeatures;
|
|
39
|
+
/** Default accent color when no signal processor provided */
|
|
40
|
+
defaultAccent?: string;
|
|
41
|
+
/** Custom signal processing */
|
|
42
|
+
signals?: SignalProcessor;
|
|
43
|
+
/** Default paths to suggest when no history available */
|
|
44
|
+
defaultPaths?: string[];
|
|
45
|
+
/** Maximum number of paths to speculate */
|
|
46
|
+
maxSpeculationPaths?: number;
|
|
47
|
+
}
|
|
48
|
+
export declare class HeuristicAdapter implements RouterAdapter {
|
|
49
|
+
name: string;
|
|
50
|
+
private config;
|
|
51
|
+
constructor(config?: HeuristicAdapterConfig);
|
|
52
|
+
route(path: string, context: UserContext, tree: ComponentTree): Promise<RouteDecision>;
|
|
53
|
+
speculate(currentPath: string, context: UserContext): Promise<string[]>;
|
|
54
|
+
personalizeTree(tree: ComponentTree, decision: RouteDecision): ComponentTree;
|
|
55
|
+
emotionToAccent(emotionState: EmotionState): string;
|
|
56
|
+
private generateSessionId;
|
|
57
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Aeon Router - Personalized Routing System
|
|
3
|
+
*
|
|
4
|
+
* The website comes to the person - adaptive routing with:
|
|
5
|
+
* - User context signals (emotion, tier, preferences)
|
|
6
|
+
* - Speculative prefetching
|
|
7
|
+
* - Edge Side Inference (ESI)
|
|
8
|
+
* - Pluggable adapters (heuristic, AI, hybrid)
|
|
9
|
+
*/
|
|
10
|
+
export type { EmotionState, Viewport, ConnectionType, UserTier, UserContext, ThemeMode, LayoutDensity, LayoutType, SkeletonHints, RouteDecision, ComponentNode, ComponentTree, ComponentTreeSchema, RouterAdapter, AIRouterConfig, SpeculationConfig, PersonalizationConfig, RouterConfig, RouterConfigWithESI, ESIModel, ESIContentType, ESIParams, ESIContent, ESIDirective, ESIResult, ESIProcessor, ESIConfig, } from './types';
|
|
11
|
+
export { DEFAULT_ROUTER_CONFIG, DEFAULT_ESI_CONFIG } from './types';
|
|
12
|
+
export { EdgeWorkersESIProcessor, esiInfer, esiEmbed, esiEmotion, esiVision, esiWithContext, } from './esi';
|
|
13
|
+
export { ESI, ESIProvider, ESIInfer, ESIEmbed, ESIEmotion, ESIVision, useESI, useESIInfer, } from './esi-react';
|
|
14
|
+
export type { ESIProviderProps, ESIInferProps, ESIEmbedProps, ESIEmotionProps, ESIVisionProps, UseESIInferOptions, } from './esi-react';
|
|
15
|
+
export { HeuristicAdapter } from './heuristic-adapter';
|
|
16
|
+
export type { HeuristicAdapterConfig, TierFeatures, SignalProcessor, } from './heuristic-adapter';
|
|
17
|
+
export { extractUserContext, createContextMiddleware, setContextCookies, addSpeculationHeaders, } from './context-extractor';
|
|
18
|
+
export type { ContextExtractorOptions } from './context-extractor';
|
|
19
|
+
export { SpeculationManager, supportsSpeculationRules, supportsLinkPrefetch, autoInitSpeculation, createSpeculationHook, } from './speculation';
|
|
20
|
+
export type { SpeculationOptions, SpeculationState, } from './speculation';
|
|
21
|
+
export { parseWithSchema, generateSchemaPrompt, createControlProcessor, esiIf, esiMatch, } from './esi-control';
|
|
22
|
+
export type { ESICondition, ESIIfDirective, ESIMatchDirective, ESIControlResult, ESISchemaParams, ESISchemaResult, ESIControlProcessor, } from './esi-control';
|
|
23
|
+
export { ESIControl, ESIStructured, ESIIf, ESIMatch, ESICase, ESIDefault, ESICollaborative, ESIReflect, ESIOptimize, ESIAuto, } from './esi-control-react';
|
|
24
|
+
export type { ESIStructuredProps, ESIIfProps, ESIMatchProps, ESICaseProps, ESIDefaultProps, ESICollaborativeProps, ESIReflectProps, ESIOptimizeProps, ESIAutoProps, OptimizeMeta, } from './esi-control-react';
|