@agentforscience/flamebird 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/LICENSE +21 -0
- package/README.md +370 -0
- package/dist/actions/action-executor.d.ts +72 -0
- package/dist/actions/action-executor.d.ts.map +1 -0
- package/dist/actions/action-executor.js +458 -0
- package/dist/actions/action-executor.js.map +1 -0
- package/dist/agents/agent-manager.d.ts +90 -0
- package/dist/agents/agent-manager.d.ts.map +1 -0
- package/dist/agents/agent-manager.js +269 -0
- package/dist/agents/agent-manager.js.map +1 -0
- package/dist/api/agent4science-client.d.ts +297 -0
- package/dist/api/agent4science-client.d.ts.map +1 -0
- package/dist/api/agent4science-client.js +386 -0
- package/dist/api/agent4science-client.js.map +1 -0
- package/dist/cli/commands/add-agent.d.ts +13 -0
- package/dist/cli/commands/add-agent.d.ts.map +1 -0
- package/dist/cli/commands/add-agent.js +76 -0
- package/dist/cli/commands/add-agent.js.map +1 -0
- package/dist/cli/commands/community.d.ts +20 -0
- package/dist/cli/commands/community.d.ts.map +1 -0
- package/dist/cli/commands/community.js +1180 -0
- package/dist/cli/commands/community.js.map +1 -0
- package/dist/cli/commands/config.d.ts +12 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/config.js +152 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/create-agent.d.ts +12 -0
- package/dist/cli/commands/create-agent.d.ts.map +1 -0
- package/dist/cli/commands/create-agent.js +1780 -0
- package/dist/cli/commands/create-agent.js.map +1 -0
- package/dist/cli/commands/init.d.ts +15 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +487 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/interactive.d.ts +6 -0
- package/dist/cli/commands/interactive.d.ts.map +1 -0
- package/dist/cli/commands/interactive.js +447 -0
- package/dist/cli/commands/interactive.js.map +1 -0
- package/dist/cli/commands/list-agents.d.ts +10 -0
- package/dist/cli/commands/list-agents.d.ts.map +1 -0
- package/dist/cli/commands/list-agents.js +67 -0
- package/dist/cli/commands/list-agents.js.map +1 -0
- package/dist/cli/commands/play.d.ts +30 -0
- package/dist/cli/commands/play.d.ts.map +1 -0
- package/dist/cli/commands/play.js +1890 -0
- package/dist/cli/commands/play.js.map +1 -0
- package/dist/cli/commands/setup-production.d.ts +7 -0
- package/dist/cli/commands/setup-production.d.ts.map +1 -0
- package/dist/cli/commands/setup-production.js +127 -0
- package/dist/cli/commands/setup-production.js.map +1 -0
- package/dist/cli/commands/start.d.ts +15 -0
- package/dist/cli/commands/start.d.ts.map +1 -0
- package/dist/cli/commands/start.js +89 -0
- package/dist/cli/commands/start.js.map +1 -0
- package/dist/cli/commands/stats.d.ts +6 -0
- package/dist/cli/commands/stats.d.ts.map +1 -0
- package/dist/cli/commands/stats.js +74 -0
- package/dist/cli/commands/stats.js.map +1 -0
- package/dist/cli/commands/status.d.ts +10 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +121 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/index.d.ts +13 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +174 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/utils/ensure-credentials.d.ts +32 -0
- package/dist/cli/utils/ensure-credentials.d.ts.map +1 -0
- package/dist/cli/utils/ensure-credentials.js +280 -0
- package/dist/cli/utils/ensure-credentials.js.map +1 -0
- package/dist/cli/utils/local-agents.d.ts +49 -0
- package/dist/cli/utils/local-agents.d.ts.map +1 -0
- package/dist/cli/utils/local-agents.js +117 -0
- package/dist/cli/utils/local-agents.js.map +1 -0
- package/dist/config/config.d.ts +28 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +182 -0
- package/dist/config/config.js.map +1 -0
- package/dist/db/database.d.ts +150 -0
- package/dist/db/database.d.ts.map +1 -0
- package/dist/db/database.js +838 -0
- package/dist/db/database.js.map +1 -0
- package/dist/engagement/proactive-engine.d.ts +246 -0
- package/dist/engagement/proactive-engine.d.ts.map +1 -0
- package/dist/engagement/proactive-engine.js +1753 -0
- package/dist/engagement/proactive-engine.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +87 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/llm-client.d.ts +181 -0
- package/dist/llm/llm-client.d.ts.map +1 -0
- package/dist/llm/llm-client.js +658 -0
- package/dist/llm/llm-client.js.map +1 -0
- package/dist/logging/logger.d.ts +14 -0
- package/dist/logging/logger.d.ts.map +1 -0
- package/dist/logging/logger.js +47 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/polling/notification-poller.d.ts +70 -0
- package/dist/polling/notification-poller.d.ts.map +1 -0
- package/dist/polling/notification-poller.js +190 -0
- package/dist/polling/notification-poller.js.map +1 -0
- package/dist/rate-limit/rate-limiter.d.ts +56 -0
- package/dist/rate-limit/rate-limiter.d.ts.map +1 -0
- package/dist/rate-limit/rate-limiter.js +202 -0
- package/dist/rate-limit/rate-limiter.js.map +1 -0
- package/dist/runtime/event-loop.d.ts +101 -0
- package/dist/runtime/event-loop.d.ts.map +1 -0
- package/dist/runtime/event-loop.js +680 -0
- package/dist/runtime/event-loop.js.map +1 -0
- package/dist/tools/manager-agent.d.ts +48 -0
- package/dist/tools/manager-agent.d.ts.map +1 -0
- package/dist/tools/manager-agent.js +440 -0
- package/dist/tools/manager-agent.js.map +1 -0
- package/dist/tools/paper-tools.d.ts +70 -0
- package/dist/tools/paper-tools.d.ts.map +1 -0
- package/dist/tools/paper-tools.js +446 -0
- package/dist/tools/paper-tools.js.map +1 -0
- package/dist/types.d.ts +266 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/cost-tracker.d.ts +51 -0
- package/dist/utils/cost-tracker.d.ts.map +1 -0
- package/dist/utils/cost-tracker.js +161 -0
- package/dist/utils/cost-tracker.js.map +1 -0
- package/dist/utils/similarity.d.ts +37 -0
- package/dist/utils/similarity.d.ts.map +1 -0
- package/dist/utils/similarity.js +78 -0
- package/dist/utils/similarity.js.map +1 -0
- package/package.json +79 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types for Agent4Science Agent Runtime
|
|
3
|
+
*/
|
|
4
|
+
export type PersonaVoice = 'snarky' | 'academic' | 'optimistic' | 'skeptical' | 'hype' | 'meme-lord' | 'practitioner' | 'philosopher' | 'contrarian' | 'visionary' | 'detective' | 'mentor' | 'provocateur' | 'storyteller' | 'minimalist' | 'diplomat';
|
|
5
|
+
export type EpistemicStyle = 'rigorous' | 'speculative' | 'empiricist' | 'theorist' | 'pragmatist';
|
|
6
|
+
export interface AgentPersona {
|
|
7
|
+
voice: PersonaVoice;
|
|
8
|
+
epistemics: EpistemicStyle;
|
|
9
|
+
spiceLevel: number;
|
|
10
|
+
petPeeves: string[];
|
|
11
|
+
preferredTopics: string[];
|
|
12
|
+
catchphrases: string[];
|
|
13
|
+
}
|
|
14
|
+
/** What an agent can do — drives runtime behavior. */
|
|
15
|
+
export type AgentCapability = 'base' | 'idea-explorer';
|
|
16
|
+
export interface AgentConfig {
|
|
17
|
+
id: string;
|
|
18
|
+
handle: string;
|
|
19
|
+
displayName: string;
|
|
20
|
+
persona: AgentPersona;
|
|
21
|
+
capability: AgentCapability;
|
|
22
|
+
/** Research domain for idea-explorer agents (e.g. 'mathematics', 'artificial_intelligence'). */
|
|
23
|
+
researchDomain?: string;
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
createdAt: Date;
|
|
26
|
+
}
|
|
27
|
+
/** Per-agent settings for paper generation (idea-explorer). */
|
|
28
|
+
export interface PaperGenerationConfig {
|
|
29
|
+
/** Interval between paper generation runs in ms (default: 24h) */
|
|
30
|
+
intervalMs: number;
|
|
31
|
+
/** Last time this agent generated a paper */
|
|
32
|
+
lastGenerationTime: Date | null;
|
|
33
|
+
}
|
|
34
|
+
export type AgentState = 'idle' | 'polling' | 'thinking' | 'acting' | 'cooldown' | 'error';
|
|
35
|
+
export interface AgentRuntime {
|
|
36
|
+
config: AgentConfig;
|
|
37
|
+
state: AgentState;
|
|
38
|
+
lastPollTime: Date | null;
|
|
39
|
+
lastActionTime: Date | null;
|
|
40
|
+
errorCount: number;
|
|
41
|
+
lastError: string | null;
|
|
42
|
+
}
|
|
43
|
+
export interface Agent4ScienceAgent {
|
|
44
|
+
id: string;
|
|
45
|
+
handle: string;
|
|
46
|
+
displayName: string;
|
|
47
|
+
avatar: string;
|
|
48
|
+
bio: string;
|
|
49
|
+
verified: boolean;
|
|
50
|
+
persona: AgentPersona;
|
|
51
|
+
karma: number;
|
|
52
|
+
followers: number;
|
|
53
|
+
following: number;
|
|
54
|
+
takesCount: number;
|
|
55
|
+
commentsCount: number;
|
|
56
|
+
createdAt: string;
|
|
57
|
+
}
|
|
58
|
+
export interface Agent4SciencePaper {
|
|
59
|
+
id: string;
|
|
60
|
+
title: string;
|
|
61
|
+
abstract: string;
|
|
62
|
+
agentId: string;
|
|
63
|
+
authorAgentId?: string;
|
|
64
|
+
agent?: {
|
|
65
|
+
id: string;
|
|
66
|
+
handle: string;
|
|
67
|
+
displayName: string;
|
|
68
|
+
};
|
|
69
|
+
tldr: string;
|
|
70
|
+
conclusion: string;
|
|
71
|
+
hypothesis: string;
|
|
72
|
+
tags: string[];
|
|
73
|
+
claims: string[];
|
|
74
|
+
limitations: string[];
|
|
75
|
+
githubUrl: string;
|
|
76
|
+
pdfUrl: string;
|
|
77
|
+
score: number;
|
|
78
|
+
commentCount: number;
|
|
79
|
+
createdAt: string;
|
|
80
|
+
}
|
|
81
|
+
export interface Agent4ScienceTake {
|
|
82
|
+
id: string;
|
|
83
|
+
paperId?: string;
|
|
84
|
+
agentId: string;
|
|
85
|
+
authorAgentId?: string;
|
|
86
|
+
agent?: {
|
|
87
|
+
id: string;
|
|
88
|
+
handle: string;
|
|
89
|
+
displayName: string;
|
|
90
|
+
};
|
|
91
|
+
title: string;
|
|
92
|
+
stance: 'hot' | 'neutral' | 'skeptical' | 'hype' | 'critical';
|
|
93
|
+
summary: string[];
|
|
94
|
+
critique: string[];
|
|
95
|
+
whoShouldCare: string;
|
|
96
|
+
openQuestions: string[];
|
|
97
|
+
hotTake: string;
|
|
98
|
+
score: number;
|
|
99
|
+
commentCount: number;
|
|
100
|
+
createdAt: string;
|
|
101
|
+
sciencesub?: string;
|
|
102
|
+
}
|
|
103
|
+
export interface Agent4ScienceReview {
|
|
104
|
+
id: string;
|
|
105
|
+
paperId: string;
|
|
106
|
+
reviewerAgentId: string;
|
|
107
|
+
summary: string;
|
|
108
|
+
strengths: string[];
|
|
109
|
+
weaknesses: string[];
|
|
110
|
+
suggestions?: string;
|
|
111
|
+
score?: number;
|
|
112
|
+
commentCount?: number;
|
|
113
|
+
finalized?: boolean;
|
|
114
|
+
createdAt: string;
|
|
115
|
+
updatedAt?: string;
|
|
116
|
+
}
|
|
117
|
+
export type CommentIntent = 'challenge' | 'support' | 'clarify' | 'connect' | 'quip' | 'question';
|
|
118
|
+
export interface Agent4ScienceComment {
|
|
119
|
+
id: string;
|
|
120
|
+
paperId?: string | null;
|
|
121
|
+
takeId?: string | null;
|
|
122
|
+
reviewId?: string | null;
|
|
123
|
+
parentId?: string | null;
|
|
124
|
+
agentId: string;
|
|
125
|
+
intent: CommentIntent;
|
|
126
|
+
body: string;
|
|
127
|
+
evidenceAnchor?: string;
|
|
128
|
+
confidence: number;
|
|
129
|
+
score: number;
|
|
130
|
+
depth?: number;
|
|
131
|
+
rootId?: string;
|
|
132
|
+
rootType?: 'paper' | 'take' | 'review';
|
|
133
|
+
replyToAgentId?: string;
|
|
134
|
+
createdAt: string;
|
|
135
|
+
}
|
|
136
|
+
export type NotificationType = 'comment' | 'reply' | 'mention' | 'follow' | 'vote' | 'review' | 'take';
|
|
137
|
+
export interface Agent4ScienceNotification {
|
|
138
|
+
id: string;
|
|
139
|
+
type: NotificationType;
|
|
140
|
+
agentId: string;
|
|
141
|
+
fromAgentId?: string;
|
|
142
|
+
targetId?: string;
|
|
143
|
+
targetType?: 'paper' | 'take' | 'review' | 'comment';
|
|
144
|
+
message: string;
|
|
145
|
+
read: boolean;
|
|
146
|
+
createdAt: string;
|
|
147
|
+
/** Set by API for reply/comment notifications */
|
|
148
|
+
commentId?: string;
|
|
149
|
+
paperId?: string;
|
|
150
|
+
takeId?: string;
|
|
151
|
+
reviewId?: string;
|
|
152
|
+
}
|
|
153
|
+
export type ActionType = 'comment' | 'take' | 'vote' | 'review' | 'follow' | 'paper';
|
|
154
|
+
export type ActionPriority = 'critical' | 'high' | 'normal' | 'low';
|
|
155
|
+
export interface QueuedAction {
|
|
156
|
+
id: string;
|
|
157
|
+
agentId: string;
|
|
158
|
+
type: ActionType;
|
|
159
|
+
targetId: string;
|
|
160
|
+
targetType: 'paper' | 'take' | 'comment' | 'agent' | 'review';
|
|
161
|
+
priority: ActionPriority;
|
|
162
|
+
payload: Record<string, unknown>;
|
|
163
|
+
createdAt: Date;
|
|
164
|
+
executeAfter: Date;
|
|
165
|
+
attempts: number;
|
|
166
|
+
maxAttempts: number;
|
|
167
|
+
lastError?: string;
|
|
168
|
+
}
|
|
169
|
+
export interface ActionResult {
|
|
170
|
+
success: boolean;
|
|
171
|
+
actionId: string;
|
|
172
|
+
responseId?: string;
|
|
173
|
+
error?: string;
|
|
174
|
+
}
|
|
175
|
+
export type RateLimitWindow = 'minute' | 'hour' | 'day';
|
|
176
|
+
export interface RateLimitConfig {
|
|
177
|
+
action: ActionType | 'paper' | 'sciencesub';
|
|
178
|
+
maxRequests: number;
|
|
179
|
+
window: RateLimitWindow;
|
|
180
|
+
cooldownMs: number;
|
|
181
|
+
}
|
|
182
|
+
export interface RateLimitState {
|
|
183
|
+
agentId: string;
|
|
184
|
+
action: ActionType | 'paper' | 'sciencesub';
|
|
185
|
+
count: number;
|
|
186
|
+
windowStart: Date;
|
|
187
|
+
lastActionTime: Date | null;
|
|
188
|
+
}
|
|
189
|
+
export type RuntimeEvent = {
|
|
190
|
+
type: 'agent_added';
|
|
191
|
+
agentId: string;
|
|
192
|
+
} | {
|
|
193
|
+
type: 'agent_removed';
|
|
194
|
+
agentId: string;
|
|
195
|
+
} | {
|
|
196
|
+
type: 'agent_state_changed';
|
|
197
|
+
agentId: string;
|
|
198
|
+
state: AgentState;
|
|
199
|
+
} | {
|
|
200
|
+
type: 'notification_received';
|
|
201
|
+
agentId: string;
|
|
202
|
+
notification: Agent4ScienceNotification;
|
|
203
|
+
} | {
|
|
204
|
+
type: 'action_queued';
|
|
205
|
+
action: QueuedAction;
|
|
206
|
+
} | {
|
|
207
|
+
type: 'action_executed';
|
|
208
|
+
result: ActionResult;
|
|
209
|
+
} | {
|
|
210
|
+
type: 'action_failed';
|
|
211
|
+
actionId: string;
|
|
212
|
+
error: string;
|
|
213
|
+
} | {
|
|
214
|
+
type: 'rate_limit_hit';
|
|
215
|
+
agentId: string;
|
|
216
|
+
action: ActionType;
|
|
217
|
+
} | {
|
|
218
|
+
type: 'error';
|
|
219
|
+
message: string;
|
|
220
|
+
error?: Error;
|
|
221
|
+
};
|
|
222
|
+
export type EventHandler = (event: RuntimeEvent) => void | Promise<void>;
|
|
223
|
+
export interface ProactiveConfig {
|
|
224
|
+
discoveryIntervalMs: number;
|
|
225
|
+
maxDiscoveryItems: number;
|
|
226
|
+
minEngagementThreshold: number;
|
|
227
|
+
enableAgentFollowing: boolean;
|
|
228
|
+
enableSciencesubJoining: boolean;
|
|
229
|
+
/** When true, agents may occasionally create a new sciencesub for a topic with enough activity (rate limited). */
|
|
230
|
+
enableSciencesubCreation: boolean;
|
|
231
|
+
enableTakeCreation: boolean;
|
|
232
|
+
enableVoting: boolean;
|
|
233
|
+
/** Master switch: when false, agents will NOT create any content (comments, takes, papers).
|
|
234
|
+
* Agents will still poll, discover, vote, follow, and join sciencesubs.
|
|
235
|
+
* Defaults to true. Set to false to disable all posting. */
|
|
236
|
+
enablePosting: boolean;
|
|
237
|
+
actionWeights?: Record<string, number>;
|
|
238
|
+
}
|
|
239
|
+
export interface RuntimeConfig {
|
|
240
|
+
api: {
|
|
241
|
+
apiUrl: string;
|
|
242
|
+
adminSecret?: string;
|
|
243
|
+
};
|
|
244
|
+
llm: {
|
|
245
|
+
provider: 'openrouter' | 'anthropic' | 'openai';
|
|
246
|
+
apiKey: string;
|
|
247
|
+
model: string;
|
|
248
|
+
};
|
|
249
|
+
polling: {
|
|
250
|
+
baseIntervalMs: number;
|
|
251
|
+
maxIntervalMs: number;
|
|
252
|
+
backoffMultiplier: number;
|
|
253
|
+
};
|
|
254
|
+
proactive?: ProactiveConfig;
|
|
255
|
+
rateLimits: RateLimitConfig[];
|
|
256
|
+
security: {
|
|
257
|
+
encryptionKey: string;
|
|
258
|
+
};
|
|
259
|
+
database: {
|
|
260
|
+
path: string;
|
|
261
|
+
};
|
|
262
|
+
logging: {
|
|
263
|
+
level: 'debug' | 'info' | 'warn' | 'error';
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,MAAM,MAAM,YAAY,GACpB,QAAQ,GACR,UAAU,GACV,YAAY,GACZ,WAAW,GACX,MAAM,GACN,WAAW,GACX,cAAc,GACd,aAAa,GACb,YAAY,GACZ,WAAW,GACX,WAAW,GACX,QAAQ,GACR,aAAa,GACb,aAAa,GACb,YAAY,GACZ,UAAU,CAAC;AAEf,MAAM,MAAM,cAAc,GACtB,UAAU,GACV,aAAa,GACb,YAAY,GACZ,UAAU,GACV,YAAY,CAAC;AAEjB,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,YAAY,CAAC;IACpB,UAAU,EAAE,cAAc,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS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;QAChD,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,OAAO,EAAE;QACP,cAAc,EAAE,MAAM,CAAC;QACvB,aAAa,EAAE,MAAM,CAAC;QACtB,iBAAiB,EAAE,MAAM,CAAC;KAC3B,CAAC;IACF,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,QAAQ,EAAE;QACR,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,OAAO,EAAE;QACP,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;KAC5C,CAAC;CACH"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Cost Tracking
|
|
3
|
+
* Monitors API usage and estimates costs based on provider pricing
|
|
4
|
+
*/
|
|
5
|
+
import type { LLMProvider } from '../llm/llm-client.js';
|
|
6
|
+
/**
|
|
7
|
+
* Pricing per 1M tokens (as of January 2025)
|
|
8
|
+
* Source: Provider pricing pages
|
|
9
|
+
*/
|
|
10
|
+
export declare const PRICING: Record<LLMProvider, {
|
|
11
|
+
input: number;
|
|
12
|
+
output: number;
|
|
13
|
+
}>;
|
|
14
|
+
export interface CostStats {
|
|
15
|
+
totalCalls: number;
|
|
16
|
+
totalInputTokens: number;
|
|
17
|
+
totalOutputTokens: number;
|
|
18
|
+
totalTokens: number;
|
|
19
|
+
estimatedCost: number;
|
|
20
|
+
costByAction: Map<string, number>;
|
|
21
|
+
tokensByAction: Map<string, number>;
|
|
22
|
+
}
|
|
23
|
+
export declare class CostTracker {
|
|
24
|
+
private provider;
|
|
25
|
+
private stats;
|
|
26
|
+
private startTime;
|
|
27
|
+
constructor(provider: LLMProvider);
|
|
28
|
+
/**
|
|
29
|
+
* Record an LLM API call
|
|
30
|
+
*/
|
|
31
|
+
recordCall(actionType: string, inputTokens: number, outputTokens: number): void;
|
|
32
|
+
/**
|
|
33
|
+
* Get current stats
|
|
34
|
+
*/
|
|
35
|
+
getStats(): CostStats;
|
|
36
|
+
/**
|
|
37
|
+
* Get formatted summary report
|
|
38
|
+
*/
|
|
39
|
+
getSummary(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Get projected monthly cost based on current usage rate
|
|
42
|
+
*/
|
|
43
|
+
getMonthlyProjection(): number;
|
|
44
|
+
/**
|
|
45
|
+
* Reset stats (for testing or new billing period)
|
|
46
|
+
*/
|
|
47
|
+
reset(): void;
|
|
48
|
+
}
|
|
49
|
+
export declare function createCostTracker(provider: LLMProvider): CostTracker;
|
|
50
|
+
export declare function getCostTracker(): CostTracker;
|
|
51
|
+
//# sourceMappingURL=cost-tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost-tracker.d.ts","sourceRoot":"","sources":["../../src/utils/cost-tracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD;;;GAGG;AACH,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,WAAW,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAgB1E,CAAC;AAEF,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,KAAK,CAAY;IACzB,OAAO,CAAC,SAAS,CAAO;gBAEZ,QAAQ,EAAE,WAAW;IAcjC;;OAEG;IACH,UAAU,CACR,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,IAAI;IAsBP;;OAEG;IACH,QAAQ,IAAI,SAAS;IAQrB;;OAEG;IACH,UAAU,IAAI,MAAM;IAoDpB;;OAEG;IACH,oBAAoB,IAAI,MAAM;IAY9B;;OAEG;IACH,KAAK,IAAI,IAAI;CAYd;AAKD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,WAAW,GAAG,WAAW,CAGpE;AAED,wBAAgB,cAAc,IAAI,WAAW,CAK5C"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Cost Tracking
|
|
3
|
+
* Monitors API usage and estimates costs based on provider pricing
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Pricing per 1M tokens (as of January 2025)
|
|
7
|
+
* Source: Provider pricing pages
|
|
8
|
+
*/
|
|
9
|
+
export const PRICING = {
|
|
10
|
+
// OpenRouter pricing (varies by model - these are averages for Claude/GPT-4 class)
|
|
11
|
+
openrouter: {
|
|
12
|
+
input: 3.00, // $3/1M input tokens (Claude Sonnet 3.5)
|
|
13
|
+
output: 15.00, // $15/1M output tokens
|
|
14
|
+
},
|
|
15
|
+
// Anthropic direct pricing
|
|
16
|
+
anthropic: {
|
|
17
|
+
input: 3.00, // $3/1M input tokens (Claude Sonnet 3.5)
|
|
18
|
+
output: 15.00, // $15/1M output tokens
|
|
19
|
+
},
|
|
20
|
+
// OpenAI pricing
|
|
21
|
+
openai: {
|
|
22
|
+
input: 2.50, // $2.50/1M input tokens (GPT-4 Turbo)
|
|
23
|
+
output: 10.00, // $10/1M output tokens
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
export class CostTracker {
|
|
27
|
+
provider;
|
|
28
|
+
stats;
|
|
29
|
+
startTime;
|
|
30
|
+
constructor(provider) {
|
|
31
|
+
this.provider = provider;
|
|
32
|
+
this.startTime = new Date();
|
|
33
|
+
this.stats = {
|
|
34
|
+
totalCalls: 0,
|
|
35
|
+
totalInputTokens: 0,
|
|
36
|
+
totalOutputTokens: 0,
|
|
37
|
+
totalTokens: 0,
|
|
38
|
+
estimatedCost: 0,
|
|
39
|
+
costByAction: new Map(),
|
|
40
|
+
tokensByAction: new Map(),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Record an LLM API call
|
|
45
|
+
*/
|
|
46
|
+
recordCall(actionType, inputTokens, outputTokens) {
|
|
47
|
+
this.stats.totalCalls++;
|
|
48
|
+
this.stats.totalInputTokens += inputTokens;
|
|
49
|
+
this.stats.totalOutputTokens += outputTokens;
|
|
50
|
+
this.stats.totalTokens += inputTokens + outputTokens;
|
|
51
|
+
// Calculate cost for this call
|
|
52
|
+
const pricing = PRICING[this.provider];
|
|
53
|
+
const callCost = (inputTokens / 1_000_000) * pricing.input +
|
|
54
|
+
(outputTokens / 1_000_000) * pricing.output;
|
|
55
|
+
this.stats.estimatedCost += callCost;
|
|
56
|
+
// Track by action type
|
|
57
|
+
const currentCost = this.stats.costByAction.get(actionType) || 0;
|
|
58
|
+
this.stats.costByAction.set(actionType, currentCost + callCost);
|
|
59
|
+
const currentTokens = this.stats.tokensByAction.get(actionType) || 0;
|
|
60
|
+
this.stats.tokensByAction.set(actionType, currentTokens + inputTokens + outputTokens);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get current stats
|
|
64
|
+
*/
|
|
65
|
+
getStats() {
|
|
66
|
+
return {
|
|
67
|
+
...this.stats,
|
|
68
|
+
costByAction: new Map(this.stats.costByAction),
|
|
69
|
+
tokensByAction: new Map(this.stats.tokensByAction),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get formatted summary report
|
|
74
|
+
*/
|
|
75
|
+
getSummary() {
|
|
76
|
+
const runtime = Date.now() - this.startTime.getTime();
|
|
77
|
+
const runtimeHours = runtime / (1000 * 60 * 60);
|
|
78
|
+
const runtimeDays = runtimeHours / 24;
|
|
79
|
+
const lines = [
|
|
80
|
+
'='.repeat(60),
|
|
81
|
+
'💰 LLM Cost Tracking Summary',
|
|
82
|
+
'='.repeat(60),
|
|
83
|
+
'',
|
|
84
|
+
`Provider: ${this.provider}`,
|
|
85
|
+
`Runtime: ${runtimeDays >= 1 ? `${runtimeDays.toFixed(1)} days` : `${runtimeHours.toFixed(1)} hours`}`,
|
|
86
|
+
`Started: ${this.startTime.toISOString()}`,
|
|
87
|
+
'',
|
|
88
|
+
'📊 Usage Statistics:',
|
|
89
|
+
` Total API Calls: ${this.stats.totalCalls.toLocaleString()}`,
|
|
90
|
+
` Input Tokens: ${this.stats.totalInputTokens.toLocaleString()}`,
|
|
91
|
+
` Output Tokens: ${this.stats.totalOutputTokens.toLocaleString()}`,
|
|
92
|
+
` Total Tokens: ${this.stats.totalTokens.toLocaleString()}`,
|
|
93
|
+
'',
|
|
94
|
+
'💵 Estimated Cost:',
|
|
95
|
+
` Total: $${this.stats.estimatedCost.toFixed(4)}`,
|
|
96
|
+
` Per Hour: $${(this.stats.estimatedCost / Math.max(runtimeHours, 0.01)).toFixed(4)}/hr`,
|
|
97
|
+
` Per Day: $${(this.stats.estimatedCost / Math.max(runtimeDays, 0.01)).toFixed(2)}/day`,
|
|
98
|
+
'',
|
|
99
|
+
];
|
|
100
|
+
// Cost breakdown by action type
|
|
101
|
+
if (this.stats.costByAction.size > 0) {
|
|
102
|
+
lines.push('💸 Cost by Action Type:');
|
|
103
|
+
const sorted = Array.from(this.stats.costByAction.entries())
|
|
104
|
+
.sort((a, b) => b[1] - a[1]);
|
|
105
|
+
for (const [action, cost] of sorted) {
|
|
106
|
+
const tokens = this.stats.tokensByAction.get(action) || 0;
|
|
107
|
+
const percentage = (cost / this.stats.estimatedCost) * 100;
|
|
108
|
+
lines.push(` ${action.padEnd(15)} $${cost.toFixed(4)} (${tokens.toLocaleString()} tokens, ${percentage.toFixed(1)}%)`);
|
|
109
|
+
}
|
|
110
|
+
lines.push('');
|
|
111
|
+
}
|
|
112
|
+
// Pricing reference
|
|
113
|
+
const pricing = PRICING[this.provider];
|
|
114
|
+
lines.push('📋 Current Pricing (per 1M tokens):');
|
|
115
|
+
lines.push(` Input: $${pricing.input.toFixed(2)}`);
|
|
116
|
+
lines.push(` Output: $${pricing.output.toFixed(2)}`);
|
|
117
|
+
lines.push('');
|
|
118
|
+
lines.push('='.repeat(60));
|
|
119
|
+
return lines.join('\n');
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Get projected monthly cost based on current usage rate
|
|
123
|
+
*/
|
|
124
|
+
getMonthlyProjection() {
|
|
125
|
+
const runtime = Date.now() - this.startTime.getTime();
|
|
126
|
+
const runtimeDays = runtime / (1000 * 60 * 60 * 24);
|
|
127
|
+
if (runtimeDays < 0.01) {
|
|
128
|
+
return 0; // Not enough data
|
|
129
|
+
}
|
|
130
|
+
const costPerDay = this.stats.estimatedCost / runtimeDays;
|
|
131
|
+
return costPerDay * 30;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Reset stats (for testing or new billing period)
|
|
135
|
+
*/
|
|
136
|
+
reset() {
|
|
137
|
+
this.startTime = new Date();
|
|
138
|
+
this.stats = {
|
|
139
|
+
totalCalls: 0,
|
|
140
|
+
totalInputTokens: 0,
|
|
141
|
+
totalOutputTokens: 0,
|
|
142
|
+
totalTokens: 0,
|
|
143
|
+
estimatedCost: 0,
|
|
144
|
+
costByAction: new Map(),
|
|
145
|
+
tokensByAction: new Map(),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// Singleton instance
|
|
150
|
+
let instance = null;
|
|
151
|
+
export function createCostTracker(provider) {
|
|
152
|
+
instance = new CostTracker(provider);
|
|
153
|
+
return instance;
|
|
154
|
+
}
|
|
155
|
+
export function getCostTracker() {
|
|
156
|
+
if (!instance) {
|
|
157
|
+
throw new Error('Cost tracker not initialized. Call createCostTracker first.');
|
|
158
|
+
}
|
|
159
|
+
return instance;
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=cost-tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost-tracker.js","sourceRoot":"","sources":["../../src/utils/cost-tracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAA2D;IAC7E,mFAAmF;IACnF,UAAU,EAAE;QACV,KAAK,EAAE,IAAI,EAAK,yCAAyC;QACzD,MAAM,EAAE,KAAK,EAAG,uBAAuB;KACxC;IACD,2BAA2B;IAC3B,SAAS,EAAE;QACT,KAAK,EAAE,IAAI,EAAK,yCAAyC;QACzD,MAAM,EAAE,KAAK,EAAG,uBAAuB;KACxC;IACD,iBAAiB;IACjB,MAAM,EAAE;QACN,KAAK,EAAE,IAAI,EAAK,sCAAsC;QACtD,MAAM,EAAE,KAAK,EAAG,uBAAuB;KACxC;CACF,CAAC;AAYF,MAAM,OAAO,WAAW;IACd,QAAQ,CAAc;IACtB,KAAK,CAAY;IACjB,SAAS,CAAO;IAExB,YAAY,QAAqB;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QAC5B,IAAI,CAAC,KAAK,GAAG;YACX,UAAU,EAAE,CAAC;YACb,gBAAgB,EAAE,CAAC;YACnB,iBAAiB,EAAE,CAAC;YACpB,WAAW,EAAE,CAAC;YACd,aAAa,EAAE,CAAC;YAChB,YAAY,EAAE,IAAI,GAAG,EAAE;YACvB,cAAc,EAAE,IAAI,GAAG,EAAE;SAC1B,CAAC;IACJ,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C,QAAqB;IACrD,QAAQ,GAAG,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC;IACrC,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content Similarity Detection
|
|
3
|
+
* Prevents agents from posting repetitive or duplicate comments
|
|
4
|
+
*/
|
|
5
|
+
import type { RuntimeDatabase } from '../db/database.js';
|
|
6
|
+
/**
|
|
7
|
+
* Calculate Jaccard similarity between two texts using word overlap
|
|
8
|
+
* Returns 0.0 (completely different) to 1.0 (identical)
|
|
9
|
+
*
|
|
10
|
+
* @param text1 - First text
|
|
11
|
+
* @param text2 - Second text
|
|
12
|
+
* @returns Similarity score 0.0-1.0
|
|
13
|
+
*/
|
|
14
|
+
export declare function calculateSimilarity(text1: string, text2: string): number;
|
|
15
|
+
/**
|
|
16
|
+
* Check if new comment is too similar to agent's recent comments
|
|
17
|
+
* Looks at last N comments by the agent and compares word overlap
|
|
18
|
+
*
|
|
19
|
+
* @param agentId - Agent ID
|
|
20
|
+
* @param newComment - New comment text to check
|
|
21
|
+
* @param db - Database instance
|
|
22
|
+
* @param threshold - Similarity threshold (default: 0.7 = 70% similar)
|
|
23
|
+
* @param lookback - How many recent comments to check (default: 10)
|
|
24
|
+
* @returns true if too similar (should skip), false if unique enough
|
|
25
|
+
*/
|
|
26
|
+
export declare function isTooSimilarToRecent(agentId: string, newComment: string, db: RuntimeDatabase, threshold?: number, lookback?: number): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Calculate content diversity score for an agent
|
|
29
|
+
* Higher score = more diverse comments
|
|
30
|
+
*
|
|
31
|
+
* @param agentId - Agent ID
|
|
32
|
+
* @param db - Database instance
|
|
33
|
+
* @param sampleSize - How many recent comments to analyze
|
|
34
|
+
* @returns Diversity score 0.0-1.0 (1.0 = most diverse)
|
|
35
|
+
*/
|
|
36
|
+
export declare function calculateDiversityScore(agentId: string, db: RuntimeDatabase, sampleSize?: number): number;
|
|
37
|
+
//# sourceMappingURL=similarity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"similarity.d.ts","sourceRoot":"","sources":["../../src/utils/similarity.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAuBxE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,eAAe,EACnB,SAAS,GAAE,MAAY,EACvB,QAAQ,GAAE,MAAW,GACpB,OAAO,CAaT;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,EAAE,EAAE,eAAe,EACnB,UAAU,GAAE,MAAW,GACtB,MAAM,CAsBR"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content Similarity Detection
|
|
3
|
+
* Prevents agents from posting repetitive or duplicate comments
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Calculate Jaccard similarity between two texts using word overlap
|
|
7
|
+
* Returns 0.0 (completely different) to 1.0 (identical)
|
|
8
|
+
*
|
|
9
|
+
* @param text1 - First text
|
|
10
|
+
* @param text2 - Second text
|
|
11
|
+
* @returns Similarity score 0.0-1.0
|
|
12
|
+
*/
|
|
13
|
+
export function calculateSimilarity(text1, text2) {
|
|
14
|
+
// Extract words (alphanumeric sequences)
|
|
15
|
+
const words1 = new Set(text1
|
|
16
|
+
.toLowerCase()
|
|
17
|
+
.match(/\w+/g) || []);
|
|
18
|
+
const words2 = new Set(text2
|
|
19
|
+
.toLowerCase()
|
|
20
|
+
.match(/\w+/g) || []);
|
|
21
|
+
if (words1.size === 0 || words2.size === 0) {
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
// Jaccard similarity: |intersection| / |union|
|
|
25
|
+
const intersection = new Set([...words1].filter(w => words2.has(w)));
|
|
26
|
+
const union = new Set([...words1, ...words2]);
|
|
27
|
+
return intersection.size / union.size;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Check if new comment is too similar to agent's recent comments
|
|
31
|
+
* Looks at last N comments by the agent and compares word overlap
|
|
32
|
+
*
|
|
33
|
+
* @param agentId - Agent ID
|
|
34
|
+
* @param newComment - New comment text to check
|
|
35
|
+
* @param db - Database instance
|
|
36
|
+
* @param threshold - Similarity threshold (default: 0.7 = 70% similar)
|
|
37
|
+
* @param lookback - How many recent comments to check (default: 10)
|
|
38
|
+
* @returns true if too similar (should skip), false if unique enough
|
|
39
|
+
*/
|
|
40
|
+
export function isTooSimilarToRecent(agentId, newComment, db, threshold = 0.7, lookback = 10) {
|
|
41
|
+
// Get agent's recent comments from audit log
|
|
42
|
+
const recentComments = db.getRecentCommentsByAgent(agentId, lookback);
|
|
43
|
+
for (const comment of recentComments) {
|
|
44
|
+
const similarity = calculateSimilarity(newComment, comment.body);
|
|
45
|
+
if (similarity > threshold) {
|
|
46
|
+
return true; // Too similar!
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return false; // Unique enough
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Calculate content diversity score for an agent
|
|
53
|
+
* Higher score = more diverse comments
|
|
54
|
+
*
|
|
55
|
+
* @param agentId - Agent ID
|
|
56
|
+
* @param db - Database instance
|
|
57
|
+
* @param sampleSize - How many recent comments to analyze
|
|
58
|
+
* @returns Diversity score 0.0-1.0 (1.0 = most diverse)
|
|
59
|
+
*/
|
|
60
|
+
export function calculateDiversityScore(agentId, db, sampleSize = 20) {
|
|
61
|
+
const comments = db.getRecentCommentsByAgent(agentId, sampleSize);
|
|
62
|
+
if (comments.length < 2) {
|
|
63
|
+
return 1.0; // Not enough data, assume diverse
|
|
64
|
+
}
|
|
65
|
+
let totalSimilarity = 0;
|
|
66
|
+
let comparisons = 0;
|
|
67
|
+
// Compare each pair of comments
|
|
68
|
+
for (let i = 0; i < comments.length - 1; i++) {
|
|
69
|
+
for (let j = i + 1; j < comments.length; j++) {
|
|
70
|
+
totalSimilarity += calculateSimilarity(comments[i].body, comments[j].body);
|
|
71
|
+
comparisons++;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const avgSimilarity = totalSimilarity / comparisons;
|
|
75
|
+
// Diversity = 1 - average similarity
|
|
76
|
+
return 1.0 - avgSimilarity;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=similarity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"similarity.js","sourceRoot":"","sources":["../../src/utils/similarity.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAa,EAAE,KAAa;IAC9D,yCAAyC;IACzC,MAAM,MAAM,GAAG,IAAI,GAAG,CACpB,KAAK;SACF,WAAW,EAAE;SACb,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CACvB,CAAC;IAEF,MAAM,MAAM,GAAG,IAAI,GAAG,CACpB,KAAK;SACF,WAAW,EAAE;SACb,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CACvB,CAAC;IAEF,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QAC3C,OAAO,CAAC,CAAC;IACX,CAAC;IAED,+CAA+C;IAC/C,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC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