@yadsh/dsh-kv-persist 0.2.0 → 0.2.2
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/README.md +3 -1
- package/docs/dsh-kv-persist.md +4 -3
- package/lib/backends/llama-cpp/client.d.ts.map +1 -1
- package/lib/backends/llama-cpp/client.js +26 -11
- package/lib/backends/llama-cpp/client.js.map +1 -1
- package/lib/coordinator/coordinator.d.ts +3 -1
- package/lib/coordinator/coordinator.d.ts.map +1 -1
- package/lib/coordinator/coordinator.js +30 -13
- package/lib/coordinator/coordinator.js.map +1 -1
- package/lib/coordinator/slot-lease.d.ts +6 -4
- package/lib/coordinator/slot-lease.d.ts.map +1 -1
- package/lib/coordinator/slot-lease.js +28 -10
- package/lib/coordinator/slot-lease.js.map +1 -1
- package/lib/observability/diagnostics.d.ts +1 -7
- package/lib/observability/diagnostics.d.ts.map +1 -1
- package/lib/observability/diagnostics.js +2 -15
- package/lib/observability/diagnostics.js.map +1 -1
- package/lib/service.d.ts +3 -2
- package/lib/service.d.ts.map +1 -1
- package/lib/service.js +19 -14
- package/lib/service.js.map +1 -1
- package/package.json +4 -4
- package/lib/logging/dsh-home.d.ts +0 -13
- package/lib/logging/dsh-home.d.ts.map +0 -1
- package/lib/logging/dsh-home.js +0 -18
- package/lib/logging/dsh-home.js.map +0 -1
- package/lib/logging/index.d.ts +0 -10
- package/lib/logging/index.d.ts.map +0 -1
- package/lib/logging/index.js +0 -10
- package/lib/logging/index.js.map +0 -1
- package/lib/logging/plugin-logger.d.ts +0 -94
- package/lib/logging/plugin-logger.d.ts.map +0 -1
- package/lib/logging/plugin-logger.js +0 -397
- package/lib/logging/plugin-logger.js.map +0 -1
package/lib/service.js
CHANGED
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
* reference plugins follow.
|
|
12
12
|
*/
|
|
13
13
|
import { mkdir, rm, writeFile } from "node:fs/promises";
|
|
14
|
-
import { join } from "node:path";
|
|
14
|
+
import { join, resolve } from "node:path";
|
|
15
15
|
import { Context, Service } from "@deepseek-ai/cordis";
|
|
16
|
+
import { resolveDshHome } from "@yadsh/dsh-plugin-log";
|
|
16
17
|
import { KvPersistConfigSchema, resolveKvPersistConfig, isManagedProvider } from "./config.js";
|
|
17
18
|
import { LlamaCppBackend } from "./backends/llama-cpp/backend.js";
|
|
18
19
|
import { SingleSlotCoordinator } from "./coordinator/coordinator.js";
|
|
@@ -21,13 +22,13 @@ import { KvPersistMetrics } from "./observability/metrics.js";
|
|
|
21
22
|
import { SnapshotRepository } from "./snapshots/repository.js";
|
|
22
23
|
/**
|
|
23
24
|
* Metadata root resolution (SPEC §39): explicit config path wins, otherwise
|
|
24
|
-
*
|
|
25
|
+
* `<DSH home>/cache/dsh-kv-persist`, where DSH home is `$DSH_HOME` when
|
|
26
|
+
* non-blank and `~/.dsh` otherwise.
|
|
25
27
|
*/
|
|
26
|
-
export function resolveMetadataDir(config) {
|
|
28
|
+
export function resolveMetadataDir(config, env = process.env) {
|
|
27
29
|
if (config.metadataPath !== null)
|
|
28
|
-
return config.metadataPath;
|
|
29
|
-
|
|
30
|
-
return join(dshHome.length > 0 ? dshHome : process.cwd(), "cache", "dsh-kv-persist");
|
|
30
|
+
return resolve(config.metadataPath);
|
|
31
|
+
return join(resolveDshHome(env), "cache", "dsh-kv-persist");
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
34
|
* Register a host event whose name lives in the host's session-service
|
|
@@ -200,16 +201,20 @@ export class KvPersistService extends Service {
|
|
|
200
201
|
* `next()` is invoked exactly once, after preparation, inside the slot
|
|
201
202
|
* lease; chunks pass through unchanged and unbuffered.
|
|
202
203
|
*/
|
|
203
|
-
|
|
204
|
+
handleStream(options, next) {
|
|
204
205
|
if (!this.handles(options.provider))
|
|
205
206
|
return next();
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
207
|
+
const coordinator = this.coordinator;
|
|
208
|
+
return (async function* () {
|
|
209
|
+
const stream = await coordinator.runSessionRequest({
|
|
210
|
+
sessionId: options.sessionId === undefined ? null : String(options.sessionId),
|
|
211
|
+
provider: options.provider,
|
|
212
|
+
model: options.model,
|
|
213
|
+
purpose: options.purpose,
|
|
214
|
+
next,
|
|
215
|
+
});
|
|
216
|
+
yield* stream;
|
|
217
|
+
})();
|
|
213
218
|
}
|
|
214
219
|
async checkMetadataWritable() {
|
|
215
220
|
const dir = resolveMetadataDir(this.config);
|
package/lib/service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAG/F,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAEvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,E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AE,CAAC,CAAC;QAChF,IAAI,CAAC;YACH,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YACtC,MAAM,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;YAC9C,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACrC,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,cAAc,EAAE,CAAC;QAC1E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,IAAI,EAAE,cAAc;gBACpB,EAAE,EAAE,KAAK;gBACT,MAAM,EAAE,GAAG,GAAG,qBAAqB,MAAM,CAAE,KAAe,EAAE,OAAO,IAAI,KAAK,CAAC,EAAE;aAChF,CAAC;QACJ,CAAC;IACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yadsh/dsh-kv-persist",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Persistent KV-cache/session-state manager for DeepSeek Harness (llama.cpp slot snapshots)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek",
|
|
@@ -68,14 +68,14 @@
|
|
|
68
68
|
"@yadsh/dsh-config": "^0.0.0"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"
|
|
71
|
+
"@yadsh/dsh-plugin-log": "^0.2.1"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"build": "tsc -p tsconfig.build.json",
|
|
75
|
-
"lint": "eslint src
|
|
75
|
+
"lint": "eslint src tests",
|
|
76
76
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
77
77
|
"test": "vitest run",
|
|
78
|
-
"test:llama": "vitest run
|
|
78
|
+
"test:llama": "vitest run tests/integration/llama-server.test.ts",
|
|
79
79
|
"verify:package": "node scripts/verify-package.mjs",
|
|
80
80
|
"verify": "npm run verify:package",
|
|
81
81
|
"check": "npm run typecheck && npm test && npm run build && npm run verify"
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DSH home resolution for plugin runtime helpers.
|
|
3
|
-
*
|
|
4
|
-
* Part of the future `@yadsh/dsh-plugin-log` package seed: this folder is a
|
|
5
|
-
* verbatim, self-contained copy in every adopting plugin (guidelines §5.2),
|
|
6
|
-
* so keep it free of imports outside `./`.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Resolve the DSH home directory: `$DSH_HOME` when set to a non-blank value,
|
|
10
|
-
* otherwise `~/.dsh` (the same convention as `dsh-draft-sessions` storage).
|
|
11
|
-
*/
|
|
12
|
-
export declare function resolveDshHome(env?: NodeJS.ProcessEnv): string;
|
|
13
|
-
//# sourceMappingURL=dsh-home.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dsh-home.d.ts","sourceRoot":"","sources":["../../src/logging/dsh-home.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAG3E"}
|
package/lib/logging/dsh-home.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DSH home resolution for plugin runtime helpers.
|
|
3
|
-
*
|
|
4
|
-
* Part of the future `@yadsh/dsh-plugin-log` package seed: this folder is a
|
|
5
|
-
* verbatim, self-contained copy in every adopting plugin (guidelines §5.2),
|
|
6
|
-
* so keep it free of imports outside `./`.
|
|
7
|
-
*/
|
|
8
|
-
import { homedir } from "node:os";
|
|
9
|
-
import { join, resolve } from "node:path";
|
|
10
|
-
/**
|
|
11
|
-
* Resolve the DSH home directory: `$DSH_HOME` when set to a non-blank value,
|
|
12
|
-
* otherwise `~/.dsh` (the same convention as `dsh-draft-sessions` storage).
|
|
13
|
-
*/
|
|
14
|
-
export function resolveDshHome(env = process.env) {
|
|
15
|
-
const configured = env.DSH_HOME?.trim();
|
|
16
|
-
return configured ? resolve(configured) : join(homedir(), ".dsh");
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=dsh-home.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dsh-home.js","sourceRoot":"","sources":["../../src/logging/dsh-home.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1C;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,MAAyB,OAAO,CAAC,GAAG;IACjE,MAAM,UAAU,GAAG,GAAG,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC;IACxC,OAAO,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;AACpE,CAAC"}
|
package/lib/logging/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plugin logging bundle (future `@yadsh/dsh-plugin-log`).
|
|
3
|
-
*
|
|
4
|
-
* Self-contained by design: every import stays inside this folder so the
|
|
5
|
-
* whole directory can be copied between plugins verbatim, or replaced by the
|
|
6
|
-
* extracted package import once it exists.
|
|
7
|
-
*/
|
|
8
|
-
export * from "./dsh-home.js";
|
|
9
|
-
export * from "./plugin-logger.js";
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logging/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC"}
|
package/lib/logging/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plugin logging bundle (future `@yadsh/dsh-plugin-log`).
|
|
3
|
-
*
|
|
4
|
-
* Self-contained by design: every import stays inside this folder so the
|
|
5
|
-
* whole directory can be copied between plugins verbatim, or replaced by the
|
|
6
|
-
* extracted package import once it exists.
|
|
7
|
-
*/
|
|
8
|
-
export * from "./dsh-home.js";
|
|
9
|
-
export * from "./plugin-logger.js";
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
package/lib/logging/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/logging/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC"}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plugin file logger — the seed of the future `@yadsh/dsh-plugin-log` package.
|
|
3
|
-
*
|
|
4
|
-
* Every plugin currently carries its own verbatim copy of `src/logging/`
|
|
5
|
-
* (guidelines §5.2); the exported API below is frozen so that switching to
|
|
6
|
-
* the extracted package later is a one-line import change. The wrapper:
|
|
7
|
-
*
|
|
8
|
-
* - wraps `pino` for severity levels and NDJSON serialization;
|
|
9
|
-
* - writes daily files `<dir>/<YYYY-MM-DD>.log`, by default under
|
|
10
|
-
* `<$DSH_HOME>/logs/<pluginId>`;
|
|
11
|
-
* - mirrors selected records to an injectable console sink (default level
|
|
12
|
-
* `warn`) so operators still see problems live;
|
|
13
|
-
* - never throws at runtime: file-system failures degrade to console-only
|
|
14
|
-
* logging (fail-open), and closed loggers silently drop records;
|
|
15
|
-
* - disables file output when `DSH_LOG_DISABLED=1`, and under `NODE_ENV=test`
|
|
16
|
-
* unless `dir` is set explicitly (unit tests never touch a real home).
|
|
17
|
-
*
|
|
18
|
-
* Record shape (one JSON object per line): pino's `level` (numeric),
|
|
19
|
-
* `time` (epoch ms) and `msg` (= the event code), plus `plugin` and the
|
|
20
|
-
* caller's fields; `child(module)` adds `module`. Reserved pino keys
|
|
21
|
-
* (`level`, `time`, `msg`, `plugin`, `module`) must not be used as field
|
|
22
|
-
* names.
|
|
23
|
-
*/
|
|
24
|
-
/** Ordered severity levels; `silent` disables the logger entirely. */
|
|
25
|
-
export declare const PLUGIN_LOG_LEVELS: readonly ["trace", "debug", "info", "warn", "error", "fatal", "silent"];
|
|
26
|
-
export type PluginLogLevel = (typeof PLUGIN_LOG_LEVELS)[number];
|
|
27
|
-
/** Every level except `silent` (which also disables the console mirror). */
|
|
28
|
-
export type ConsoleLevel = Exclude<PluginLogLevel, "silent">;
|
|
29
|
-
/**
|
|
30
|
-
* Receives console-mirrored records. Must not throw; the wrapper guards every
|
|
31
|
-
* call regardless.
|
|
32
|
-
*/
|
|
33
|
-
export type PluginConsoleSink = (level: ConsoleLevel, message: string) => void;
|
|
34
|
-
/** Default console mirror threshold. */
|
|
35
|
-
export declare const DEFAULT_CONSOLE_LEVEL: PluginLogLevel;
|
|
36
|
-
/** Daily log files kept per plugin by default (0 = keep forever). */
|
|
37
|
-
export declare const DEFAULT_LOG_RETENTION_DAYS = 14;
|
|
38
|
-
/** Type guard for level strings (config parsing, env overrides). */
|
|
39
|
-
export declare function isPluginLogLevel(value: unknown): value is PluginLogLevel;
|
|
40
|
-
/** Logger configuration; every field except `pluginId` is optional. */
|
|
41
|
-
export interface PluginLoggerOptions {
|
|
42
|
-
/**
|
|
43
|
-
* Plugin id: directory name, `plugin` record field and env-prefix source
|
|
44
|
-
* (`DSH_LOG_LEVEL_<ID>`). Must match `[A-Za-z0-9][A-Za-z0-9._-]*`.
|
|
45
|
-
*/
|
|
46
|
-
readonly pluginId: string;
|
|
47
|
-
/** Severity threshold. Default: `DSH_LOG_LEVEL_<ID>` / `DSH_LOG_LEVEL` env, else `info`. */
|
|
48
|
-
readonly level?: PluginLogLevel;
|
|
49
|
-
/** Absolute log directory. Default: `<$DSH_HOME>/logs/<pluginId>`. */
|
|
50
|
-
readonly dir?: string;
|
|
51
|
-
/** Overrides the DSH home used to build the default `dir` (tests). */
|
|
52
|
-
readonly dshHome?: string;
|
|
53
|
-
/** Console mirror threshold; `silent` disables mirroring. Default: `warn`. */
|
|
54
|
-
readonly console?: PluginLogLevel;
|
|
55
|
-
/** Mirror target. Default: the global `console`. */
|
|
56
|
-
readonly consoleSink?: PluginConsoleSink;
|
|
57
|
-
/** Daily files older than this are deleted on rollover. Default: 14; 0 disables. */
|
|
58
|
-
readonly retentionDays?: number;
|
|
59
|
-
/** Master switch for file output. Default: auto (see the module docs). */
|
|
60
|
-
readonly file?: boolean;
|
|
61
|
-
/** Record fields to redact (pino `redact` paths), e.g. `["apiKey"]`. */
|
|
62
|
-
readonly redact?: readonly string[];
|
|
63
|
-
/** Clock for file naming, rollover and retention (tests). */
|
|
64
|
-
readonly now?: () => number;
|
|
65
|
-
}
|
|
66
|
-
/** Stable logging surface shared by every plugin (future package contract). */
|
|
67
|
-
export interface PluginLogger {
|
|
68
|
-
trace(event: string, fields?: Record<string, unknown>): void;
|
|
69
|
-
debug(event: string, fields?: Record<string, unknown>): void;
|
|
70
|
-
info(event: string, fields?: Record<string, unknown>): void;
|
|
71
|
-
warn(event: string, fields?: Record<string, unknown>): void;
|
|
72
|
-
error(event: string, fields?: Record<string, unknown>): void;
|
|
73
|
-
fatal(event: string, fields?: Record<string, unknown>): void;
|
|
74
|
-
/** Bound sub-logger that adds a `module` field to every record. */
|
|
75
|
-
child(module: string): PluginLogger;
|
|
76
|
-
/** Current severity threshold. */
|
|
77
|
-
get level(): PluginLogLevel;
|
|
78
|
-
/** Change the severity threshold at runtime. */
|
|
79
|
-
setLevel(level: PluginLogLevel): void;
|
|
80
|
-
/** Best-effort synchronous flush of buffered file output. */
|
|
81
|
-
flush(): void;
|
|
82
|
-
/** Flush and close the destination; idempotent; later writes are dropped. */
|
|
83
|
-
close(): Promise<void>;
|
|
84
|
-
}
|
|
85
|
-
/** Create a standalone logger instance (no caching). */
|
|
86
|
-
export declare function createPluginLogger(options: PluginLoggerOptions): PluginLogger;
|
|
87
|
-
/**
|
|
88
|
-
* Create or return the cached logger for `pluginId` + resolved `dir`. A later
|
|
89
|
-
* call with an explicit `level` updates the cached instance's threshold, so
|
|
90
|
-
* plugin config reloads take effect. `close()` evicts the cache entry; the
|
|
91
|
-
* next call creates a fresh instance.
|
|
92
|
-
*/
|
|
93
|
-
export declare function getPluginLogger(options: PluginLoggerOptions): PluginLogger;
|
|
94
|
-
//# sourceMappingURL=plugin-logger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-logger.d.ts","sourceRoot":"","sources":["../../src/logging/plugin-logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAUH,sEAAsE;AACtE,eAAO,MAAM,iBAAiB,yEAQpB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,4EAA4E;AAC5E,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;AAE7D;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;AAE/E,wCAAwC;AACxC,eAAO,MAAM,qBAAqB,EAAE,cAAuB,CAAC;AAE5D,qEAAqE;AACrE,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAmB7C,oEAAoE;AACpE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAExE;AAED,uEAAuE;AACvE,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,4FAA4F;IAC5F,QAAQ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