infinium-o2 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.
Files changed (53) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +550 -0
  3. package/dist/cjs/asyncClient.d.ts +119 -0
  4. package/dist/cjs/asyncClient.d.ts.map +1 -0
  5. package/dist/cjs/asyncClient.js +464 -0
  6. package/dist/cjs/asyncClient.js.map +1 -0
  7. package/dist/cjs/client.d.ts +92 -0
  8. package/dist/cjs/client.d.ts.map +1 -0
  9. package/dist/cjs/client.js +354 -0
  10. package/dist/cjs/client.js.map +1 -0
  11. package/dist/cjs/errors.d.ts +102 -0
  12. package/dist/cjs/errors.d.ts.map +1 -0
  13. package/dist/cjs/errors.js +218 -0
  14. package/dist/cjs/errors.js.map +1 -0
  15. package/dist/cjs/index.d.ts +12 -0
  16. package/dist/cjs/index.d.ts.map +1 -0
  17. package/dist/cjs/index.js +61 -0
  18. package/dist/cjs/index.js.map +1 -0
  19. package/dist/cjs/package.json +1 -0
  20. package/dist/cjs/types.d.ts +231 -0
  21. package/dist/cjs/types.d.ts.map +1 -0
  22. package/dist/cjs/types.js +23 -0
  23. package/dist/cjs/types.js.map +1 -0
  24. package/dist/cjs/utils.d.ts +130 -0
  25. package/dist/cjs/utils.d.ts.map +1 -0
  26. package/dist/cjs/utils.js +381 -0
  27. package/dist/cjs/utils.js.map +1 -0
  28. package/dist/esm/asyncClient.d.ts +119 -0
  29. package/dist/esm/asyncClient.d.ts.map +1 -0
  30. package/dist/esm/asyncClient.js +457 -0
  31. package/dist/esm/asyncClient.js.map +1 -0
  32. package/dist/esm/client.d.ts +92 -0
  33. package/dist/esm/client.d.ts.map +1 -0
  34. package/dist/esm/client.js +347 -0
  35. package/dist/esm/client.js.map +1 -0
  36. package/dist/esm/errors.d.ts +102 -0
  37. package/dist/esm/errors.d.ts.map +1 -0
  38. package/dist/esm/errors.js +200 -0
  39. package/dist/esm/errors.js.map +1 -0
  40. package/dist/esm/index.d.ts +12 -0
  41. package/dist/esm/index.d.ts.map +1 -0
  42. package/dist/esm/index.js +17 -0
  43. package/dist/esm/index.js.map +1 -0
  44. package/dist/esm/package.json +1 -0
  45. package/dist/esm/types.d.ts +231 -0
  46. package/dist/esm/types.d.ts.map +1 -0
  47. package/dist/esm/types.js +20 -0
  48. package/dist/esm/types.js.map +1 -0
  49. package/dist/esm/utils.d.ts +130 -0
  50. package/dist/esm/utils.d.ts.map +1 -0
  51. package/dist/esm/utils.js +355 -0
  52. package/dist/esm/utils.js.map +1 -0
  53. package/package.json +94 -0
