mcp4openapi 0.3.1 → 0.3.4

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 (160) hide show
  1. package/README.md +7 -0
  2. package/dist/src/auth/oauth-provider.d.ts +1 -0
  3. package/dist/src/auth/oauth-provider.d.ts.map +1 -1
  4. package/dist/src/auth/oauth-provider.js +17 -0
  5. package/dist/src/auth/oauth-provider.js.map +1 -1
  6. package/dist/src/core/cli-config.d.ts.map +1 -1
  7. package/dist/src/core/cli-config.js +2 -0
  8. package/dist/src/core/cli-config.js.map +1 -1
  9. package/dist/src/core/index.d.ts.map +1 -1
  10. package/dist/src/core/index.js +18 -3
  11. package/dist/src/core/index.js.map +1 -1
  12. package/dist/src/index.js +0 -0
  13. package/dist/src/profile/profile-allowlist.d.ts +18 -0
  14. package/dist/src/profile/profile-allowlist.d.ts.map +1 -0
  15. package/dist/src/profile/profile-allowlist.js +68 -0
  16. package/dist/src/profile/profile-allowlist.js.map +1 -0
  17. package/dist/src/profile/profile-registry.d.ts +5 -0
  18. package/dist/src/profile/profile-registry.d.ts.map +1 -1
  19. package/dist/src/profile/profile-registry.js +38 -14
  20. package/dist/src/profile/profile-registry.js.map +1 -1
  21. package/dist/src/security/ssrf-validator.d.ts +31 -0
  22. package/dist/src/security/ssrf-validator.d.ts.map +1 -0
  23. package/dist/src/security/ssrf-validator.js +190 -0
  24. package/dist/src/security/ssrf-validator.js.map +1 -0
  25. package/package.json +2 -2
  26. package/profiles/gitlab/developer-profile-oauth.json +445 -81
  27. package/profiles/gitlab/developer-profile-oauth.test.json +1037 -12
  28. package/profiles/gitlab/openapi.yaml +1420 -165
  29. package/profiles/gitlab/profile-optimized-oauth.json +928 -0
  30. package/profiles/gitlab/profile-optimized-oauth.test.json +1606 -0
  31. package/profiles/grafana/openapi.json +28078 -0
  32. package/profiles/grafana/profile.json +1083 -0
  33. package/profiles/grafana/profile.test.json +235 -0
  34. package/profiles/mattermost/openapi.yaml +27434 -0
  35. package/profiles/mattermost/profile.json +463 -0
  36. package/profiles/mattermost/profile.test.json +607 -0
  37. package/profiles/n8n/profile-optimized.json +1002 -364
  38. package/profiles/n8n/profile-optimized.test.json +43 -43
  39. package/dist/src/argument-normalizer.d.ts +0 -5
  40. package/dist/src/argument-normalizer.d.ts.map +0 -1
  41. package/dist/src/argument-normalizer.js +0 -61
  42. package/dist/src/argument-normalizer.js.map +0 -1
  43. package/dist/src/cli-config.d.ts +0 -9
  44. package/dist/src/cli-config.d.ts.map +0 -1
  45. package/dist/src/cli-config.js +0 -111
  46. package/dist/src/cli-config.js.map +0 -1
  47. package/dist/src/composite-executor.d.ts +0 -77
  48. package/dist/src/composite-executor.d.ts.map +0 -1
  49. package/dist/src/composite-executor.js +0 -193
  50. package/dist/src/composite-executor.js.map +0 -1
  51. package/dist/src/constants.d.ts +0 -85
  52. package/dist/src/constants.d.ts.map +0 -1
  53. package/dist/src/constants.js +0 -85
  54. package/dist/src/constants.js.map +0 -1
  55. package/dist/src/dag-executor.d.ts +0 -49
  56. package/dist/src/dag-executor.d.ts.map +0 -1
  57. package/dist/src/dag-executor.js +0 -138
  58. package/dist/src/dag-executor.js.map +0 -1
  59. package/dist/src/errors.d.ts +0 -59
  60. package/dist/src/errors.d.ts.map +0 -1
  61. package/dist/src/errors.js +0 -119
  62. package/dist/src/errors.js.map +0 -1
  63. package/dist/src/filtering.d.ts +0 -19
  64. package/dist/src/filtering.d.ts.map +0 -1
  65. package/dist/src/filtering.js +0 -292
  66. package/dist/src/filtering.js.map +0 -1
  67. package/dist/src/http-client-factory.d.ts +0 -62
  68. package/dist/src/http-client-factory.d.ts.map +0 -1
  69. package/dist/src/http-client-factory.js +0 -133
  70. package/dist/src/http-client-factory.js.map +0 -1
  71. package/dist/src/http-transport-config.d.ts +0 -6
  72. package/dist/src/http-transport-config.d.ts.map +0 -1
  73. package/dist/src/http-transport-config.js +0 -47
  74. package/dist/src/http-transport-config.js.map +0 -1
  75. package/dist/src/http-transport.d.ts +0 -316
  76. package/dist/src/http-transport.d.ts.map +0 -1
  77. package/dist/src/http-transport.js +0 -2412
  78. package/dist/src/http-transport.js.map +0 -1
  79. package/dist/src/interceptors.d.ts +0 -116
  80. package/dist/src/interceptors.d.ts.map +0 -1
  81. package/dist/src/interceptors.js +0 -392
  82. package/dist/src/interceptors.js.map +0 -1
  83. package/dist/src/jsonrpc-validator.d.ts +0 -27
  84. package/dist/src/jsonrpc-validator.d.ts.map +0 -1
  85. package/dist/src/jsonrpc-validator.js +0 -58
  86. package/dist/src/jsonrpc-validator.js.map +0 -1
  87. package/dist/src/logger.d.ts +0 -59
  88. package/dist/src/logger.d.ts.map +0 -1
  89. package/dist/src/logger.js +0 -177
  90. package/dist/src/logger.js.map +0 -1
  91. package/dist/src/mcp-server-manager.d.ts +0 -20
  92. package/dist/src/mcp-server-manager.d.ts.map +0 -1
  93. package/dist/src/mcp-server-manager.js +0 -38
  94. package/dist/src/mcp-server-manager.js.map +0 -1
  95. package/dist/src/mcp-server.d.ts +0 -203
  96. package/dist/src/mcp-server.d.ts.map +0 -1
  97. package/dist/src/mcp-server.js +0 -1369
  98. package/dist/src/mcp-server.js.map +0 -1
  99. package/dist/src/metrics.d.ts +0 -97
  100. package/dist/src/metrics.d.ts.map +0 -1
  101. package/dist/src/metrics.js +0 -273
  102. package/dist/src/metrics.js.map +0 -1
  103. package/dist/src/naming-warnings.d.ts +0 -23
  104. package/dist/src/naming-warnings.d.ts.map +0 -1
  105. package/dist/src/naming-warnings.js +0 -83
  106. package/dist/src/naming-warnings.js.map +0 -1
  107. package/dist/src/naming.d.ts +0 -58
  108. package/dist/src/naming.d.ts.map +0 -1
  109. package/dist/src/naming.js +0 -510
  110. package/dist/src/naming.js.map +0 -1
  111. package/dist/src/oauth-provider.d.ts +0 -131
  112. package/dist/src/oauth-provider.d.ts.map +0 -1
  113. package/dist/src/oauth-provider.js +0 -836
  114. package/dist/src/oauth-provider.js.map +0 -1
  115. package/dist/src/openapi-parser.d.ts +0 -70
  116. package/dist/src/openapi-parser.d.ts.map +0 -1
  117. package/dist/src/openapi-parser.js +0 -436
  118. package/dist/src/openapi-parser.js.map +0 -1
  119. package/dist/src/profile-loader.d.ts +0 -78
  120. package/dist/src/profile-loader.d.ts.map +0 -1
  121. package/dist/src/profile-loader.js +0 -483
  122. package/dist/src/profile-loader.js.map +0 -1
  123. package/dist/src/profile-registry.d.ts +0 -18
  124. package/dist/src/profile-registry.d.ts.map +0 -1
  125. package/dist/src/profile-registry.js +0 -26
  126. package/dist/src/profile-registry.js.map +0 -1
  127. package/dist/src/profile-resolver.d.ts +0 -19
  128. package/dist/src/profile-resolver.d.ts.map +0 -1
  129. package/dist/src/profile-resolver.js +0 -167
  130. package/dist/src/profile-resolver.js.map +0 -1
  131. package/dist/src/proxy-executor.d.ts +0 -86
  132. package/dist/src/proxy-executor.d.ts.map +0 -1
  133. package/dist/src/proxy-executor.js +0 -497
  134. package/dist/src/proxy-executor.js.map +0 -1
  135. package/dist/src/schema-validator.d.ts +0 -30
  136. package/dist/src/schema-validator.d.ts.map +0 -1
  137. package/dist/src/schema-validator.js +0 -128
  138. package/dist/src/schema-validator.js.map +0 -1
  139. package/dist/src/startup-profile.d.ts +0 -17
  140. package/dist/src/startup-profile.d.ts.map +0 -1
  141. package/dist/src/startup-profile.js +0 -30
  142. package/dist/src/startup-profile.js.map +0 -1
  143. package/dist/src/startup-validation.d.ts +0 -11
  144. package/dist/src/startup-validation.d.ts.map +0 -1
  145. package/dist/src/startup-validation.js +0 -21
  146. package/dist/src/startup-validation.js.map +0 -1
  147. package/dist/src/tool-filter.d.ts +0 -65
  148. package/dist/src/tool-filter.d.ts.map +0 -1
  149. package/dist/src/tool-filter.js +0 -471
  150. package/dist/src/tool-filter.js.map +0 -1
  151. package/dist/src/tool-generator.d.ts +0 -67
  152. package/dist/src/tool-generator.d.ts.map +0 -1
  153. package/dist/src/tool-generator.js +0 -182
  154. package/dist/src/tool-generator.js.map +0 -1
  155. package/dist/src/validation-utils.d.ts +0 -49
  156. package/dist/src/validation-utils.d.ts.map +0 -1
  157. package/dist/src/validation-utils.js +0 -138
  158. package/dist/src/validation-utils.js.map +0 -1
  159. package/profiles/gitlab/developer-profile.json +0 -1508
  160. package/profiles/gitlab/developer-profile.test.json +0 -3432
