@lobu/core 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/encryption.test.d.ts +2 -0
- package/dist/__tests__/encryption.test.d.ts.map +1 -0
- package/dist/__tests__/encryption.test.js +88 -0
- package/dist/__tests__/encryption.test.js.map +1 -0
- package/dist/__tests__/fixtures/factories.d.ts +30 -0
- package/dist/__tests__/fixtures/factories.d.ts.map +1 -0
- package/dist/__tests__/fixtures/factories.js +53 -0
- package/dist/__tests__/fixtures/factories.js.map +1 -0
- package/dist/__tests__/fixtures/index.d.ts +5 -0
- package/dist/__tests__/fixtures/index.d.ts.map +1 -0
- package/dist/__tests__/fixtures/index.js +14 -0
- package/dist/__tests__/fixtures/index.js.map +1 -0
- package/dist/__tests__/fixtures/mock-fetch.d.ts +13 -0
- package/dist/__tests__/fixtures/mock-fetch.d.ts.map +1 -0
- package/dist/__tests__/fixtures/mock-fetch.js +29 -0
- package/dist/__tests__/fixtures/mock-fetch.js.map +1 -0
- package/dist/__tests__/fixtures/mock-queue.d.ts +19 -0
- package/dist/__tests__/fixtures/mock-queue.d.ts.map +1 -0
- package/dist/__tests__/fixtures/mock-queue.js +45 -0
- package/dist/__tests__/fixtures/mock-queue.js.map +1 -0
- package/dist/__tests__/fixtures/mock-redis.d.ts +54 -0
- package/dist/__tests__/fixtures/mock-redis.d.ts.map +1 -0
- package/dist/__tests__/fixtures/mock-redis.js +267 -0
- package/dist/__tests__/fixtures/mock-redis.js.map +1 -0
- package/dist/__tests__/retry.test.d.ts +2 -0
- package/dist/__tests__/retry.test.d.ts.map +1 -0
- package/dist/__tests__/retry.test.js +114 -0
- package/dist/__tests__/retry.test.js.map +1 -0
- package/dist/__tests__/sanitize.test.d.ts +2 -0
- package/dist/__tests__/sanitize.test.d.ts.map +1 -0
- package/dist/__tests__/sanitize.test.js +129 -0
- package/dist/__tests__/sanitize.test.js.map +1 -0
- package/dist/agent-policy.d.ts +21 -0
- package/dist/agent-policy.d.ts.map +1 -0
- package/dist/agent-policy.js +181 -0
- package/dist/agent-policy.js.map +1 -0
- package/dist/agent-store.d.ts +140 -0
- package/dist/agent-store.d.ts.map +1 -0
- package/dist/agent-store.js +27 -0
- package/dist/agent-store.js.map +1 -0
- package/dist/api-types.d.ts +213 -0
- package/dist/api-types.d.ts.map +1 -0
- package/dist/api-types.js +7 -0
- package/dist/api-types.js.map +1 -0
- package/dist/command-registry.d.ts +41 -0
- package/dist/command-registry.d.ts.map +1 -0
- package/dist/command-registry.js +43 -0
- package/dist/command-registry.js.map +1 -0
- package/dist/constants.d.ts +54 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +60 -0
- package/dist/constants.js.map +1 -0
- package/dist/errors.d.ts +97 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +182 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +64 -0
- package/dist/index.js.map +1 -0
- package/dist/integration-types.d.ts +22 -0
- package/dist/integration-types.d.ts.map +1 -0
- package/dist/integration-types.js +9 -0
- package/dist/integration-types.js.map +1 -0
- package/dist/logger.d.ts +15 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +223 -0
- package/dist/logger.js.map +1 -0
- package/dist/modules.d.ts +96 -0
- package/dist/modules.d.ts.map +1 -0
- package/dist/modules.js +140 -0
- package/dist/modules.js.map +1 -0
- package/dist/otel.d.ts +107 -0
- package/dist/otel.d.ts.map +1 -0
- package/dist/otel.js +251 -0
- package/dist/otel.js.map +1 -0
- package/dist/plugin-types.d.ts +42 -0
- package/dist/plugin-types.d.ts.map +1 -0
- package/dist/plugin-types.js +8 -0
- package/dist/plugin-types.js.map +1 -0
- package/dist/provider-config-types.d.ts +53 -0
- package/dist/provider-config-types.d.ts.map +1 -0
- package/dist/provider-config-types.js +7 -0
- package/dist/provider-config-types.js.map +1 -0
- package/dist/redis/base-store.d.ts +73 -0
- package/dist/redis/base-store.d.ts.map +1 -0
- package/dist/redis/base-store.js +174 -0
- package/dist/redis/base-store.js.map +1 -0
- package/dist/sentry.d.ts +12 -0
- package/dist/sentry.d.ts.map +1 -0
- package/dist/sentry.js +82 -0
- package/dist/sentry.js.map +1 -0
- package/dist/trace.d.ts +25 -0
- package/dist/trace.d.ts.map +1 -0
- package/dist/trace.js +32 -0
- package/dist/trace.js.map +1 -0
- package/dist/types.d.ts +373 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/encryption.d.ts +9 -0
- package/dist/utils/encryption.d.ts.map +1 -0
- package/dist/utils/encryption.js +107 -0
- package/dist/utils/encryption.js.map +1 -0
- package/dist/utils/env.d.ts +20 -0
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/utils/env.js +50 -0
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/json.d.ts +11 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +38 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/lock.d.ts +34 -0
- package/dist/utils/lock.d.ts.map +1 -0
- package/dist/utils/lock.js +66 -0
- package/dist/utils/lock.js.map +1 -0
- package/dist/utils/mcp-tool-instructions.d.ts +6 -0
- package/dist/utils/mcp-tool-instructions.d.ts.map +1 -0
- package/dist/utils/mcp-tool-instructions.js +3 -0
- package/dist/utils/mcp-tool-instructions.js.map +1 -0
- package/dist/utils/retry.d.ts +40 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +67 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/utils/sanitize.d.ts +55 -0
- package/dist/utils/sanitize.d.ts.map +1 -0
- package/dist/utils/sanitize.js +111 -0
- package/dist/utils/sanitize.js.map +1 -0
- package/dist/worker/auth.d.ts +34 -0
- package/dist/worker/auth.d.ts.map +1 -0
- package/dist/worker/auth.js +63 -0
- package/dist/worker/auth.js.map +1 -0
- package/dist/worker/transport.d.ts +86 -0
- package/dist/worker/transport.d.ts.map +1 -0
- package/dist/worker/transport.js +13 -0
- package/dist/worker/transport.js.map +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get required environment variable
|
|
3
|
+
* Throws ConfigError if not set
|
|
4
|
+
*/
|
|
5
|
+
export declare function getRequiredEnv(name: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Get optional environment variable with default
|
|
8
|
+
*/
|
|
9
|
+
export declare function getOptionalEnv(name: string, defaultValue: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Get optional number environment variable with default
|
|
12
|
+
* Throws ConfigError if value is not a valid number
|
|
13
|
+
*/
|
|
14
|
+
export declare function getOptionalNumber(name: string, defaultValue: number): number;
|
|
15
|
+
/**
|
|
16
|
+
* Get optional boolean environment variable with default
|
|
17
|
+
* Accepts "true", "1", "yes" as truthy values
|
|
18
|
+
*/
|
|
19
|
+
export declare function getOptionalBoolean(name: string, defaultValue: boolean): boolean;
|
|
20
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/utils/env.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMnD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAU5E;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,OAAO,GACpB,OAAO,CAKT"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRequiredEnv = getRequiredEnv;
|
|
4
|
+
exports.getOptionalEnv = getOptionalEnv;
|
|
5
|
+
exports.getOptionalNumber = getOptionalNumber;
|
|
6
|
+
exports.getOptionalBoolean = getOptionalBoolean;
|
|
7
|
+
const errors_1 = require("../errors");
|
|
8
|
+
/**
|
|
9
|
+
* Get required environment variable
|
|
10
|
+
* Throws ConfigError if not set
|
|
11
|
+
*/
|
|
12
|
+
function getRequiredEnv(name) {
|
|
13
|
+
const value = process.env[name];
|
|
14
|
+
if (!value) {
|
|
15
|
+
throw new errors_1.ConfigError(`Missing required environment variable: ${name}`);
|
|
16
|
+
}
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get optional environment variable with default
|
|
21
|
+
*/
|
|
22
|
+
function getOptionalEnv(name, defaultValue) {
|
|
23
|
+
return process.env[name] || defaultValue;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get optional number environment variable with default
|
|
27
|
+
* Throws ConfigError if value is not a valid number
|
|
28
|
+
*/
|
|
29
|
+
function getOptionalNumber(name, defaultValue) {
|
|
30
|
+
const value = process.env[name];
|
|
31
|
+
if (!value)
|
|
32
|
+
return defaultValue;
|
|
33
|
+
const parsed = parseInt(value, 10);
|
|
34
|
+
if (Number.isNaN(parsed)) {
|
|
35
|
+
throw new errors_1.ConfigError(`Invalid number for ${name}: ${value} (expected integer)`);
|
|
36
|
+
}
|
|
37
|
+
return parsed;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get optional boolean environment variable with default
|
|
41
|
+
* Accepts "true", "1", "yes" as truthy values
|
|
42
|
+
*/
|
|
43
|
+
function getOptionalBoolean(name, defaultValue) {
|
|
44
|
+
const value = process.env[name];
|
|
45
|
+
if (!value)
|
|
46
|
+
return defaultValue;
|
|
47
|
+
const lower = value.toLowerCase();
|
|
48
|
+
return lower === "true" || lower === "1" || lower === "yes";
|
|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,CAAC,WAAW,EAAE,CAAC;IAClC,OAAO,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,KAAK,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safely parse JSON string
|
|
3
|
+
* Returns null on parse failure instead of throwing
|
|
4
|
+
*/
|
|
5
|
+
export declare function safeJsonParse<T = unknown>(data: string, fallback?: T | null): T | null;
|
|
6
|
+
/**
|
|
7
|
+
* Safely stringify value to JSON
|
|
8
|
+
* Returns null on stringify failure instead of throwing
|
|
9
|
+
*/
|
|
10
|
+
export declare function safeJsonStringify(value: unknown): string | null;
|
|
11
|
+
//# sourceMappingURL=json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/utils/json.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,GAAG,OAAO,EACvC,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,CAAC,GAAG,IAAW,GACxB,CAAC,GAAG,IAAI,CAUV;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAS/D"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.safeJsonParse = safeJsonParse;
|
|
4
|
+
exports.safeJsonStringify = safeJsonStringify;
|
|
5
|
+
const logger_1 = require("../logger");
|
|
6
|
+
const logger = (0, logger_1.createLogger)("json-utils");
|
|
7
|
+
/**
|
|
8
|
+
* Safely parse JSON string
|
|
9
|
+
* Returns null on parse failure instead of throwing
|
|
10
|
+
*/
|
|
11
|
+
function safeJsonParse(data, fallback = null) {
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse(data);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
logger.debug("JSON parse failed", {
|
|
17
|
+
error: error instanceof Error ? error.message : String(error),
|
|
18
|
+
dataPreview: data.substring(0, 100),
|
|
19
|
+
});
|
|
20
|
+
return fallback;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Safely stringify value to JSON
|
|
25
|
+
* Returns null on stringify failure instead of throwing
|
|
26
|
+
*/
|
|
27
|
+
function safeJsonStringify(value) {
|
|
28
|
+
try {
|
|
29
|
+
return JSON.stringify(value);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
logger.error("JSON stringify failed", {
|
|
33
|
+
error: error instanceof Error ? error.message : String(error),
|
|
34
|
+
});
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/utils/json.ts"],"names":[],"mappings":";;AAQA,sCAaC;AAMD,8CASC;AApCD,sCAAyC;AAEzC,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC,YAAY,CAAC,CAAC;AAE1C;;;GAGG;AACH,SAAgB,aAAa,CAC3B,IAAY,EACZ,WAAqB,IAAI;IAEzB,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAC;IAC/B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,mBAAmB,EAAE;YAChC,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YAC7D,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC;SACpC,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC;IAClB,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,KAAc;IAC9C,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,uBAAuB,EAAE;YACpC,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC9D,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async lock for serializing concurrent operations
|
|
3
|
+
* Prevents race conditions in async code by ensuring only one operation runs at a time
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* class StreamSession {
|
|
8
|
+
* private streamLock = new AsyncLock();
|
|
9
|
+
*
|
|
10
|
+
* async appendDelta(delta: string) {
|
|
11
|
+
* return this.streamLock.acquire(() => this.appendDeltaUnsafe(delta));
|
|
12
|
+
* }
|
|
13
|
+
*
|
|
14
|
+
* private async appendDeltaUnsafe(delta: string) {
|
|
15
|
+
* // Critical section - only one execution at a time
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare class AsyncLock {
|
|
21
|
+
private lock;
|
|
22
|
+
private lockContext;
|
|
23
|
+
constructor(context?: string);
|
|
24
|
+
/**
|
|
25
|
+
* Acquire lock and execute function exclusively
|
|
26
|
+
*
|
|
27
|
+
* @param fn - The async function to execute with exclusive access
|
|
28
|
+
* @param timeoutMs - Maximum time to wait for lock acquisition (default: 30s)
|
|
29
|
+
* @returns The result of the function
|
|
30
|
+
* @throws Error if lock acquisition times out
|
|
31
|
+
*/
|
|
32
|
+
acquire<T>(fn: () => Promise<T>, timeoutMs?: number): Promise<T>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=lock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lock.d.ts","sourceRoot":"","sources":["../../src/utils/lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,IAAI,CAAoC;IAChD,OAAO,CAAC,WAAW,CAAS;gBAEhB,OAAO,GAAE,MAAkB;IAIvC;;;;;;;OAOG;IACG,OAAO,CAAC,CAAC,EACb,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,SAAS,GAAE,MAAc,GACxB,OAAO,CAAC,CAAC,CAAC;CAoCd"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AsyncLock = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Async lock for serializing concurrent operations
|
|
6
|
+
* Prevents race conditions in async code by ensuring only one operation runs at a time
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* class StreamSession {
|
|
11
|
+
* private streamLock = new AsyncLock();
|
|
12
|
+
*
|
|
13
|
+
* async appendDelta(delta: string) {
|
|
14
|
+
* return this.streamLock.acquire(() => this.appendDeltaUnsafe(delta));
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* private async appendDeltaUnsafe(delta: string) {
|
|
18
|
+
* // Critical section - only one execution at a time
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
class AsyncLock {
|
|
24
|
+
constructor(context = "unknown") {
|
|
25
|
+
this.lock = Promise.resolve();
|
|
26
|
+
this.lockContext = context;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Acquire lock and execute function exclusively
|
|
30
|
+
*
|
|
31
|
+
* @param fn - The async function to execute with exclusive access
|
|
32
|
+
* @param timeoutMs - Maximum time to wait for lock acquisition (default: 30s)
|
|
33
|
+
* @returns The result of the function
|
|
34
|
+
* @throws Error if lock acquisition times out
|
|
35
|
+
*/
|
|
36
|
+
async acquire(fn, timeoutMs = 30000) {
|
|
37
|
+
const currentLock = this.lock;
|
|
38
|
+
let releaseLock;
|
|
39
|
+
// Create new lock that will be released when fn completes
|
|
40
|
+
this.lock = new Promise((resolve) => {
|
|
41
|
+
releaseLock = resolve;
|
|
42
|
+
});
|
|
43
|
+
let timeoutId;
|
|
44
|
+
try {
|
|
45
|
+
// Wait for previous operation with timeout to prevent deadlock
|
|
46
|
+
const lockTimeout = new Promise((_, reject) => {
|
|
47
|
+
timeoutId = setTimeout(() => {
|
|
48
|
+
reject(new Error(`Lock acquisition timeout after ${timeoutMs}ms - possible deadlock in ${this.lockContext}`));
|
|
49
|
+
}, timeoutMs);
|
|
50
|
+
});
|
|
51
|
+
await Promise.race([currentLock, lockTimeout]);
|
|
52
|
+
// Execute function with exclusive access
|
|
53
|
+
return await fn();
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
// Clear the timeout to prevent leak
|
|
57
|
+
if (timeoutId !== undefined) {
|
|
58
|
+
clearTimeout(timeoutId);
|
|
59
|
+
}
|
|
60
|
+
// Always release lock, even on error
|
|
61
|
+
releaseLock?.();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.AsyncLock = AsyncLock;
|
|
66
|
+
//# sourceMappingURL=lock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lock.js","sourceRoot":"","sources":["../../src/utils/lock.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAa,SAAS;IAIpB,YAAY,UAAkB,SAAS;QAH/B,SAAI,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;QAI9C,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;IAC7B,CAAC;IAED;;;;;;;OAOG;IACH,KAAK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CAAC;CACvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tool-instructions.js","sourceRoot":"","sources":["../../src/utils/mcp-tool-instructions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface RetryOptions {
|
|
2
|
+
maxRetries?: number;
|
|
3
|
+
baseDelay?: number;
|
|
4
|
+
strategy?: "exponential" | "linear";
|
|
5
|
+
jitter?: boolean;
|
|
6
|
+
onRetry?: (attempt: number, error: Error) => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Retry a function with configurable backoff strategy
|
|
10
|
+
*
|
|
11
|
+
* @param fn - The async function to retry
|
|
12
|
+
* @param options - Retry configuration
|
|
13
|
+
* @returns The result of the function
|
|
14
|
+
* @throws The last error if all retries fail
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // Exponential backoff (default)
|
|
19
|
+
* const result = await retryWithBackoff(
|
|
20
|
+
* () => fetch('https://api.example.com'),
|
|
21
|
+
* { maxRetries: 3, baseDelay: 1000 }
|
|
22
|
+
* );
|
|
23
|
+
*
|
|
24
|
+
* // Linear backoff with jitter
|
|
25
|
+
* const result = await retryWithBackoff(
|
|
26
|
+
* () => createDeployment(),
|
|
27
|
+
* {
|
|
28
|
+
* maxRetries: 3,
|
|
29
|
+
* strategy: 'linear',
|
|
30
|
+
* jitter: true,
|
|
31
|
+
* baseDelay: 2000,
|
|
32
|
+
* onRetry: (attempt, error) => {
|
|
33
|
+
* logger.warn(`Attempt ${attempt} failed: ${error.message}`);
|
|
34
|
+
* }
|
|
35
|
+
* }
|
|
36
|
+
* );
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function retryWithBackoff<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
40
|
+
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/utils/retry.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,aAAa,GAAG,QAAQ,CAAC;IACpC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACnD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,CAAC,CAAC,CA4CZ"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.retryWithBackoff = retryWithBackoff;
|
|
4
|
+
const logger_1 = require("../logger");
|
|
5
|
+
const logger = (0, logger_1.createLogger)("retry");
|
|
6
|
+
/**
|
|
7
|
+
* Retry a function with configurable backoff strategy
|
|
8
|
+
*
|
|
9
|
+
* @param fn - The async function to retry
|
|
10
|
+
* @param options - Retry configuration
|
|
11
|
+
* @returns The result of the function
|
|
12
|
+
* @throws The last error if all retries fail
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // Exponential backoff (default)
|
|
17
|
+
* const result = await retryWithBackoff(
|
|
18
|
+
* () => fetch('https://api.example.com'),
|
|
19
|
+
* { maxRetries: 3, baseDelay: 1000 }
|
|
20
|
+
* );
|
|
21
|
+
*
|
|
22
|
+
* // Linear backoff with jitter
|
|
23
|
+
* const result = await retryWithBackoff(
|
|
24
|
+
* () => createDeployment(),
|
|
25
|
+
* {
|
|
26
|
+
* maxRetries: 3,
|
|
27
|
+
* strategy: 'linear',
|
|
28
|
+
* jitter: true,
|
|
29
|
+
* baseDelay: 2000,
|
|
30
|
+
* onRetry: (attempt, error) => {
|
|
31
|
+
* logger.warn(`Attempt ${attempt} failed: ${error.message}`);
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
* );
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
async function retryWithBackoff(fn, options = {}) {
|
|
38
|
+
const { maxRetries = 3, baseDelay = 1000, strategy = "exponential", jitter = false, onRetry, } = options;
|
|
39
|
+
let lastError;
|
|
40
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
41
|
+
try {
|
|
42
|
+
return await fn();
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
lastError = error;
|
|
46
|
+
if (attempt < maxRetries) {
|
|
47
|
+
// Calculate delay based on strategy
|
|
48
|
+
const delay = strategy === "exponential"
|
|
49
|
+
? baseDelay * 2 ** attempt
|
|
50
|
+
: baseDelay * (attempt + 1);
|
|
51
|
+
// Add jitter if requested (0-1000ms random)
|
|
52
|
+
const jitterMs = jitter ? Math.random() * 1000 : 0;
|
|
53
|
+
const finalDelay = delay + jitterMs;
|
|
54
|
+
// Notify caller of retry
|
|
55
|
+
if (onRetry) {
|
|
56
|
+
onRetry(attempt + 1, lastError);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
logger.warn(`Retry attempt ${attempt + 1}/${maxRetries} after ${Math.round(finalDelay)}ms`, { error: lastError.message });
|
|
60
|
+
}
|
|
61
|
+
await new Promise((resolve) => setTimeout(resolve, finalDelay));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
throw lastError;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=retry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/utils/retry.ts"],"names":[],"mappings":";;AA2CA,4CA+CC;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E,EAAE,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,CAC7B,CAAC;gBACJ,CAAC;gBAED,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;YAClE,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,SAAS,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sanitize filename to prevent path traversal attacks
|
|
3
|
+
* Removes directory separators and dangerous characters
|
|
4
|
+
*
|
|
5
|
+
* @param filename - The filename to sanitize
|
|
6
|
+
* @param maxLength - Maximum filename length (default: 255)
|
|
7
|
+
* @returns Safe filename
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* sanitizeFilename("../../etc/passwd") // "etc_passwd"
|
|
12
|
+
* sanitizeFilename("file<>|name.txt") // "file___name.txt"
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function sanitizeFilename(filename: string, maxLength?: number): string;
|
|
16
|
+
/**
|
|
17
|
+
* Sanitize conversation ID for filesystem usage
|
|
18
|
+
* Removes any characters that aren't safe for directory names
|
|
19
|
+
*
|
|
20
|
+
* @param conversationId - The conversation ID to sanitize
|
|
21
|
+
* @returns Safe conversation ID
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* sanitizeConversationId("1756766056.836119") // "1756766056.836119"
|
|
26
|
+
* sanitizeConversationId("thread/123/../456") // "thread_123___456"
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function sanitizeConversationId(conversationId: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Sanitize sensitive data from objects before logging
|
|
32
|
+
* Redacts API keys, tokens, and other credentials
|
|
33
|
+
*
|
|
34
|
+
* @param obj - Object to sanitize
|
|
35
|
+
* @param sensitiveKeys - Additional sensitive key names to redact
|
|
36
|
+
* @returns Sanitized object safe for logging
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const config = {
|
|
41
|
+
* apiKey: "secret-key-123",
|
|
42
|
+
* timeout: 5000,
|
|
43
|
+
* env: { TOKEN: "bearer-xyz" }
|
|
44
|
+
* };
|
|
45
|
+
*
|
|
46
|
+
* sanitizeForLogging(config)
|
|
47
|
+
* // {
|
|
48
|
+
* // apiKey: "[REDACTED:14]",
|
|
49
|
+
* // timeout: 5000,
|
|
50
|
+
* // env: { TOKEN: "[REDACTED:10]" }
|
|
51
|
+
* // }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function sanitizeForLogging(obj: any, additionalSensitiveKeys?: string[]): any;
|
|
55
|
+
//# sourceMappingURL=sanitize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/utils/sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,SAAS,GAAE,MAAY,GACtB,MAAM,CAiBR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAErE;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,GAAG,EACR,uBAAuB,GAAE,MAAM,EAAO,GACrC,GAAG,CA8CL"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sanitizeFilename = sanitizeFilename;
|
|
4
|
+
exports.sanitizeConversationId = sanitizeConversationId;
|
|
5
|
+
exports.sanitizeForLogging = sanitizeForLogging;
|
|
6
|
+
/**
|
|
7
|
+
* Sanitize filename to prevent path traversal attacks
|
|
8
|
+
* Removes directory separators and dangerous characters
|
|
9
|
+
*
|
|
10
|
+
* @param filename - The filename to sanitize
|
|
11
|
+
* @param maxLength - Maximum filename length (default: 255)
|
|
12
|
+
* @returns Safe filename
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* sanitizeFilename("../../etc/passwd") // "etc_passwd"
|
|
17
|
+
* sanitizeFilename("file<>|name.txt") // "file___name.txt"
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
function sanitizeFilename(filename, maxLength = 255) {
|
|
21
|
+
// Remove any directory path components
|
|
22
|
+
const basename = filename.replace(/^.*[\\/]/, "");
|
|
23
|
+
// Remove null bytes and other dangerous characters
|
|
24
|
+
const sanitized = basename.replace(/[^\w\s.-]/g, "_");
|
|
25
|
+
// Prevent hidden files and parent directory references
|
|
26
|
+
const safe = sanitized.replace(/^\.+/, "").replace(/\.{2,}/g, ".");
|
|
27
|
+
// Ensure filename is not empty after sanitization
|
|
28
|
+
if (!safe || safe.length === 0) {
|
|
29
|
+
return "unnamed_file";
|
|
30
|
+
}
|
|
31
|
+
// Limit filename length
|
|
32
|
+
return safe.length > maxLength ? safe.substring(0, maxLength) : safe;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Sanitize conversation ID for filesystem usage
|
|
36
|
+
* Removes any characters that aren't safe for directory names
|
|
37
|
+
*
|
|
38
|
+
* @param conversationId - The conversation ID to sanitize
|
|
39
|
+
* @returns Safe conversation ID
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* sanitizeConversationId("1756766056.836119") // "1756766056.836119"
|
|
44
|
+
* sanitizeConversationId("thread/123/../456") // "thread_123___456"
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
function sanitizeConversationId(conversationId) {
|
|
48
|
+
return conversationId.replace(/[^a-zA-Z0-9.-]/g, "_");
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Sanitize sensitive data from objects before logging
|
|
52
|
+
* Redacts API keys, tokens, and other credentials
|
|
53
|
+
*
|
|
54
|
+
* @param obj - Object to sanitize
|
|
55
|
+
* @param sensitiveKeys - Additional sensitive key names to redact
|
|
56
|
+
* @returns Sanitized object safe for logging
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* const config = {
|
|
61
|
+
* apiKey: "secret-key-123",
|
|
62
|
+
* timeout: 5000,
|
|
63
|
+
* env: { TOKEN: "bearer-xyz" }
|
|
64
|
+
* };
|
|
65
|
+
*
|
|
66
|
+
* sanitizeForLogging(config)
|
|
67
|
+
* // {
|
|
68
|
+
* // apiKey: "[REDACTED:14]",
|
|
69
|
+
* // timeout: 5000,
|
|
70
|
+
* // env: { TOKEN: "[REDACTED:10]" }
|
|
71
|
+
* // }
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
function sanitizeForLogging(obj, additionalSensitiveKeys = []) {
|
|
75
|
+
if (!obj || typeof obj !== "object") {
|
|
76
|
+
return obj;
|
|
77
|
+
}
|
|
78
|
+
const defaultSensitiveKeys = [
|
|
79
|
+
"anthropic_api_key",
|
|
80
|
+
"api_key",
|
|
81
|
+
"apiKey",
|
|
82
|
+
"token",
|
|
83
|
+
"password",
|
|
84
|
+
"secret",
|
|
85
|
+
"authorization",
|
|
86
|
+
"bearer",
|
|
87
|
+
"credentials",
|
|
88
|
+
"privateKey",
|
|
89
|
+
"private_key",
|
|
90
|
+
];
|
|
91
|
+
const sensitiveKeys = [...defaultSensitiveKeys, ...additionalSensitiveKeys];
|
|
92
|
+
const sanitized = Array.isArray(obj) ? [...obj] : { ...obj };
|
|
93
|
+
for (const key in sanitized) {
|
|
94
|
+
const lowerKey = key.toLowerCase();
|
|
95
|
+
const isSensitive = sensitiveKeys.some((k) => lowerKey.includes(k));
|
|
96
|
+
if (isSensitive && typeof sanitized[key] === "string") {
|
|
97
|
+
// Redact but show length for debugging
|
|
98
|
+
sanitized[key] = `[REDACTED:${sanitized[key].length}]`;
|
|
99
|
+
}
|
|
100
|
+
else if (key === "env" && typeof sanitized[key] === "object") {
|
|
101
|
+
// Recursively sanitize env object
|
|
102
|
+
sanitized[key] = sanitizeForLogging(sanitized[key], additionalSensitiveKeys);
|
|
103
|
+
}
|
|
104
|
+
else if (typeof sanitized[key] === "object") {
|
|
105
|
+
// Recursively sanitize nested objects
|
|
106
|
+
sanitized[key] = sanitizeForLogging(sanitized[key], additionalSensitiveKeys);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return sanitized;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=sanitize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitize.js","sourceRoot":"","sources":["../../src/utils/sanitize.ts"],"names":[],"mappings":";;AAcA,4CAoBC;AAeD,wDAEC;AA0BD,gDAiDC;AA9HD;;;;;;;;;;;;;GAaG;AACH,SAAgB,gBAAgB,CAC9B,QAAgB,EAChB,YAAoB,GAAG;IAEvB,uCAAuC;IACvC,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAElD,mDAAmD;IACnD,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IAEtD,uDAAuD;IACvD,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IAEnE,kDAAkD;IAClD,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,wBAAwB;IACxB,OAAO,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,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,KAAK,IAAI,OAAO,SAAS,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC/D,kCAAkC;YAClC,SAAS,CAAC,GAAG,CAAC,GAAG,kBAAkB,CACjC,SAAS,CAAC,GAAG,CAAC,EACd,uBAAuB,CACxB,CAAC;QACJ,CAAC;aAAM,IAAI,OAAO,SAAS,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC9C,sCAAsC;YACtC,SAAS,CAAC,GAAG,CAAC,GAAG,kBAAkB,CACjC,SAAS,CAAC,GAAG,CAAC,EACd,uBAAuB,CACxB,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker authentication using encrypted conversation ID
|
|
3
|
+
* Token format: encrypted(userId:conversationId:deploymentName:timestamp)
|
|
4
|
+
*/
|
|
5
|
+
export interface WorkerTokenData {
|
|
6
|
+
userId: string;
|
|
7
|
+
conversationId: string;
|
|
8
|
+
channelId: string;
|
|
9
|
+
teamId?: string;
|
|
10
|
+
agentId?: string;
|
|
11
|
+
connectionId?: string;
|
|
12
|
+
deploymentName: string;
|
|
13
|
+
timestamp: number;
|
|
14
|
+
platform?: string;
|
|
15
|
+
sessionKey?: string;
|
|
16
|
+
traceId?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Generate a worker authentication token by encrypting thread metadata
|
|
20
|
+
*/
|
|
21
|
+
export declare function generateWorkerToken(userId: string, conversationId: string, deploymentName: string, options: {
|
|
22
|
+
channelId: string;
|
|
23
|
+
teamId?: string;
|
|
24
|
+
agentId?: string;
|
|
25
|
+
connectionId?: string;
|
|
26
|
+
platform?: string;
|
|
27
|
+
sessionKey?: string;
|
|
28
|
+
traceId?: string;
|
|
29
|
+
}): string;
|
|
30
|
+
/**
|
|
31
|
+
* Verify and decrypt a worker authentication token
|
|
32
|
+
*/
|
|
33
|
+
export declare function verifyWorkerToken(token: string): WorkerTokenData | null;
|
|
34
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/worker/auth.ts"],"names":[],"mappings":"AAKA;;;GAGG;AAEH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE;IACP,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GACA,MAAM,CAwBR;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CA8BvE"}
|