@@ -0,0 +1,354 @@
1
+ "use strict";
2
+ /**
3
+ * Synchronous client for Infinium API.
4
+ */
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.InfiniumClient = void 0;
10
+ const axios_1 = __importDefault(require("axios"));
11
+ const axios_retry_1 = __importDefault(require("axios-retry"));
12
+ const types_1 = require("./types");
13
+ const errors_1 = require("./errors");
14
+ const utils_1 = require("./utils");
15
+ /**
16
+ * Synchronous client for Infinium API.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * import { InfiniumClient, AgentType } from 'infinium';
21
+ *
22
+ * const client = new InfiniumClient({
23
+ * agentId: 'your-agent-id',
24
+ * agentSecret: 'your-agent-secret'
25
+ * });
26
+ *
27
+ * // Send a simple task
28
+ * const response = client.sendTask({
29
+ * name: 'Process customer inquiry',
30
+ * description: 'Handled customer question about pricing',
31
+ * duration: 120.5
32
+ * });
33
+ *
34
+ * // Send with additional data
35
+ * const taskData = {
36
+ * name: 'Marketing campaign analysis',
37
+ * description: 'Analyzed Q3 campaign performance',
38
+ * currentDatetime: client.getCurrentIsoDatetime(),
39
+ * duration: 300.0,
40
+ * agentType: AgentType.MARKETING_ASSISTANT
41
+ * };
42
+ * const response2 = client.sendTaskData(taskData);
43
+ * ```
44
+ */
45
+ class InfiniumClient {
46
+ agentId;
47
+ agentSecret;
48
+ baseUrl;
49
+ timeout;
50
+ maxRetries;
51
+ userAgent;
52
+ logger;
53
+ rateLimiter;
54
+ httpClient;
55
+ /**
56
+ * Initialize the Infinium client.
57
+ */
58
+ constructor(config) {
59
+ // Validate configuration
60
+ (0, utils_1.validateAgentCredentials)(config.agentId, config.agentSecret);
61
+ this.agentId = config.agentId;
62
+ this.agentSecret = config.agentSecret;
63
+ this.baseUrl = (0, utils_1.normalizeUrl)(config.baseUrl || 'https://api.i42m.ai/api/v1');
64
+ this.timeout = config.timeout || 30000;
65
+ this.maxRetries = config.maxRetries || 3;
66
+ this.userAgent = config.userAgent || (0, utils_1.generateUserAgent)('1.0.0');
67
+ this.logger = (0, utils_1.setupLogging)(config.enableLogging, config.logLevel);
68
+ // Setup rate limiter if enabled
69
+ this.rateLimiter =
70
+ config.enableRateLimiting !== false
71
+ ? new utils_1.RateLimiter({
72
+ requestsPerSecond: config.requestsPerSecond || 10,
73
+ burstSize: (config.requestsPerSecond || 10) * 2,
74
+ })
75
+ : null;
76
+ // Setup HTTP client
77
+ this.httpClient = this.createHttpClient();
78
+ this.logger.info('Infinium client initialized', {
79
+ agentId: this.agentId,
80
+ baseUrl: this.baseUrl,
81
+ timeout: this.timeout,
82
+ maxRetries: this.maxRetries,
83
+ rateLimitingEnabled: !!this.rateLimiter,
84
+ });
85
+ }
86
+ /**
87
+ * Create and configure HTTP client.
88
+ */
89
+ createHttpClient() {
90
+ const client = axios_1.default.create({
91
+ baseURL: this.baseUrl,
92
+ timeout: this.timeout,
93
+ headers: {
94
+ 'Content-Type': 'application/json',
95
+ 'User-Agent': this.userAgent,
96
+ 'x-agent-id': this.agentId,
97
+ 'x-agent-key': this.agentSecret,
98
+ },
99
+ });
100
+ // Setup retry logic
101
+ (0, axios_retry_1.default)(client, {
102
+ retries: this.maxRetries,
103
+ retryDelay: (retryCount) => {
104
+ return Math.min(1000 * 2 ** (retryCount - 1), 30000);
105
+ },
106
+ retryCondition: (error) => {
107
+ // eslint-disable-line @typescript-eslint/no-explicit-any
108
+ return (0, utils_1.shouldRetryError)(error);
109
+ },
110
+ onRetry: (retryCount, error, requestConfig) => {
111
+ // eslint-disable-line @typescript-eslint/no-explicit-any
112
+ this.logger.warn('Retrying request', {
113
+ retryCount,
114
+ url: requestConfig.url,
115
+ method: requestConfig.method,
116
+ error: error.message,
117
+ });
118
+ },
119
+ });
120
+ // Request interceptor for rate limiting
121
+ client.interceptors.request.use((config) => {
122
+ // eslint-disable-line @typescript-eslint/no-explicit-any
123
+ if (this.rateLimiter) {
124
+ if (!this.rateLimiter.canMakeRequest()) {
125
+ const waitTime = this.rateLimiter.getWaitTime();
126
+ throw new errors_1.RateLimitError(`Rate limit exceeded. Wait ${waitTime}ms before retrying.`, waitTime);
127
+ }
128
+ }
129
+ this.logger.debug('Making request', {
130
+ url: config.url,
131
+ method: config.method,
132
+ });
133
+ return config;
134
+ });
135
+ // Response interceptor for logging and error handling
136
+ client.interceptors.response.use((response) => {
137
+ // eslint-disable-line @typescript-eslint/no-explicit-any
138
+ this.logger.debug('Request successful', {
139
+ url: response.config.url,
140
+ method: response.config.method,
141
+ status: response.status,
142
+ });
143
+ return response;
144
+ }, (error) => {
145
+ // eslint-disable-line @typescript-eslint/no-explicit-any
146
+ this.logger.error('Request failed', {
147
+ url: error.config?.url,
148
+ method: error.config?.method,
149
+ status: error.response?.status,
150
+ message: error.message,
151
+ });
152
+ throw (0, errors_1.handleAxiosError)(error);
153
+ });
154
+ return client;
155
+ }
156
+ /**
157
+ * Make HTTP request with proper error handling.
158
+ */
159
+ async makeRequest(method, endpoint, data, options) {
160
+ try {
161
+ const config = {
162
+ method,
163
+ url: endpoint,
164
+ data,
165
+ timeout: options?.timeout || this.timeout,
166
+ ...(options?.headers && { headers: options.headers }),
167
+ };
168
+ const response = await this.httpClient.request(config);
169
+ return response.data;
170
+ }
171
+ catch (error) {
172
+ throw (0, errors_1.handleAxiosError)(error);
173
+ }
174
+ }
175
+ /**
176
+ * Send task data to the API.
177
+ */
178
+ async sendTask(task) {
179
+ // Validate required fields
180
+ (0, utils_1.validateRequiredField)(task.name, 'name');
181
+ (0, utils_1.validateRequiredField)(task.description, 'description');
182
+ (0, utils_1.validateRequiredField)(task.duration, 'duration', 'number');
183
+ // Validate and normalize data
184
+ (0, utils_1.validateDuration)(task.duration);
185
+ const agentType = task.agentType ? (0, utils_1.validateAgentType)(task.agentType) : types_1.AgentType.OTHER;
186
+ const currentDatetime = task.currentDatetime || (0, utils_1.getCurrentIsoDatetime)();
187
+ if (!(0, utils_1.validateIsoDatetime)(currentDatetime)) {
188
+ throw new errors_1.ValidationError('Invalid currentDatetime format. Must be ISO 8601.', 'currentDatetime');
189
+ }
190
+ // Build task payload
191
+ const taskPayload = {
192
+ name: task.name.trim(),
193
+ description: task.description.trim(),
194
+ current_datetime: currentDatetime,
195
+ duration: task.duration,
196
+ agent_type: agentType,
197
+ time_tracking: task.timeTracking,
198
+ customer: task.customer,
199
+ support: task.support,
200
+ sales: task.sales,
201
+ marketing: task.marketing,
202
+ content: task.content,
203
+ research: task.research,
204
+ project: task.project,
205
+ development: task.development,
206
+ executive: task.executive,
207
+ general: task.general,
208
+ };
209
+ // Remove undefined values
210
+ const cleanPayload = this.cleanPayload(taskPayload);
211
+ this.logger.info('Sending task', {
212
+ agentId: this.agentId,
213
+ taskName: task.name,
214
+ agentType,
215
+ });
216
+ return this.makeRequest('POST', `/agents/${this.agentId}/trace`, cleanPayload);
217
+ }
218
+ /**
219
+ * Send pre-built TaskData object.
220
+ */
221
+ async sendTaskData(taskData) {
222
+ return await this.sendTask(taskData);
223
+ }
224
+ /**
225
+ * Send multiple tasks in batch.
226
+ */
227
+ async sendBatch(tasks) {
228
+ if (!Array.isArray(tasks) || tasks.length === 0) {
229
+ throw new errors_1.ValidationError('Tasks array cannot be empty', 'tasks');
230
+ }
231
+ if (tasks.length > 100) {
232
+ throw new errors_1.ValidationError('Batch size cannot exceed 100 tasks', 'tasks');
233
+ }
234
+ const results = [];
235
+ const errors = [];
236
+ let successfulTasks = 0;
237
+ this.logger.info('Sending batch tasks', {
238
+ agentId: this.agentId,
239
+ taskCount: tasks.length,
240
+ });
241
+ for (let i = 0; i < tasks.length; i++) {
242
+ try {
243
+ const result = await this.sendTaskData(tasks[i]);
244
+ results.push(result);
245
+ if (result.success) {
246
+ successfulTasks++;
247
+ }
248
+ else {
249
+ errors.push(`Task ${i + 1}: ${result.message}`);
250
+ }
251
+ }
252
+ catch (error) {
253
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
254
+ errors.push(`Task ${i + 1}: ${errorMessage}`);
255
+ const errorResponse = {
256
+ success: false,
257
+ message: errorMessage,
258
+ ...(error instanceof errors_1.InfiniumError && error.statusCode
259
+ ? { statusCode: error.statusCode }
260
+ : {}),
261
+ };
262
+ results.push(errorResponse);
263
+ }
264
+ }
265
+ const batchResult = {
266
+ totalTasks: tasks.length,
267
+ successfulTasks,
268
+ failedTasks: tasks.length - successfulTasks,
269
+ results,
270
+ errors,
271
+ };
272
+ if (batchResult.failedTasks > 0) {
273
+ this.logger.warn('Batch completed with errors', {
274
+ totalTasks: batchResult.totalTasks,
275
+ successfulTasks: batchResult.successfulTasks,
276
+ failedTasks: batchResult.failedTasks,
277
+ });
278
+ }
279
+ else {
280
+ this.logger.info('Batch completed successfully', {
281
+ totalTasks: batchResult.totalTasks,
282
+ });
283
+ }
284
+ return batchResult;
285
+ }
286
+ /**
287
+ * Test connection to the API.
288
+ */
289
+ async testConnection() {
290
+ this.logger.info('Testing connection', { agentId: this.agentId });
291
+ const response = await this.makeRequest('GET', `/agents/${this.agentId}/health`);
292
+ if (!response.success || !response.data) {
293
+ throw new errors_1.ServerError(response.message || 'Health check failed', response.statusCode);
294
+ }
295
+ this.logger.info('Connection test successful', {
296
+ agentId: this.agentId,
297
+ agentName: response.data.agentName,
298
+ status: response.data.status,
299
+ });
300
+ return response.data;
301
+ }
302
+ /**
303
+ * Get interpreted task result.
304
+ */
305
+ getInterpretedTaskResult(taskId) {
306
+ (0, utils_1.validateRequiredField)(taskId, 'taskId');
307
+ this.logger.info('Getting interpreted task result', {
308
+ agentId: this.agentId,
309
+ taskId,
310
+ });
311
+ return this.makeRequest('GET', `/agents/${this.agentId}/interpreted-result/${taskId}`);
312
+ }
313
+ /**
314
+ * Get current ISO datetime string.
315
+ */
316
+ getCurrentIsoDatetime() {
317
+ return (0, utils_1.getCurrentIsoDatetime)();
318
+ }
319
+ /**
320
+ * Get client configuration.
321
+ */
322
+ getConfig() {
323
+ return {
324
+ agentId: this.agentId,
325
+ baseUrl: this.baseUrl,
326
+ timeout: this.timeout,
327
+ maxRetries: this.maxRetries,
328
+ userAgent: this.userAgent,
329
+ enableRateLimiting: !!this.rateLimiter,
330
+ };
331
+ }
332
+ /**
333
+ * Clean payload by removing undefined values.
334
+ */
335
+ cleanPayload(payload) {
336
+ const cleaned = {};
337
+ for (const [key, value] of Object.entries(payload)) {
338
+ if (value !== undefined && value !== null) {
339
+ if (typeof value === 'object' && !Array.isArray(value)) {
340
+ const cleanedNested = this.cleanPayload(value);
341
+ if (Object.keys(cleanedNested).length > 0) {
342
+ cleaned[key] = cleanedNested;
343
+ }
344
+ }
345
+ else {
346
+ cleaned[key] = value;
347
+ }
348
+ }
349
+ }
350
+ return cleaned;
351
+ }
352
+ }
353
+ exports.InfiniumClient = InfiniumClient;
354
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;AAEH,kDAAgF;AAChF,8DAAqC;AAErC,mCAmBiB;AACjB,qCAWkB;AAClB,mCAeiB;AAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAa,cAAc;IACR,OAAO,CAAS;IAEhB,WAAW,CAAS;IAEpB,OAAO,CAAS;IAEhB,OAAO,CAAS;IAEhB,UAAU,CAAS;IAEnB,SAAS,C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nD,MAAM,OAAO,GAA4B,EAAE,CAAC;QAE5C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACnD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;oBACvD,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,KAAgC,CAAC,CAAC;oBAC1E,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBAC1C,OAAO,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC;oBAC/B,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;gBACvB,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAnXD,wCAmXC"}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Exception classes for the Infinium SDK.
3
+ */
4
+ /**
5
+ * Base exception for all Infinium SDK errors.
6
+ */
7
+ export declare class InfiniumError extends Error {
8
+ readonly statusCode: number | undefined;
9
+ readonly details: Record<string, unknown>;
10
+ constructor(message: string, statusCode?: number, details?: Record<string, unknown>);
11
+ /**
12
+ * Convert error to JSON for logging or serialization.
13
+ */
14
+ toJSON(): Record<string, unknown>;
15
+ }
16
+ /**
17
+ * Raised when authentication fails.
18
+ */
19
+ export declare class AuthenticationError extends InfiniumError {
20
+ constructor(message?: string, statusCode?: number, details?: Record<string, unknown>);
21
+ }
22
+ /**
23
+ * Raised when request validation fails.
24
+ */
25
+ export declare class ValidationError extends InfiniumError {
26
+ readonly field: string | undefined;
27
+ constructor(message: string, field?: string, details?: Record<string, unknown>);
28
+ }
29
+ /**
30
+ * Raised when rate limit is exceeded.
31
+ */
32
+ export declare class RateLimitError extends InfiniumError {
33
+ readonly retryAfter: number | undefined;
34
+ constructor(message?: string, retryAfter?: number, details?: Record<string, unknown>);
35
+ }
36
+ /**
37
+ * Raised when network-related errors occur.
38
+ */
39
+ export declare class NetworkError extends InfiniumError {
40
+ readonly originalError: Error | undefined;
41
+ constructor(message: string, originalError?: Error, details?: Record<string, unknown>);
42
+ }
43
+ /**
44
+ * Raised when requests timeout.
45
+ */
46
+ export declare class TimeoutError extends NetworkError {
47
+ constructor(message?: string, timeout?: number, details?: Record<string, unknown>);
48
+ }
49
+ /**
50
+ * Raised when server returns 5xx status codes.
51
+ */
52
+ export declare class ServerError extends InfiniumError {
53
+ constructor(message: string, statusCode?: number, details?: Record<string, unknown>);
54
+ }
55
+ /**
56
+ * Raised when resource is not found (404).
57
+ */
58
+ export declare class NotFoundError extends InfiniumError {
59
+ readonly resource: string | undefined;
60
+ constructor(message: string, resource?: string, details?: Record<string, unknown>);
61
+ }
62
+ /**
63
+ * Raised when batch operations fail.
64
+ */
65
+ export declare class BatchError extends InfiniumError {
66
+ readonly failedTasks: number;
67
+ readonly totalTasks: number;
68
+ readonly errors: string[];
69
+ constructor(message: string, failedTasks: number, totalTasks: number, errors?: string[], details?: Record<string, unknown>);
70
+ }
71
+ /**
72
+ * Raised when configuration is invalid.
73
+ */
74
+ export declare class ConfigurationError extends InfiniumError {
75
+ readonly configField: string | undefined;
76
+ constructor(message: string, configField?: string, details?: Record<string, unknown>);
77
+ }
78
+ /**
79
+ * Raised when request data is too large.
80
+ */
81
+ export declare class PayloadTooLargeError extends InfiniumError {
82
+ readonly maxSize: number | undefined;
83
+ readonly actualSize: number | undefined;
84
+ constructor(message: string, maxSize?: number, actualSize?: number, details?: Record<string, unknown>);
85
+ }
86
+ /**
87
+ * Type guard to check if an error is an Infinium error.
88
+ */
89
+ export declare function isInfiniumError(error: unknown): error is InfiniumError;
90
+ /**
91
+ * Type guard to check if an error is a specific Infinium error type.
92
+ */
93
+ export declare function isErrorType<T extends InfiniumError>(error: unknown, errorClass: new (...args: any[]) => T): error is T;
94
+ /**
95
+ * Convert an unknown error to an InfiniumError.
96
+ */
97
+ export declare function toInfiniumError(error: unknown): InfiniumError;
98
+ /**
99
+ * Handle axios errors and convert to appropriate Infinium errors.
100
+ */
101
+ export declare function handleAxiosError(error: unknown): InfiniumError;
102
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,SAAgB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAE/C,SAAgB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAErC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;IAYvF;;OAEG;IACH,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CASlC;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,aAAa;gBAElD,OAAO,SAA0B,EACjC,UAAU,SAAM,EAChB,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAIxC;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,aAAa;IAChD,SAAgB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;gBAE9B,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;CAInF;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,aAAa;IAC/C,SAAgB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;gBAG7C,OAAO,SAAwB,EAC/B,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,GA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