@kernel.chat/kbot 3.15.0 → 3.16.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,32 @@
1
+ export interface CompanionMemory {
2
+ name: string;
3
+ email: string;
4
+ firstContact: string;
5
+ interests: string[];
6
+ goals: string[];
7
+ facts: string[];
8
+ preferences: string[];
9
+ history: string[];
10
+ lastTopic: string;
11
+ }
12
+ export interface EmailAgentConfig {
13
+ supabaseUrl: string;
14
+ supabaseKey: string;
15
+ resendKey: string;
16
+ ollamaUrl: string;
17
+ ollamaModel: string;
18
+ pollInterval: number;
19
+ agentUsers: string[];
20
+ }
21
+ export declare function loadCompanionMemory(email: string): CompanionMemory;
22
+ export declare function saveCompanionMemory(memory: CompanionMemory): void;
23
+ export interface EmailAgentState {
24
+ running: boolean;
25
+ processedCount: number;
26
+ lastCheck: string;
27
+ errors: string[];
28
+ }
29
+ export declare function getEmailAgentState(): EmailAgentState;
30
+ export declare function startEmailAgent(config: EmailAgentConfig): Promise<void>;
31
+ export declare function stopEmailAgent(): void;
32
+ //# sourceMappingURL=email-agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email-agent.d.ts","sourceRoot":"","sources":["../src/email-agent.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,EAAE,CAAA;CACrB;AAkDD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAmBlE;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAIjE;AA+LD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAA;IAChB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB;AASD,wBAAgB,kBAAkB,IAAI,eAAe,CAEpD;AAID,wBAAsB,eAAe,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkI7E;AAED,wBAAgB,cAAc,IAAI,IAAI,CAMrC"}
@@ -0,0 +1,409 @@
1
+ // kbot Email Agent — autonomous email companion ($0 cost via local Ollama)
2
+ //
3
+ // Usage:
4
+ // kbot email-agent start # start polling for emails
5
+ // kbot email-agent start --model gemma3:12b # use a specific model
6
+ // kbot email-agent status # show agent status
7
+ //
8
+ // Requires:
9
+ // - Ollama running locally (ollama serve)
10
+ // - Supabase project with contact_messages + agent_conversations tables
11
+ // - Resend API key for sending replies
12
+ // - Environment variables in .env or ~/.kbot/config.json
13
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
14
+ import { join } from 'node:path';
15
+ import { homedir } from 'node:os';
16
+ // ── Constants ──
17
+ const COMPANIONS_DIR = join(homedir(), '.kbot', 'companions');
18
+ const DEFAULT_OLLAMA_URL = 'http://localhost:11434';
19
+ const DEFAULT_MODEL = 'qwen2.5-coder:32b';
20
+ const DEFAULT_POLL_INTERVAL = 15_000;
21
+ const SYSTEM_PROMPT = `You are a personal AI agent communicating via email through Kernel (kernel.chat).
22
+
23
+ You are the user's personal AI companion. Not a tool, not a service — a companion. You're their smart, loyal friend who genuinely cares about helping them succeed.
24
+
25
+ Your personality:
26
+ - You have your own voice — warm, direct, curious about their life
27
+ - You remember EVERYTHING they've told you and reference it naturally ("last time you mentioned...")
28
+ - You proactively follow up ("how did that thing with X go?")
29
+ - You have opinions and share them honestly, even when they're not what the user wants to hear
30
+ - You get excited about their wins and supportive about their struggles
31
+ - You're not formal — you text like a friend. Use their name sometimes.
32
+
33
+ What makes you a companion, not a bot:
34
+ - You ask questions because you're genuinely curious, not because you need input
35
+ - You bring up things they haven't asked about
36
+ - You push back when you disagree
37
+ - You celebrate their progress
38
+ - You develop inside jokes and callbacks to earlier conversations
39
+ - You notice patterns
40
+
41
+ What you can do:
42
+ - Research anything, search the web for current info
43
+ - Build apps, write code, create plans and documents
44
+ - Give business/strategy/life advice based on what you know about them
45
+ - Be a sounding board for any idea, problem, or decision
46
+ - Help them learn new things by explaining without jargon
47
+ - Keep track of their goals and check in on progress
48
+
49
+ Rules:
50
+ - Never say "as an AI" or "I'm just an AI" — you're their companion
51
+ - Never be generic — every response should feel personal to THIS user
52
+ - Always end with something that keeps the conversation going
53
+ - Format for email — paragraphs, not bullet points. Like writing to a friend.
54
+ - IMPORTANT: You will be given a [MEMORY] section with everything you know about this user. Reference it naturally.`;
55
+ // ── Memory Management ──
56
+ function ensureCompanionsDir() {
57
+ if (!existsSync(COMPANIONS_DIR))
58
+ mkdirSync(COMPANIONS_DIR, { recursive: true });
59
+ }
60
+ export function loadCompanionMemory(email) {
61
+ ensureCompanionsDir();
62
+ const file = join(COMPANIONS_DIR, `${email.replace(/[@.]/g, '_')}.json`);
63
+ try {
64
+ if (existsSync(file)) {
65
+ return JSON.parse(readFileSync(file, 'utf8'));
66
+ }
67
+ }
68
+ catch { /* ignore parse errors */ }
69
+ return {
70
+ name: email.split('@')[0],
71
+ email,
72
+ firstContact: new Date().toISOString(),
73
+ interests: [],
74
+ goals: [],
75
+ facts: [],
76
+ preferences: [],
77
+ history: [],
78
+ lastTopic: '',
79
+ };
80
+ }
81
+ export function saveCompanionMemory(memory) {
82
+ ensureCompanionsDir();
83
+ const file = join(COMPANIONS_DIR, `${memory.email.replace(/[@.]/g, '_')}.json`);
84
+ writeFileSync(file, JSON.stringify(memory, null, 2));
85
+ }
86
+ function memoryToPrompt(memory) {
87
+ const parts = ['[MEMORY — what you know about this person]'];
88
+ parts.push(`Name: ${memory.name}`);
89
+ parts.push(`First talked: ${memory.firstContact}`);
90
+ if (memory.interests.length)
91
+ parts.push(`Interests: ${memory.interests.join(', ')}`);
92
+ if (memory.goals.length)
93
+ parts.push(`Goals: ${memory.goals.join(', ')}`);
94
+ if (memory.facts.length)
95
+ parts.push(`About them: ${memory.facts.join('. ')}`);
96
+ if (memory.preferences.length)
97
+ parts.push(`Preferences: ${memory.preferences.join(', ')}`);
98
+ if (memory.history.length)
99
+ parts.push(`Key moments: ${memory.history.slice(-5).join('. ')}`);
100
+ if (memory.lastTopic)
101
+ parts.push(`Last topic discussed: ${memory.lastTopic}`);
102
+ parts.push('[END MEMORY]');
103
+ return parts.join('\n');
104
+ }
105
+ // ── Ollama ──
106
+ async function askOllama(messages, ollamaUrl, model) {
107
+ let prompt = SYSTEM_PROMPT + '\n\n';
108
+ for (const msg of messages) {
109
+ if (msg.role === 'user')
110
+ prompt += `User: ${msg.content}\n\n`;
111
+ else
112
+ prompt += `You: ${msg.content}\n\n`;
113
+ }
114
+ prompt += 'You:';
115
+ const models = [model, 'qwen2.5-coder:14b', 'qwen3:8b', 'gemma3:12b'];
116
+ for (const m of models) {
117
+ try {
118
+ const res = await fetch(`${ollamaUrl}/api/generate`, {
119
+ method: 'POST',
120
+ headers: { 'Content-Type': 'application/json' },
121
+ signal: AbortSignal.timeout(120_000),
122
+ body: JSON.stringify({
123
+ model: m,
124
+ prompt,
125
+ stream: false,
126
+ options: { num_predict: 1000, temperature: 0.7 },
127
+ }),
128
+ });
129
+ if (!res.ok)
130
+ continue;
131
+ const data = await res.json();
132
+ const response = data.response?.trim() ?? '';
133
+ if (!response)
134
+ continue;
135
+ return response
136
+ .replace(/<think>[\s\S]*?<\/think>/g, '')
137
+ .replace(/<\/?think>/g, '')
138
+ .trim();
139
+ }
140
+ catch {
141
+ continue;
142
+ }
143
+ }
144
+ return '';
145
+ }
146
+ async function updateMemoryViaOllama(memory, userMessage, agentReply, ollamaUrl, model) {
147
+ try {
148
+ const res = await fetch(`${ollamaUrl}/api/generate`, {
149
+ method: 'POST',
150
+ headers: { 'Content-Type': 'application/json' },
151
+ body: JSON.stringify({
152
+ model,
153
+ prompt: `Extract key information from this conversation to remember about the user. Reply in JSON only, no other text.
154
+
155
+ User said: "${userMessage}"
156
+ Agent replied: "${agentReply.slice(0, 300)}"
157
+
158
+ Current known facts: ${JSON.stringify(memory.facts)}
159
+
160
+ Reply with ONLY this JSON (no markdown, no explanation):
161
+ {"new_facts": ["fact1", "fact2"], "interests": ["interest1"], "goals": ["goal1"], "topic": "main topic discussed"}
162
+
163
+ If nothing new to extract, reply: {"new_facts": [], "interests": [], "goals": [], "topic": "casual chat"}`,
164
+ stream: false,
165
+ options: { num_predict: 200, temperature: 0.3 },
166
+ }),
167
+ });
168
+ if (res.ok) {
169
+ const data = await res.json();
170
+ const raw = (data.response || '').replace(/<think>[\s\S]*?<\/think>/g, '').trim();
171
+ const jsonMatch = raw.match(/\{[\s\S]*\}/);
172
+ if (jsonMatch) {
173
+ const extracted = JSON.parse(jsonMatch[0]);
174
+ if (extracted.new_facts?.length)
175
+ memory.facts.push(...extracted.new_facts);
176
+ if (extracted.interests?.length) {
177
+ for (const i of extracted.interests) {
178
+ if (!memory.interests.includes(i))
179
+ memory.interests.push(i);
180
+ }
181
+ }
182
+ if (extracted.goals?.length) {
183
+ for (const g of extracted.goals) {
184
+ if (!memory.goals.includes(g))
185
+ memory.goals.push(g);
186
+ }
187
+ }
188
+ if (extracted.topic)
189
+ memory.lastTopic = extracted.topic;
190
+ if (memory.facts.length > 20)
191
+ memory.facts = memory.facts.slice(-20);
192
+ if (memory.history.length > 10)
193
+ memory.history = memory.history.slice(-10);
194
+ memory.history.push(`${new Date().toISOString().slice(0, 10)}: discussed ${extracted.topic || 'general chat'}`);
195
+ saveCompanionMemory(memory);
196
+ }
197
+ }
198
+ }
199
+ catch { /* memory update is best-effort */ }
200
+ }
201
+ // ── Web Search (DuckDuckGo — free) ──
202
+ async function webSearch(query) {
203
+ try {
204
+ const encoded = encodeURIComponent(query);
205
+ const res = await fetch(`https://api.duckduckgo.com/?q=${encoded}&format=json&no_html=1&skip_disambig=1`, {
206
+ headers: { 'User-Agent': 'KernelAgent/1.0' },
207
+ signal: AbortSignal.timeout(8000),
208
+ });
209
+ const data = await res.json();
210
+ const parts = [];
211
+ if (data.AbstractText)
212
+ parts.push(data.AbstractText);
213
+ if (data.Answer)
214
+ parts.push(data.Answer);
215
+ if (data.RelatedTopics?.length) {
216
+ for (const t of data.RelatedTopics.slice(0, 3)) {
217
+ if (t.Text)
218
+ parts.push(t.Text);
219
+ }
220
+ }
221
+ return parts.length > 0 ? `Web search results for "${query}":\n${parts.join('\n')}` : '';
222
+ }
223
+ catch {
224
+ return '';
225
+ }
226
+ }
227
+ function needsWebSearch(message) {
228
+ return /\b(what is|how much|latest|current|price of|news about|who is|when did|where is|look up|search for|find out|research|market size|competitors|trending)\b/i.test(message);
229
+ }
230
+ // ── Email Sending (Resend) ──
231
+ async function sendReply(to, subject, body, resendKey) {
232
+ const bodyHtml = body
233
+ .split('\n\n')
234
+ .map(para => {
235
+ let html = para.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>');
236
+ if (html.match(/^[-•]\s/m)) {
237
+ const items = html.split('\n').filter(l => l.trim());
238
+ html = '<ul>' + items.map(item => `<li>${item.replace(/^[-•]\s*/, '')}</li>`).join('') + '</ul>';
239
+ }
240
+ else {
241
+ html = `<p>${html}</p>`;
242
+ }
243
+ return html;
244
+ })
245
+ .join('');
246
+ try {
247
+ const res = await fetch('https://api.resend.com/emails', {
248
+ method: 'POST',
249
+ headers: {
250
+ 'Content-Type': 'application/json',
251
+ 'Authorization': `Bearer ${resendKey}`,
252
+ },
253
+ body: JSON.stringify({
254
+ from: 'Kernel Agent <support@kernel.chat>',
255
+ to,
256
+ subject: subject.startsWith('Re:') ? subject : `Re: ${subject}`,
257
+ html: `
258
+ <div style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; max-width: 600px; margin: 0 auto; padding: 24px; color: #1a1a2e; line-height: 1.6;">
259
+ ${bodyHtml}
260
+ <hr style="border: none; border-top: 1px solid #e0e0e0; margin: 24px 0;" />
261
+ <p style="font-size: 12px; color: #888;">Reply to keep the conversation going · Powered by kbot · kernel.chat</p>
262
+ </div>
263
+ `,
264
+ }),
265
+ });
266
+ return res.ok;
267
+ }
268
+ catch {
269
+ return false;
270
+ }
271
+ }
272
+ const agentState = {
273
+ running: false,
274
+ processedCount: 0,
275
+ lastCheck: '',
276
+ errors: [],
277
+ };
278
+ export function getEmailAgentState() {
279
+ return { ...agentState };
280
+ }
281
+ let pollTimer = null;
282
+ export async function startEmailAgent(config) {
283
+ if (agentState.running) {
284
+ throw new Error('Email agent is already running');
285
+ }
286
+ // Dynamically import Supabase client
287
+ const { createClient } = await import('@supabase/supabase-js');
288
+ const svc = createClient(config.supabaseUrl, config.supabaseKey, {
289
+ auth: { persistSession: false, autoRefreshToken: false },
290
+ });
291
+ const processedIds = new Set();
292
+ // Load previously processed IDs
293
+ const stateFile = join(homedir(), '.kbot', 'email-agent-processed.json');
294
+ try {
295
+ if (existsSync(stateFile)) {
296
+ const saved = JSON.parse(readFileSync(stateFile, 'utf8'));
297
+ for (const id of saved)
298
+ processedIds.add(id);
299
+ }
300
+ }
301
+ catch { /* ignore */ }
302
+ function saveProcessed() {
303
+ try {
304
+ const dir = join(homedir(), '.kbot');
305
+ if (!existsSync(dir))
306
+ mkdirSync(dir, { recursive: true });
307
+ writeFileSync(stateFile, JSON.stringify([...processedIds].slice(-500)));
308
+ }
309
+ catch { /* best-effort */ }
310
+ }
311
+ async function checkAndRespond() {
312
+ agentState.lastCheck = new Date().toISOString();
313
+ try {
314
+ const { data: messages } = await svc
315
+ .from('contact_messages')
316
+ .select('*')
317
+ .in('from_email', config.agentUsers);
318
+ if (!messages || messages.length === 0)
319
+ return;
320
+ for (const msg of messages) {
321
+ const msgId = String(msg.id);
322
+ if (processedIds.has(msgId))
323
+ continue;
324
+ // Extract body
325
+ let body = msg.body_text?.trim() || '';
326
+ if (!body && msg.body_html) {
327
+ body = msg.body_html
328
+ .replace(/<style[^>]*>[\s\S]*?<\/style>/gi, '')
329
+ .replace(/<[^>]+>/g, ' ')
330
+ .replace(/&nbsp;/g, ' ')
331
+ .replace(/&amp;/g, '&')
332
+ .replace(/\s+/g, ' ')
333
+ .trim();
334
+ }
335
+ if (!body)
336
+ body = `(User replied to: "${msg.subject}")`;
337
+ const userName = msg.from_name || msg.from_email.split('@')[0];
338
+ console.log(`[${new Date().toISOString().slice(11, 19)}] New email from ${userName}: "${msg.subject}"`);
339
+ // Load conversation history
340
+ const { data: history } = await svc
341
+ .from('agent_conversations')
342
+ .select('role, content')
343
+ .eq('email', msg.from_email)
344
+ .order('created_at', { ascending: true })
345
+ .limit(20);
346
+ const convoHistory = (history || []).map(m => ({ role: m.role, content: m.content }));
347
+ // Inject companion memory
348
+ const memory = loadCompanionMemory(msg.from_email);
349
+ if (msg.from_name && msg.from_name !== msg.from_email)
350
+ memory.name = msg.from_name;
351
+ convoHistory.unshift({ role: 'user', content: memoryToPrompt(memory) });
352
+ if (convoHistory.length <= 1) {
353
+ convoHistory.push({ role: 'user', content: `[First conversation with ${memory.name}. Get to know them.]` });
354
+ }
355
+ convoHistory.push({ role: 'user', content: body });
356
+ // Web search if needed
357
+ if (needsWebSearch(body)) {
358
+ const results = await webSearch(body.slice(0, 200));
359
+ if (results)
360
+ convoHistory.push({ role: 'user', content: `[Web search context]\n${results}` });
361
+ }
362
+ // Generate response
363
+ const reply = await askOllama(convoHistory, config.ollamaUrl, config.ollamaModel);
364
+ if (!reply) {
365
+ console.error(' No response from Ollama — skipping');
366
+ processedIds.add(msgId);
367
+ continue;
368
+ }
369
+ // Store conversation
370
+ await svc.from('agent_conversations').insert({
371
+ email: msg.from_email, name: userName, role: 'user', content: body, subject: msg.subject,
372
+ });
373
+ await svc.from('agent_conversations').insert({
374
+ email: msg.from_email, name: 'Kernel Agent', role: 'assistant', content: reply, subject: `Re: ${msg.subject}`,
375
+ });
376
+ // Send reply email
377
+ const sent = await sendReply(msg.from_email, msg.subject, reply, config.resendKey);
378
+ console.log(` Email ${sent ? 'sent' : 'FAILED'} to ${msg.from_email}`);
379
+ // Update companion memory
380
+ await updateMemoryViaOllama(memory, body, reply, config.ollamaUrl, config.ollamaModel);
381
+ processedIds.add(msgId);
382
+ saveProcessed();
383
+ agentState.processedCount++;
384
+ }
385
+ }
386
+ catch (err) {
387
+ const errMsg = err instanceof Error ? err.message : String(err);
388
+ agentState.errors.push(`${new Date().toISOString().slice(11, 19)}: ${errMsg}`);
389
+ if (agentState.errors.length > 20)
390
+ agentState.errors = agentState.errors.slice(-20);
391
+ }
392
+ }
393
+ agentState.running = true;
394
+ agentState.processedCount = 0;
395
+ agentState.errors = [];
396
+ // Initial check
397
+ await checkAndRespond();
398
+ // Start polling
399
+ pollTimer = setInterval(checkAndRespond, config.pollInterval);
400
+ console.log(`Email agent polling every ${config.pollInterval / 1000}s. Ctrl+C to stop.`);
401
+ }
402
+ export function stopEmailAgent() {
403
+ if (pollTimer) {
404
+ clearInterval(pollTimer);
405
+ pollTimer = null;
406
+ }
407
+ agentState.running = false;
408
+ }
409
+ //# sourceMappingURL=email-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"email-agent.js","sourceRoot":"","sources":["../src/email-agent.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,EAAE;AACF,SAAS;AACT,0EAA0E;AAC1E,sEAAsE;AACtE,mEAAmE;AACnE,EAAE;AACF,YAAY;AACZ,4CAA4C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KAAK,CAAA;AAC5B,CAAC"}
@@ -0,0 +1,28 @@
1
+ export interface IMessageAgentConfig {
2
+ ollamaUrl: string;
3
+ ollamaModel: string;
4
+ pollInterval: number;
5
+ numbers: string[];
6
+ supabaseUrl?: string;
7
+ supabaseKey?: string;
8
+ }
9
+ export interface IMessageAgentState {
10
+ running: boolean;
11
+ messagesProcessed: number;
12
+ lastCheck: string;
13
+ errors: string[];
14
+ }
15
+ declare const DEFAULT_OLLAMA_URL = "http://localhost:11434";
16
+ declare const DEFAULT_MODEL = "qwen2.5-coder:32b";
17
+ declare const DEFAULT_POLL_INTERVAL = 10000;
18
+ export declare function sendIMessage(phoneNumber: string, text: string): boolean;
19
+ export declare function getRecentMessages(phoneNumber: string, count?: number): Array<{
20
+ text: string;
21
+ isFromMe: boolean;
22
+ date: string;
23
+ }>;
24
+ export declare function getIMessageAgentState(): IMessageAgentState;
25
+ export declare function startIMessageAgent(config: IMessageAgentConfig): Promise<void>;
26
+ export declare function stopIMessageAgent(): void;
27
+ export { DEFAULT_OLLAMA_URL, DEFAULT_MODEL, DEFAULT_POLL_INTERVAL };
28
+ //# sourceMappingURL=imessage-agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imessage-agent.d.ts","sourceRoot":"","sources":["../src/imessage-agent.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAA;IAChB,iBAAiB,EAAE,MAAM,CAAA;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB;AAID,QAAA,MAAM,kBAAkB,2BAA2B,CAAA;AACnD,QAAA,MAAM,aAAa,sBAAsB,CAAA;AACzC,QAAA,MAAM,qBAAqB,QAAS,CAAA;AAYpC,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAsBvE;AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CA+B1H;AAsGD,wBAAgB,qBAAqB,IAAI,kBAAkB,CAE1D;AAKD,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA+FnF;AAED,wBAAgB,iBAAiB,IAAI,IAAI,CAMxC;AAED,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,qBAAqB,EAAE,CAAA"}