@kadi.build/core 0.0.1-alpha.13 → 0.0.1-alpha.15

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 (51) hide show
  1. package/dist/abilities/AbilityLoader.d.ts +136 -12
  2. package/dist/abilities/AbilityLoader.d.ts.map +1 -1
  3. package/dist/abilities/AbilityLoader.js +432 -64
  4. package/dist/abilities/AbilityLoader.js.map +1 -1
  5. package/dist/abilities/types.d.ts +119 -4
  6. package/dist/abilities/types.d.ts.map +1 -1
  7. package/dist/broker/BrokerConnectionManager.d.ts +12 -32
  8. package/dist/broker/BrokerConnectionManager.d.ts.map +1 -1
  9. package/dist/broker/BrokerConnectionManager.js +12 -40
  10. package/dist/broker/BrokerConnectionManager.js.map +1 -1
  11. package/dist/client/KadiClient.d.ts +6 -8
  12. package/dist/client/KadiClient.d.ts.map +1 -1
  13. package/dist/client/KadiClient.js +143 -89
  14. package/dist/client/KadiClient.js.map +1 -1
  15. package/dist/config/ConfigLoader.d.ts.map +1 -1
  16. package/dist/config/ConfigLoader.js +1 -0
  17. package/dist/config/ConfigLoader.js.map +1 -1
  18. package/dist/config/ConfigResolver.d.ts +7 -14
  19. package/dist/config/ConfigResolver.d.ts.map +1 -1
  20. package/dist/config/ConfigResolver.js +23 -42
  21. package/dist/config/ConfigResolver.js.map +1 -1
  22. package/dist/index.d.ts +2 -2
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +2 -2
  25. package/dist/index.js.map +1 -1
  26. package/dist/transports/NativeTransport.d.ts.map +1 -1
  27. package/dist/transports/NativeTransport.js +22 -0
  28. package/dist/transports/NativeTransport.js.map +1 -1
  29. package/dist/transports/StdioTransport.d.ts +17 -2
  30. package/dist/transports/StdioTransport.d.ts.map +1 -1
  31. package/dist/transports/StdioTransport.js +45 -10
  32. package/dist/transports/StdioTransport.js.map +1 -1
  33. package/dist/types/config.d.ts +90 -51
  34. package/dist/types/config.d.ts.map +1 -1
  35. package/dist/types/config.js.map +1 -1
  36. package/dist/types/index.d.ts +1 -1
  37. package/dist/types/index.d.ts.map +1 -1
  38. package/dist/types/index.js.map +1 -1
  39. package/dist/utils/LockfileResolver.d.ts +169 -28
  40. package/dist/utils/LockfileResolver.d.ts.map +1 -1
  41. package/dist/utils/LockfileResolver.js +325 -71
  42. package/dist/utils/LockfileResolver.js.map +1 -1
  43. package/dist/utils/legacyHelpers.d.ts +82 -0
  44. package/dist/utils/legacyHelpers.d.ts.map +1 -0
  45. package/dist/utils/legacyHelpers.js +226 -0
  46. package/dist/utils/legacyHelpers.js.map +1 -0
  47. package/package.json +1 -1
  48. package/dist/api/index.d.ts +0 -92
  49. package/dist/api/index.d.ts.map +0 -1
  50. package/dist/api/index.js +0 -124
  51. package/dist/api/index.js.map +0 -1
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Legacy Helper Functions from kadi-core alpha.2
3
+ *
4
+ * TODO: These functions are temporary and will be replaced by the config.json
5
+ * approach described in CLI-REVAMP-PLAN.md
6
+ *
7
+ * The new architecture will use:
8
+ * - ~/.kadi/config.json for configuration
9
+ * - Environment variables: KADI_HOME, KADI_CONFIG, KADI_BROKER_URL
10
+ * - Simple discovery functions implemented in CLI itself
11
+ *
12
+ * These functions are copied here ONLY to unblock development and testing.
13
+ * DO NOT rely on these for new features - they will be removed.
14
+ *
15
+ * @deprecated Will be removed once config.json approach is implemented
16
+ */
17
+ import path from 'path';
18
+ import fs from 'fs';
19
+ import { execSync } from 'child_process';
20
+ import { fileURLToPath } from 'url';
21
+ // Cache the resolved paths
22
+ let kadiRootDir = null;
23
+ let kadiBrokers = {};
24
+ let defaultBrokerName = null;
25
+ let activeBrokerName = null;
26
+ /**
27
+ * Resolve KADI CLI installation path
28
+ *
29
+ * TODO: Replace with config.json approach where CLI path is stored in
30
+ * ~/.kadi/config.json and accessible via KADI_HOME environment variable
31
+ *
32
+ * @deprecated Use config.json approach instead
33
+ * @returns The KADI CLI installation directory
34
+ */
35
+ function resolveKadiInstallPath() {
36
+ // Use cached value if available
37
+ if (kadiRootDir) {
38
+ return kadiRootDir;
39
+ }
40
+ /* Strategy 1: Use import.meta.resolve for @kadi.build/cli */
41
+ try {
42
+ // @ts-ignore - import.meta.resolve may not be available in all environments
43
+ if (typeof import.meta.resolve === 'function') {
44
+ // @ts-ignore
45
+ const resolved = import.meta.resolve('@kadi.build/cli/package.json');
46
+ if (resolved) {
47
+ const url = new URL(resolved);
48
+ kadiRootDir = path.dirname(fileURLToPath(url));
49
+ return kadiRootDir;
50
+ }
51
+ }
52
+ }
53
+ catch {
54
+ // Fall through to next strategy
55
+ }
56
+ /* Strategy 2: Follow the kadi executable (legacy) */
57
+ try {
58
+ const cmd = process.platform === 'win32' ? 'where kadi' : 'which kadi';
59
+ const kadiBinaryPath = execSync(cmd, { encoding: 'utf8' }).trim();
60
+ if (!kadiBinaryPath) {
61
+ throw new Error('Kadi CLI tool not found in the system PATH');
62
+ }
63
+ // Resolve symlinks to get the real path
64
+ const realKadiBinaryPath = fs.realpathSync(kadiBinaryPath);
65
+ let kadiDir = path.dirname(realKadiBinaryPath);
66
+ // Look for package.json to confirm this is the CLI
67
+ const kadiPackageJsonPath = path.join(kadiDir, 'package.json');
68
+ if (fs.existsSync(kadiPackageJsonPath)) {
69
+ const kadiPackageJson = JSON.parse(fs.readFileSync(kadiPackageJsonPath, 'utf8'));
70
+ if (kadiPackageJson.name === '@kadi.build/cli' ||
71
+ (kadiPackageJson.bin && kadiPackageJson.bin.kadi)) {
72
+ kadiRootDir = kadiDir;
73
+ return kadiRootDir;
74
+ }
75
+ }
76
+ // If not found in immediate directory, check parent (for bin/ structure)
77
+ const parentDir = path.dirname(kadiDir);
78
+ const parentPackageJsonPath = path.join(parentDir, 'package.json');
79
+ if (fs.existsSync(parentPackageJsonPath)) {
80
+ const parentPackageJson = JSON.parse(fs.readFileSync(parentPackageJsonPath, 'utf8'));
81
+ if (parentPackageJson.name === '@kadi.build/cli' ||
82
+ (parentPackageJson.bin && parentPackageJson.bin.kadi)) {
83
+ kadiRootDir = parentDir;
84
+ return kadiRootDir;
85
+ }
86
+ }
87
+ throw new Error('@kadi.build/cli package.json not found in the resolved path');
88
+ }
89
+ catch {
90
+ // Fall through to error
91
+ }
92
+ /* Strategy 3: Give up */
93
+ throw new Error('Could not locate @kadi.build/cli installation. ' +
94
+ 'Make sure the CLI is installed (`npm i -g @kadi.build/cli`) ' +
95
+ 'or run commands from inside the CLI repository during development.\n' +
96
+ 'TODO: This will be replaced with config.json approach from CLI-REVAMP-PLAN.md');
97
+ }
98
+ /**
99
+ * Load broker configuration from KADI's agent.json
100
+ *
101
+ * TODO: Replace with config.json approach where brokers are stored in
102
+ * ~/.kadi/config.json
103
+ *
104
+ * @deprecated Use config.json approach instead
105
+ */
106
+ function loadBrokerConfig() {
107
+ if (Object.keys(kadiBrokers).length > 0) {
108
+ return; // Already loaded
109
+ }
110
+ try {
111
+ const kadiRoot = resolveKadiInstallPath();
112
+ const agentJsonPath = path.join(kadiRoot, 'agent.json');
113
+ if (fs.existsSync(agentJsonPath)) {
114
+ const agentJson = JSON.parse(fs.readFileSync(agentJsonPath, 'utf8'));
115
+ if (agentJson.brokers && typeof agentJson.brokers === 'object') {
116
+ for (const [name, url] of Object.entries(agentJson.brokers)) {
117
+ const brokerUrl = new URL(url);
118
+ kadiBrokers[name] =
119
+ `${brokerUrl.hostname}:${brokerUrl.port}${brokerUrl.pathname}`;
120
+ }
121
+ // Set default broker (first one defined)
122
+ const brokerNames = Object.keys(kadiBrokers);
123
+ if (brokerNames.length > 0) {
124
+ defaultBrokerName = brokerNames[0] ?? null;
125
+ activeBrokerName = defaultBrokerName;
126
+ }
127
+ }
128
+ }
129
+ }
130
+ catch (error) {
131
+ // Silently fail - brokers may not be configured
132
+ }
133
+ }
134
+ /**
135
+ * Get KADI CLI installation path
136
+ *
137
+ * TODO: Replace with KADI_HOME environment variable or ~/.kadi/config.json
138
+ *
139
+ * @deprecated Use config.json approach instead
140
+ * @returns The KADI CLI installation directory
141
+ */
142
+ export function getKadiInstallPath() {
143
+ if (!kadiRootDir) {
144
+ kadiRootDir = resolveKadiInstallPath();
145
+ }
146
+ return kadiRootDir;
147
+ }
148
+ /**
149
+ * Get broker URL by name
150
+ *
151
+ * TODO: Replace with ~/.kadi/config.json brokers section
152
+ *
153
+ * @deprecated Use config.json approach instead
154
+ * @param brokerName - Name of the broker
155
+ * @returns Broker URL or null if not found
156
+ */
157
+ export function getBrokerUrl(brokerName) {
158
+ loadBrokerConfig();
159
+ return kadiBrokers[brokerName] || null;
160
+ }
161
+ /**
162
+ * Get all broker names
163
+ *
164
+ * TODO: Replace with ~/.kadi/config.json brokers section
165
+ *
166
+ * @deprecated Use config.json approach instead
167
+ * @returns Array of broker names
168
+ */
169
+ export function getBrokerNames() {
170
+ loadBrokerConfig();
171
+ return Object.keys(kadiBrokers);
172
+ }
173
+ /**
174
+ * Get default broker name
175
+ *
176
+ * TODO: Replace with ~/.kadi/config.json default broker setting
177
+ *
178
+ * @deprecated Use config.json approach instead
179
+ * @returns Default broker name or null
180
+ */
181
+ export function getDefaultBrokerName() {
182
+ loadBrokerConfig();
183
+ return defaultBrokerName;
184
+ }
185
+ /**
186
+ * Set active broker
187
+ *
188
+ * TODO: Replace with ~/.kadi/config.json active broker setting
189
+ *
190
+ * @deprecated Use config.json approach instead
191
+ * @param brokerName - Name of the broker to set as active
192
+ * @returns True if broker exists and was set, false otherwise
193
+ */
194
+ export function setActiveBroker(brokerName) {
195
+ loadBrokerConfig();
196
+ if (kadiBrokers[brokerName]) {
197
+ activeBrokerName = brokerName;
198
+ return true;
199
+ }
200
+ return false;
201
+ }
202
+ /**
203
+ * Get active broker name
204
+ *
205
+ * TODO: Replace with ~/.kadi/config.json active broker setting
206
+ *
207
+ * @deprecated Use config.json approach instead
208
+ * @returns Active broker name or null
209
+ */
210
+ export function getActiveBrokerName() {
211
+ loadBrokerConfig();
212
+ return activeBrokerName;
213
+ }
214
+ /**
215
+ * Get active broker URL
216
+ *
217
+ * TODO: Replace with ~/.kadi/config.json active broker setting
218
+ *
219
+ * @deprecated Use config.json approach instead
220
+ * @returns Active broker URL or null
221
+ */
222
+ export function getActiveBrokerUrl() {
223
+ loadBrokerConfig();
224
+ return activeBrokerName ? (kadiBrokers[activeBrokerName] ?? null) : null;
225
+ }
226
+ //# sourceMappingURL=legacyHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacyHelpers.js","sourceRoot":"","sources":["../../src/utils/legacyHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,2BAA2B;AAC3B,IAAI,WAAW,GAAkB,IAAI,CAAC;AACtC,IAAI,WAAW,GAA2B,EAAE,CAAC;AAC7C,IAAI,iBAAiB,GAAkB,IAAI,CAAC;AAC5C,IAAI,gBAAgB,GAAkB,IAAI,CAAC;AAE3C;;;;;;;;GAQG;AACH,SAAS,sBAAsB;IAC7B,gCAAgC;IAChC,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,6DAA6D;IAC7D,IAAI,CAAC;QACH,4EAA4E;QAC5E,IAAI,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;YAC9C,aAAa;YACb,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC;YACrE,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;gBAC9B,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC/C,OAAO,WAAW,CAAC;YACrB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nB,IAAI,WAAW,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,gBAAgB,GAAG,UAAU,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB;IACjC,gBAAgB,EAAE,CAAC;IACnB,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB;IAChC,gBAAgB,EAAE,CAAC;IACnB,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,gBAAgB,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kadi.build/core",
3
- "version": "0.0.1-alpha.13",
3
+ "version": "0.0.1-alpha.15",
4
4
  "description": "A module that is a comprehensive toolkit for developers integrating with the KADI infrastructure.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,92 +0,0 @@