@@ -1,19 +0,0 @@
1
- /**
2
- * Profile resolver
3
- *
4
- * Why: Allow selecting profiles by ID or alias without hardcoding paths.
5
- */
6
- export interface ResolvedProfile {
7
- profileId: string;
8
- profileName: string;
9
- profileAliases?: string[];
10
- profilePath: string;
11
- specPath: string;
12
- }
13
- export declare function resolveProfileById(profileId: string, profilesDir?: string, options?: {
14
- specPathOverride?: string;
15
- }): Promise<ResolvedProfile>;
16
- export declare function resolveProfileFromPath(profilePath: string, options?: {
17
- specPathOverride?: string;
18
- }): Promise<ResolvedProfile>;
19
- //# sourceMappingURL=profile-resolver.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"profile-resolver.d.ts","sourceRoot":"","sources":["../../src/profile-resolver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAuID,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,MAAM,EACjB,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE;IAAE,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAE,GACtC,OAAO,CAAC,eAAe,CAAC,CA0B1B;AAED,wBAAsB,sBAAsB,CAC1C,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;IAAE,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAE,GACtC,OAAO,CAAC,eAAe,CAAC,CAiB1B"}
@@ -1,167 +0,0 @@
1
- /**
2
- * Profile resolver
3
- *
4
- * Why: Allow selecting profiles by ID or alias without hardcoding paths.
5
- */
6
- import fs from 'node:fs/promises';
7
- import path from 'node:path';
8
- import { ConfigurationError } from './errors.js';
9
- const DEFAULT_PROFILES_DIR = 'profiles';
10
- function normalizeProfilesDir(profilesDir) {
11
- const base = profilesDir && profilesDir.trim().length > 0 ? profilesDir : DEFAULT_PROFILES_DIR;
12
- return path.isAbsolute(base) ? base : path.resolve(process.cwd(), base);
13
- }
14
- function isProfileJson(data) {
15
- if (!data || typeof data !== 'object')
16
- return false;
17
- const obj = data;
18
- return typeof obj.profile_name === 'string' && Array.isArray(obj.tools);
19
- }
20
- function isHttpUrl(value) {
21
- try {
22
- const url = new URL(value);
23
- return url.protocol === 'http:' || url.protocol === 'https:';
24
- }
25
- catch {
26
- return false;
27
- }
28
- }
29
- function normalizeSpecPath(value) {
30
- if (typeof value !== 'string')
31
- return undefined;
32
- const trimmed = value.trim();
33
- return trimmed.length > 0 ? trimmed : undefined;
34
- }
35
- function resolveSpecPath(profilePath, specPathRaw, overrideSpecPath) {
36
- const trimmed = normalizeSpecPath(specPathRaw);
37
- if (!trimmed) {
38
- const override = normalizeSpecPath(overrideSpecPath);
39
- if (override) {
40
- return override;
41
- }
42
- throw new ConfigurationError('Profile is missing openapi_spec_path', { profilePath });
43
- }
44
- if (isHttpUrl(trimmed)) {
45
- return trimmed;
46
- }
47
- return path.isAbsolute(trimmed) ? trimmed : path.resolve(path.dirname(profilePath), trimmed);
48
- }
49
- async function loadProfileIndexEntry(profilePath) {
50
- const raw = await fs.readFile(profilePath, 'utf-8');
51
- let parsed;
52
- try {
53
- parsed = JSON.parse(raw);
54
- }
55
- catch (error) {
56
- throw new ConfigurationError('Failed to parse profile JSON', {
57
- profilePath,
58
- error: String(error),
59
- });
60
- }
61
- if (!isProfileJson(parsed)) {
62
- return null;
63
- }
64
- const profile = parsed;
65
- const profileName = profile.profile_name;
66
- const profileId = typeof profile.profile_id === 'string' && profile.profile_id.trim().length > 0
67
- ? profile.profile_id
68
- : profileName;
69
- const aliases = Array.isArray(profile.profile_aliases)
70
- ? profile.profile_aliases.filter((alias) => typeof alias === 'string')
71
- : [];
72
- return {
73
- profileId,
74
- profileName,
75
- aliases,
76
- profilePath,
77
- specPathRaw: typeof profile.openapi_spec_path === 'string' ? profile.openapi_spec_path : undefined,
78
- };
79
- }
80
- async function collectProfileFiles(dir) {
81
- const entries = await fs.readdir(dir, { withFileTypes: true });
82
- const files = [];
83
- for (const entry of entries) {
84
- if (entry.name.startsWith('.'))
85
- continue;
86
- const fullPath = path.join(dir, entry.name);
87
- if (entry.isDirectory()) {
88
- files.push(...await collectProfileFiles(fullPath));
89
- continue;
90
- }
91
- if (!entry.isFile())
92
- continue;
93
- if (!entry.name.endsWith('.json'))
94
- continue;
95
- if (entry.name.endsWith('.test.json'))
96
- continue;
97
- files.push(fullPath);
98
- }
99
- return files;
100
- }
101
- async function buildProfileIndex(profilesDir) {
102
- let entries;
103
- try {
104
- entries = await collectProfileFiles(profilesDir);
105
- }
106
- catch (error) {
107
- throw new ConfigurationError('Profiles directory not found', {
108
- profilesDir,
109
- error: String(error),
110
- });
111
- }
112
- const profiles = [];
113
- for (const filePath of entries) {
114
- const entry = await loadProfileIndexEntry(filePath);
115
- if (entry)
116
- profiles.push(entry);
117
- }
118
- return profiles;
119
- }
120
- function matchProfiles(profileId, profiles) {
121
- return profiles.filter(profile => {
122
- if (profile.profileId === profileId)
123
- return true;
124
- if (profile.profileName === profileId)
125
- return true;
126
- return profile.aliases.includes(profileId);
127
- });
128
- }
129
- export async function resolveProfileById(profileId, profilesDir, options) {
130
- const resolvedDir = normalizeProfilesDir(profilesDir);
131
- const profiles = await buildProfileIndex(resolvedDir);
132
- const matches = matchProfiles(profileId, profiles);
133
- if (matches.length === 0) {
134
- throw new ConfigurationError('Profile not found', { profileId, profilesDir: resolvedDir });
135
- }
136
- if (matches.length > 1) {
137
- throw new ConfigurationError('Profile ID or alias is not unique', {
138
- profileId,
139
- matches: matches.map(m => ({ profileName: m.profileName, profilePath: m.profilePath })),
140
- });
141
- }
142
- const match = matches[0];
143
- const specPath = resolveSpecPath(match.profilePath, match.specPathRaw, options?.specPathOverride);
144
- return {
145
- profileId: match.profileId,
146
- profileName: match.profileName,
147
- profileAliases: match.aliases,
148
- profilePath: match.profilePath,
149
- specPath,
150
- };
151
- }
152
- export async function resolveProfileFromPath(profilePath, options) {
153
- const resolvedPath = path.isAbsolute(profilePath) ? profilePath : path.resolve(process.cwd(), profilePath);
154
- const entry = await loadProfileIndexEntry(resolvedPath);
155
- if (!entry) {
156
- throw new ConfigurationError('Profile file does not look like a valid profile', { profilePath: resolvedPath });
157
- }
158
- const specPath = resolveSpecPath(resolvedPath, entry.specPathRaw, options?.specPathOverride);
159
- return {
160
- profileId: entry.profileId,
161
- profileName: entry.profileName,
162
- profileAliases: entry.aliases,
163
- profilePath: resolvedPath,
164
- specPath,
165
- };
166
- }
167
- //# sourceMappingURL=profile-resolver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"profile-resolver.js","sourceRoot":"","sources":["../../src/profile-resolver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAkBjD,MAAM,oBAAoB,GAAG,UAAU,CAAC;AAExC,SAAS,oBAAoB,CAAC,WAAoB;IAChD,MAAM,IAAI,GAAG,WAAW,IAAI,WAAW,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,oBAAoB,CAAC;IAC/F,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;AAC1E,CAA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AC7B,WAAW,EAAE,YAAY;QACzB,QAAQ;KACT,CAAC;AACJ,CAAC"}
@@ -1,86 +0,0 @@
1
- /**
2
- * Proxy download executor for fetching binary content through API
3
- *
4
- * Why: LLM needs file content but URLs require authentication.
5
- * This executor fetches metadata, extracts URL, downloads content,
6
- * and returns base64-encoded result.
7
- */
8
- import type { ProxyDownloadOperation } from './types/profile.js';
9
- import type { ResponseContext, AuthCredentials } from './interceptors.js';
10
- export interface DebugLogger {
11
- debug(message: string, context?: Record<string, unknown>): void;
12
- warn?(message: string, context?: Record<string, unknown>): void;
13
- }
14
- export interface HttpClient {
15
- request(method: string, url: string, options?: {
16
- headers?: Record<string, string>;
17
- body?: unknown;
18
- }): Promise<ResponseContext>;
19
- getBaseUrl(): string;
20
- }
21
- export interface ProxyDownloadResult {
22
- /** Original metadata from API */
23
- metadata: Record<string, unknown>;
24
- /** Base64-encoded file content */
25
- content: string;
26
- /** MIME type of the file */
27
- mimeType: string;
28
- /** File size in bytes */
29
- size: number;
30
- /** Original filename if available */
31
- fileName?: string;
32
- }
33
- export declare class ProxyDownloadExecutor {
34
- private httpClient;
35
- private logger;
36
- constructor(httpClient: HttpClient, logger?: DebugLogger);
37
- /**
38
- * Execute proxy download operation
39
- *
40
- * @param operation Proxy download configuration
41
- * @param path API path with substituted parameters
42
- * @param authCredentials Auth credentials (headers + query params) for download
43
- */
44
- execute(operation: ProxyDownloadOperation, metadataRequest: {
45
- path: string;
46
- method: string;
47
- }, authCredentials: AuthCredentials, directDownloadRequest?: {
48
- path: string;
49
- method: string;
50
- }): Promise<ProxyDownloadResult>;
51
- private resolveMaxSize;
52
- /**
53
- * Extract URL from metadata using dot-notation path
54
- */
55
- private extractUrl;
56
- private extractNestedString;
57
- private extractNestedNumber;
58
- private extractNestedValue;
59
- private getBaseOrigin;
60
- private resolveHttpUrl;
61
- private enforceDownloadPolicy;
62
- /**
63
- * Check if MIME type matches whitelist (supports wildcards like 'image/*')
64
- */
65
- private isMimeTypeAllowed;
66
- /**
67
- * Download binary content and return base64
68
- *
69
- * @param skipAuth If true, download URL is fetched without authentication headers/params
70
- * Metadata endpoint still requires auth, only the final download is unauthenticated
71
- */
72
- private downloadWithAuth;
73
- private buildDownloadUrlWithOptionalQueryAuth;
74
- private isRedirectStatus;
75
- private resolveRedirectTarget;
76
- private enforceAllowedDownloadTarget;
77
- private lookupAllIpAddresses;
78
- private isAllowedHost;
79
- private isDisallowedIPv4;
80
- private isDisallowedIPv6;
81
- /**
82
- * Handle inline data URLs (data:mime;base64,...)
83
- */
84
- private downloadFromDataUrl;
85
- }
86
- //# sourceMappingURL=proxy-executor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"proxy-executor.d.ts","sourceRoot":"","sources":["../../src/proxy-executor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAM1E,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAChE,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACjE;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,CACL,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjC,IAAI,CAAC,EAAE,OAAO,CAAC;KAChB,GACA,OAAO,CAAC,eAAe,CAAC,CAAC;IAC5B,UAAU,IAAI,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,mBAAmB;IAClC,iCAAiC;IACjC,QA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