@ebowwa/glm-daemon 0.4.3 → 0.4.5

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,162 @@
1
+ /**
2
+ * Base Channel - Implements ChannelConnector from @ebowwa/channel-types
3
+ *
4
+ * Abstract base class for all communication channels (Telegram, Discord, etc.)
5
+ * Provides shared functionality for message routing, error handling, and conversation management.
6
+ */
7
+ import { type ChannelConnector, type ChannelId, type ChannelMessage, type ChannelResponse, type ChannelCapabilities, type MessageHandler, type StreamChunk } from "@ebowwa/channel-types";
8
+ import { GLMClient } from "@ebowwa/ai";
9
+ import { GLMDaemon } from "../daemon.js";
10
+ export interface GLMChannelConfig {
11
+ /** Platform identifier */
12
+ platform: "telegram" | "discord" | "whatsapp" | "cli";
13
+ /** Account/bot ID */
14
+ accountId: string;
15
+ /** Instance ID for multiple instances */
16
+ instanceId?: string;
17
+ /** Butler storage directory */
18
+ butlerStorageDir?: string;
19
+ /** Working directory for daemon tasks */
20
+ daemonWorkdir?: string;
21
+ /** Base branch for daemon */
22
+ daemonBaseBranch?: string;
23
+ /** Auto-PR on completion */
24
+ enableDaemonAutoPR?: boolean;
25
+ /** Auto-commit during work */
26
+ enableDaemonAutoCommit?: boolean;
27
+ }
28
+ export interface MessageContext {
29
+ userId: string;
30
+ userName?: string;
31
+ channelId?: string;
32
+ timestamp: Date;
33
+ }
34
+ export interface RouteResult {
35
+ source: "butler" | "daemon" | "error";
36
+ response: string;
37
+ metadata?: {
38
+ daemonId?: string;
39
+ phase?: string;
40
+ executionTime?: number;
41
+ };
42
+ }
43
+ export interface MessageClassification {
44
+ type: "chat" | "task" | "status" | "unknown";
45
+ confidence: number;
46
+ suggestedAction: "handle_locally" | "delegate_daemon" | "both";
47
+ }
48
+ export type BaseChannelConfig = GLMChannelConfig;
49
+ /**
50
+ * Abstract base class for communication channels.
51
+ * Implements ChannelConnector from @ebowwa/channel-types.
52
+ */
53
+ export declare abstract class BaseChannel implements ChannelConnector {
54
+ abstract readonly id: ChannelId;
55
+ abstract readonly label: string;
56
+ abstract readonly capabilities: ChannelCapabilities;
57
+ protected glmClient: GLMClient;
58
+ protected daemon: GLMDaemon | null;
59
+ protected activeDaemonTask: string | null;
60
+ protected config: GLMChannelConfig;
61
+ protected conversationHistory: Map<string, Array<{
62
+ role: string;
63
+ content: string;
64
+ }>>;
65
+ protected messageHandler?: MessageHandler;
66
+ protected connected: boolean;
67
+ constructor(config: GLMChannelConfig);
68
+ /**
69
+ * Start the channel
70
+ */
71
+ start(): Promise<void>;
72
+ /**
73
+ * Stop the channel
74
+ */
75
+ stop(): Promise<void>;
76
+ /**
77
+ * Register message handler (from ChannelConnector interface)
78
+ */
79
+ onMessage(handler: MessageHandler): void;
80
+ /**
81
+ * Send response (from ChannelConnector interface)
82
+ * Must be implemented by subclasses for platform-specific delivery
83
+ */
84
+ abstract send(response: ChannelResponse): Promise<void>;
85
+ /**
86
+ * Optional streaming support
87
+ */
88
+ stream?(response: ChannelResponse, chunks: AsyncIterable<StreamChunk>): Promise<void>;
89
+ /**
90
+ * Check if connected
91
+ */
92
+ isConnected(): boolean;
93
+ /**
94
+ * Start the platform-specific bot (must be implemented by subclasses)
95
+ */
96
+ protected abstract startPlatform(): Promise<void>;
97
+ /**
98
+ * Stop the platform-specific bot (must be implemented by subclasses)
99
+ */
100
+ protected abstract stopPlatform(): Promise<void>;
101
+ /**
102
+ * Route a ChannelMessage through the internal handler or use default routing.
103
+ * This bridges ChannelMessage (from channel-types) to the internal routing logic.
104
+ */
105
+ routeChannelMessage(message: ChannelMessage): Promise<ChannelResponse>;
106
+ /**
107
+ * Route a message to appropriate handler (internal routing logic)
108
+ */
109
+ routeMessage(content: string, context: MessageContext): Promise<RouteResult>;
110
+ /**
111
+ * Convert internal RouteResult to ChannelResponse
112
+ */
113
+ protected resultToResponse(result: RouteResult, originalMessage: ChannelMessage): ChannelResponse;
114
+ /**
115
+ * Classify incoming message
116
+ */
117
+ protected classifyMessage(content: string): Promise<MessageClassification>;
118
+ /**
119
+ * Handle chat messages locally with GLM + tools
120
+ *
121
+ * Uses ToolExecutor from @ebowwa/ai/tools for the tool call loop.
122
+ * Refactored from manual tool loop on Feb 15, 2026.
123
+ */
124
+ protected handleChat(content: string, context: MessageContext): Promise<RouteResult>;
125
+ /**
126
+ * Handle task messages by delegating to GLMDaemon
127
+ */
128
+ protected handleTask(content: string, context: MessageContext): Promise<RouteResult>;
129
+ /**
130
+ * Handle status queries
131
+ */
132
+ protected handleStatus(): Promise<RouteResult>;
133
+ /**
134
+ * Handle unknown messages - ask for clarification
135
+ */
136
+ protected handleUnknown(content: string): Promise<RouteResult>;
137
+ /**
138
+ * Add message to conversation history
139
+ */
140
+ protected addToHistory(userId: string, message: {
141
+ role: string;
142
+ content: string;
143
+ }): void;
144
+ /**
145
+ * Get current status
146
+ */
147
+ getStatus(): {
148
+ hasActiveDaemon: boolean;
149
+ activeTask: string | null;
150
+ conversationCount: number;
151
+ daemonPhase: string | null;
152
+ };
153
+ /**
154
+ * Cleanup resources
155
+ */
156
+ cleanup(): Promise<void>;
157
+ /**
158
+ * Helper to create ChannelId for this channel
159
+ */
160
+ protected createId(): ChannelId;
161
+ }
162
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/channels/base.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EAGnB,KAAK,WAAW,EAIjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAwB,MAAM,cAAc,CAAC;AAM/D,MAAM,WAAW,gBAAgB;IAC/B,0BAA0B;IAC1B,QAAQ,EAAE,UAAU,GAAG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IACG,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC;IA2BlF;;OAEG;IACH,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,GAAG,eAAe;IA0BjG;;OAEG;cACa,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAsEhF;;;;;OAKG;cACa,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC;IAgE1F;;OAEG;cACa,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC;IA6D1F;;OAEG;cACa,YAAY,IAAI,OAAO,CAAC,WAAW,CAAC;IAgCpD;;OAEG;cACa,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAWpE;;OAEG;IACH,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAaxF;;OAEG;IACH,SAAS,IAAI;QACX,eAAe,EAAE,OAAO,CAAC;QACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,iBAAiB,EAAE,MAAM,CAAC;QAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;KAC5B;IASD;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAU9B;;OAEG;IACH,SAAS,CAAC,QAAQ,IAAI,SAAS;CAOhC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Discord Channel Adapter
3
+ *
4
+ * Implements ChannelConnector from @ebowwa/channel-types.
5
+ * Discord bot using discord.js.
6
+ */
7
+ import { type ChannelId, type ChannelResponse, type ChannelCapabilities } from "@ebowwa/channel-types";
8
+ import { BaseChannel, type GLMChannelConfig } from "./base.js";
9
+ export interface DiscordChannelConfig extends GLMChannelConfig {
10
+ platform: "discord";
11
+ /** Bot token */
12
+ botToken: string;
13
+ /** Application ID for slash commands */
14
+ applicationId?: string;
15
+ /** Guild ID to restrict to */
16
+ guildId?: string;
17
+ /** Channel IDs to listen to (empty = all) */
18
+ channelIds?: string[];
19
+ /** Enable slash commands */
20
+ enableSlashCommands?: boolean;
21
+ }
22
+ export type { DiscordChannelConfig as DiscordConfig };
23
+ export declare class DiscordChannel extends BaseChannel {
24
+ readonly id: ChannelId;
25
+ readonly label = "Discord";
26
+ readonly capabilities: ChannelCapabilities;
27
+ private client;
28
+ private token;
29
+ private guildId?;
30
+ private channelIds?;
31
+ constructor(config: DiscordChannelConfig);
32
+ /**
33
+ * Send response to Discord
34
+ */
35
+ send(response: ChannelResponse): Promise<void>;
36
+ /**
37
+ * Start Discord bot
38
+ */
39
+ protected startPlatform(): Promise<void>;
40
+ /**
41
+ * Stop Discord bot
42
+ */
43
+ protected stopPlatform(): Promise<void>;
44
+ /**
45
+ * Create normalized ChannelMessage from Discord message
46
+ */
47
+ private createChannelMessage;
48
+ /**
49
+ * Send response, handling chunking for long messages
50
+ */
51
+ private sendResponse;
52
+ }
53
+ /**
54
+ * Create a Discord channel from config
55
+ */
56
+ export declare function createDiscordChannel(config: DiscordChannelConfig): DiscordChannel;
57
+ /**
58
+ * Create Discord channel config from environment (Doppler)
59
+ */
60
+ export declare function createDiscordConfigFromEnv(): DiscordChannelConfig | null;
61
+ //# sourceMappingURL=discord.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discord.d.ts","sourceRoot":"","sources":["../../src/channels/discord.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,eAAe,EACpB,KAAK,mBAAmB,EAIzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,WAAW,EACX,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Communication channel adapters for GLM Daemon.
5
+ * All channels implement ChannelConnector from @ebowwa/channel-types.
6
+ *
7
+ * Supported platforms:
8
+ * - Telegram
9
+ * - Discord
10
+ */
11
+ export type { ChannelConnector, ChannelId, ChannelMessage, ChannelResponse, ChannelCapabilities, MessageHandler, MessageRef, ResponseContent, } from "@ebowwa/channel-types";
12
+ export { BaseChannel, type GLMChannelConfig, type BaseChannelConfig, type MessageContext, type RouteResult, type MessageClassification, } from "./base.js";
13
+ export { GLMTelegramChannel, type TelegramChannelConfig, type TelegramConfig, createTelegramChannel, createTelegramConfigFromEnv, } from "./telegram.js";
14
+ export { GLMTelegramChannel as TelegramChannel } from "./telegram.js";
15
+ export { DiscordChannel, type DiscordChannelConfig, type DiscordConfig, createDiscordChannel, createDiscordConfigFromEnv, } from "./discord.js";
16
+ import type { ChannelConnector } from "@ebowwa/channel-types";
17
+ /**
18
+ * Channel registry for managing multiple channels
19
+ */
20
+ export declare class ChannelRegistry {
21
+ private static channels;
22
+ /**
23
+ * Register a channel
24
+ */
25
+ static register(name: string, channel: ChannelConnector): void;
26
+ /**
27
+ * Get a registered channel
28
+ */
29
+ static get(name: string): ChannelConnector | undefined;
30
+ /**
31
+ * Unregister a channel
32
+ */
33
+ static unregister(name: string): void;
34
+ /**
35
+ * Get all registered channels
36
+ */
37
+ static getAll(): Map<string, ChannelConnector>;
38
+ /**
39
+ * Stop all channels
40
+ */
41
+ static stopAll(): Promise<void>;
42
+ /**
43
+ * Start all channels
44
+ */
45
+ static startAll(): Promise<void>;
46
+ }
47
+ /**
48
+ * Create all channels from environment variables (Doppler)
49
+ */
50
+ export declare function createChannelsFromEnv(): ChannelConnector[];
51
+ /**
52
+ * Initialize channels from environment and register them
53
+ */
54
+ export declare function initializeChannelsFromEnv(): Promise<ChannelRegistry>;
55
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/channels/index.ts"],"names":[],"mappings":"AA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AAI,gBAAgB,EAAE,CAgB1D;AAED;;GAEG;AACH,wBAAsB,yBAAyB,IAAI,OAAO,CAAC,eAAe,CAAC,CAa1E"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * GLM Daemon - Core Daemon
3
+ *
4
+ * Main orchestrator for autonomous GLM 4.7 agents.
5
+ * Implements SLAM pattern: State → Loop → Action → Memory
6
+ */
7
+ import type { GLMDaemonConfig, GLMDaemonStatus } from "./types.js";
8
+ export declare class GLMDaemon {
9
+ private config;
10
+ private state;
11
+ private statePath;
12
+ private agent;
13
+ private hooks;
14
+ private tools;
15
+ private stateManager;
16
+ private team;
17
+ private subagents;
18
+ private running;
19
+ private client;
20
+ constructor(config: GLMDaemonConfig);
21
+ /**
22
+ * Initialize daemon state
23
+ */
24
+ private initializeState;
25
+ /**
26
+ * Build system prompt from config and state
27
+ * // TODO MOVE PROMPT TO STRUCTURED PROMPTS seed
28
+ *
29
+ */
30
+ private buildSystemPrompt;
31
+ /**
32
+ * Start the daemon with a prompt
33
+ */
34
+ start(prompt: string): Promise<string>;
35
+ /**
36
+ * Main daemon loop (SLAM pattern with reflection checkpoints)
37
+ */
38
+ private runLoop;
39
+ /**
40
+ * Execute current SLAM phase
41
+ */
42
+ private executePhase;
43
+ /**
44
+ * Planning phase - break down task into subtasks
45
+ */
46
+ private phasePlanning;
47
+ /**
48
+ * Executing phase - work on current subtask
49
+ */
50
+ private phaseExecuting;
51
+ /**
52
+ * Reflecting phase - TL;DR checkpoint after N tools
53
+ * Pauses, summarizes progress, saves state, continues
54
+ */
55
+ private phaseReflecting;
56
+ /**
57
+ * Parse reflection summary from agent response
58
+ */
59
+ private parseReflectionSummary;
60
+ /**
61
+ * Increment tool count and check for reflection trigger
62
+ */
63
+ incrementToolCount(): boolean;
64
+ /**
65
+ * Paranoid phase - quality check after every edit
66
+ */
67
+ private phaseParanoid;
68
+ /**
69
+ * Reviewing phase - final quality review
70
+ */
71
+ private phaseReviewing;
72
+ /**
73
+ * Fixing phase - fix issues found
74
+ */
75
+ private phaseFixing;
76
+ /**
77
+ * Committing phase - commit changes
78
+ */
79
+ private phaseCommitting;
80
+ /**
81
+ * Complete the daemon run
82
+ */
83
+ private complete;
84
+ /**
85
+ * Stop the daemon
86
+ */
87
+ stop(): Promise<void>;
88
+ /**
89
+ * Get daemon status
90
+ */
91
+ getStatus(): GLMDaemonStatus;
92
+ /**
93
+ * Get reflection status and summaries
94
+ */
95
+ getReflectionStatus(): {
96
+ enabled: boolean;
97
+ toolLimit: number;
98
+ toolCount: number;
99
+ totalToolCount: number;
100
+ checkpointCount: number;
101
+ lastReflection: string | null;
102
+ summaries: import("./types.js").GLMReflectionSummary[];
103
+ };
104
+ /**
105
+ * Force a reflection checkpoint now
106
+ */
107
+ forceReflection(): Promise<import("./types.js").GLMReflectionSummary | null>;
108
+ /**
109
+ * Parse subtasks from agent response
110
+ */
111
+ private parseSubtasks;
112
+ /**
113
+ * Detect issues in paranoid check response
114
+ */
115
+ private detectIssues;
116
+ /**
117
+ * Check if completion promise is met
118
+ */
119
+ private checkCompletion;
120
+ }
121
+ //# sourceMappingURL=daemon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daemon.d.ts","sourceRoot":"","sources":["../src/daemon.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EACV,eAAe,EAGf,eAAe,EAChB,MAAM,YAAY,CAAC;AAWpB,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,KAAK,CAAiB;IAC9B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,IAAI,CAAqB;IACjC,OAAO,CAAC,SAAS,CAAoC;IACrD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAY;gBAE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 */
7
+ import type { GLMHooksConfig } from "./types.js";
8
+ type GLMHookHandler = (...args: unknown[]) => Promise<unknown> | unknown;
9
+ export declare class HookSystem {
10
+ private hooks;
11
+ constructor(config: GLMHooksConfig);
12
+ /**
13
+ * Register a hook handler
14
+ */
15
+ register(event: string, handler: GLMHookHandler): void;
16
+ /**
17
+ * Execute all handlers for an event
18
+ */
19
+ execute(event: string, ...args: unknown[]): Promise<void>;
20
+ /**
21
+ * Remove all handlers for an event
22
+ */
23
+ clear(event: string): void;
24
+ /**
25
+ * Remove all hooks
26
+ */
27
+ clearAll(): void;
28
+ /**
29
+ * Get registered events
30
+ */
31
+ getEvents(): string[];
32
+ }
33
+ export {};
34
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,YAAY,CAAC;AAEjE,KAAK,cAAc,GAAG,CACpB,GAAG,IAAI,EAAE,OAAO,EAAE,KACf,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AAEhC,qBAAa,UAAU;IACrB,OAAO,CAAC,KAAK,CAA4C;gBAE7C,MAAM,EAAE,cAAc;IA+BlC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI;IAOtD;;OAEG;IACG,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB/D;;OAEG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI1B;;OAEG;IACH,QAAQ,IAAI,IAAI;IAIhB;;OAEG;IACH,SAAS,IAAI,MAAM,EAAE;CAGtB"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * GLM Daemon - Autonomous GLM 4.7 Agent Daemon
3
+ *
4
+ * A daemon for autonomous AI agents powered by GLM 4.7.
5
+ * Implements SLAM pattern (State → Loop → Action → Memory).
6
+ * Supports hooks, tools via MCP, multi-agent coordination, and communication channels.
7
+ *
8
+ * @module @ebowwa/glm-daemon
9
+ */
10
+ export { GLMDaemon } from "./daemon.js";
11
+ export { GLMAgent } from "./agent.js";
12
+ export { HookSystem } from "./hooks.js";
13
+ export { ToolBridge } from "./tools.js";
14
+ export { StateManager } from "./state.js";
15
+ export { BUILTIN_TOOLS, getBuiltinTool, getBuiltinToolNames, toGLMFormat, executeBuiltinTool, ToolExecutor, type ToolDefinition, type ToolCall, type ToolExecutorOptions, type ToolExecutionResult, } from "@ebowwa/ai/tools";
16
+ export { ConversationMemory, NumericConversationMemory, StringConversationMemory, type ConversationMessage, type ConversationMemoryConfig, } from "./memory.js";
17
+ export { BaseChannel, TelegramChannel, DiscordChannel, ChannelRegistry, type BaseChannelConfig, type TelegramChannelConfig, type DiscordChannelConfig, type MessageContext, type RouteResult, type MessageClassification, } from "./channels/index.js";
18
+ export * from "./types.js";
19
+ import { GLMDaemon } from "./daemon.js";
20
+ import type { GLMDaemonConfig } from "./types.js";
21
+ export declare function createGLMDaemon(config: GLMDaemonConfig): Promise<GLMDaemon>;
22
+ export declare function startGLMDaemon(config: GLMDaemonConfig, prompt: string): Promise<string>;
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG1C,OAAO,EACL,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,GACzB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EACzB,wBAAwB,EACxB,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,GAC9B,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,WAAW,EACX,eAAe,EACf,cAAc,EACd,eAAe,EACf,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,qBAAqB,GAC3B,MAAM,qBAAqB,CAAC;AAG7B,cAAc,YAAY,CAAC;AAG3B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,wBAAsB,eAAe,CACnC,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,SAAS,CAAC,CAGpB;AAED,wBAAsB,cAAc,CAClC,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,CAGjB"}