1
- /**
2
- * Simplified KADI API
3
- *
4
- * User-friendly API wrapper that makes KADI incredibly simple to use.
5
- * This is what developers actually interact with.
6
- *
7
- * @module api
8
- */
9
- import { KadiClient } from '../client/KadiClient.js';
10
- import type { KadiConfig, ServiceConfig } from '../types/index.js';
11
- /**
12
- * Connect to a KADI broker and create a client
13
- *
14
- * Simplified connection API that handles common cases beautifully.
15
- *
16
- * @param config - Broker URL string or full configuration object
17
- * @returns Connected KADI client
18
- *
19
- * @example
20
- * ```typescript
21
- * // Simple broker URL
22
- * const client = await Kadi.connect('ws://localhost:8080');
23
- *
24
- * // Full configuration
25
- * const client = await Kadi.connect({
26
- * name: 'my-app',
27
- * brokers: { local: 'ws://localhost:8080' },
28
- * networks: ['global']
29
- * });
30
- * ```
31
- */
32
- export declare function connect(config: string | KadiConfig): Promise<KadiClient>;
33
- /**
34
- * Create a service that provides tools
35
- *
36
- * Simplified service creation for agents that expose capabilities.
37
- *
38
- * @param config - Service configuration
39
- * @returns Service client ready for tool registration
40
- *
41
- * @example
42
- * ```typescript
43
- * const service = await Kadi.service({
44
- * name: 'calculator',
45
- * broker: 'ws://localhost:8080'
46
- * });
47
- *
48
- * // Register tools using MCP schema format
49
- * service.registerTool({
50
- * name: 'add',
51
- * description: 'Add two numbers',
52
- * inputSchema: {
53
- * type: 'object',
54
- * properties: {
55
- * a: { type: 'number' },
56
- * b: { type: 'number' }
57
- * },
58
- * required: ['a', 'b']
59
- * },
60
- * outputSchema: {
61
- * type: 'object',
62
- * properties: {
63
- * result: { type: 'number' }
64
- * }
65
- * }
66
- * }, async ({ a, b }) => {
67
- * return { result: a + b };
68
- * });
69
- * ```
70
- */
71
- export declare function service(config: ServiceConfig): Promise<KadiClient>;
72
- /**
73
- * Create a client without connecting to brokers
74
- *
75
- * Useful for local-only operations (native/stdio transports).
76
- *
77
- * @param name - Client name
78
- * @returns Local client (not connected to brokers)
79
- *
80
- * @example
81
- * ```typescript
82
- * const client = Kadi.local('my-app');
83
- *
84
- * // Load abilities locally
85
- * const calc = await client.loadAbility('calculator', {
86
- * transport: 'native',
87
- * path: './calculator'
88
- * });
89
- * ```
90
- */
91
- export declare function local(name: string): KadiClient;
92
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAoB,MAAM,mBAAmB,CAAC;AAErF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAa9E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAsB,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,CAqBxE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAK9C"}
package/dist/api/index.js DELETED
@@ -1,124 +0,0 @@
1
- /**
2
- * Simplified KADI API
3
- *
4
- * User-friendly API wrapper that makes KADI incredibly simple to use.
5
- * This is what developers actually interact with.
6
- *
7
- * @module api
8
- */
9
- import { KadiClient } from '../client/KadiClient.js';
10
- /**
11
- * Connect to a KADI broker and create a client
12
- *
13
- * Simplified connection API that handles common cases beautifully.
14
- *
15
- * @param config - Broker URL string or full configuration object
16
- * @returns Connected KADI client
17
- *
18
- * @example
19
- * ```typescript
20
- * // Simple broker URL
21
- * const client = await Kadi.connect('ws://localhost:8080');
22
- *
23
- * // Full configuration
24
- * const client = await Kadi.connect({
25
- * name: 'my-app',
26
- * brokers: { local: 'ws://localhost:8080' },
27
- * networks: ['global']
28
- * });
29
- * ```
30
- */
31
- export async function connect(config) {
32
- // Normalize config
33
- const normalizedConfig = typeof config === 'string'
34
- ? { name: 'kadi-client', brokers: { default: config } }
35
- : config;
36
- // Create client
37
- const client = new KadiClient(normalizedConfig);
38
- // Auto-connect
39
- await client.connect();
40
- return client;
41
- }
42
- /**
43
- * Create a service that provides tools
44
- *
45
- * Simplified service creation for agents that expose capabilities.
46
- *
47
- * @param config - Service configuration
48
- * @returns Service client ready for tool registration
49
- *
50
- * @example
51
- * ```typescript
52
- * const service = await Kadi.service({
53
- * name: 'calculator',
54
- * broker: 'ws://localhost:8080'
55
- * });
56
- *
57
- * // Register tools using MCP schema format
58
- * service.registerTool({
59
- * name: 'add',
60
- * description: 'Add two numbers',
61
- * inputSchema: {
62
- * type: 'object',
63
- * properties: {
64
- * a: { type: 'number' },
65
- * b: { type: 'number' }
66
- * },
67
- * required: ['a', 'b']
68
- * },
69
- * outputSchema: {
70
- * type: 'object',
71
- * properties: {
72
- * result: { type: 'number' }
73
- * }
74
- * }
75
- * }, async ({ a, b }) => {
76
- * return { result: a + b };
77
- * });
78
- * ```
79
- */
80
- export async function service(config) {
81
- // Convert ServiceConfig to KadiConfig
82
- const clientConfig = {
83
- name: config.name,
84
- version: config.version,
85
- description: config.description,
86
- role: 'ability',
87
- networks: config.networks ?? ['global']
88
- };
89
- // Add broker configuration
90
- if (config.broker) {
91
- clientConfig.brokers = { default: config.broker };
92
- clientConfig.defaultBroker = 'default';
93
- }
94
- // Create and return client
95
- const client = new KadiClient(clientConfig);
96
- await client.connect();
97
- return client;
98
- }
99
- /**
100
- * Create a client without connecting to brokers
101
- *
102
- * Useful for local-only operations (native/stdio transports).
103
- *
104
- * @param name - Client name
105
- * @returns Local client (not connected to brokers)
106
- *
107
- * @example
108
- * ```typescript
109
- * const client = Kadi.local('my-app');
110
- *
111
- * // Load abilities locally
112
- * const calc = await client.loadAbility('calculator', {
113
- * transport: 'native',
114
- * path: './calculator'
115
- * });
116
- * ```
117
- */
118
- export function local(name) {
119
- return new KadiClient({
120
- name,
121
- networks: ['local']
122
- });
123
- }
124
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGrD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,MAA2B;IACvD,mBAAmB;IACnB,MAAM,gBAAgB,GAAe,OAAO,MAAM,KAAK,QAAQ;QAC7D,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;QACvD,CAAC,CAAC,MAAM,CAAC;IAEX,gBAAgB;IAChB,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,gBAAgB,CAAC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