@merabylabs/promptarchitect-mcp 0.3.1 → 0.7.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/server.d.ts.map +1 -1
- package/dist/server.js +524 -2
- package/dist/server.js.map +1 -1
- package/dist/tools/executeCommand.d.ts +151 -0
- package/dist/tools/executeCommand.d.ts.map +1 -0
- package/dist/tools/executeCommand.js +229 -0
- package/dist/tools/executeCommand.js.map +1 -0
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +7 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/workflowTools.d.ts +179 -0
- package/dist/tools/workflowTools.d.ts.map +1 -0
- package/dist/tools/workflowTools.js +384 -0
- package/dist/tools/workflowTools.js.map +1 -0
- package/dist/tools/workspaceTools.d.ts +255 -0
- package/dist/tools/workspaceTools.d.ts.map +1 -0
- package/dist/tools/workspaceTools.js +463 -0
- package/dist/tools/workspaceTools.js.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execute Command Tool
|
|
3
|
+
* Allows the agent to execute shell commands in the workspace
|
|
4
|
+
*
|
|
5
|
+
* Security considerations:
|
|
6
|
+
* - Commands run in the workspace directory by default
|
|
7
|
+
* - Timeout protection prevents runaway processes
|
|
8
|
+
* - Dangerous commands are blocked
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
export declare const executeCommandSchema: z.ZodObject<{
|
|
12
|
+
command: z.ZodString;
|
|
13
|
+
workingDirectory: z.ZodOptional<z.ZodString>;
|
|
14
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
15
|
+
shell: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
command: string;
|
|
18
|
+
timeout: number;
|
|
19
|
+
shell: boolean;
|
|
20
|
+
workingDirectory?: string | undefined;
|
|
21
|
+
}, {
|
|
22
|
+
command: string;
|
|
23
|
+
workingDirectory?: string | undefined;
|
|
24
|
+
timeout?: number | undefined;
|
|
25
|
+
shell?: boolean | undefined;
|
|
26
|
+
}>;
|
|
27
|
+
export type ExecuteCommandInput = z.infer<typeof executeCommandSchema>;
|
|
28
|
+
export interface ExecuteCommandResult {
|
|
29
|
+
command: string;
|
|
30
|
+
stdout: string;
|
|
31
|
+
stderr: string;
|
|
32
|
+
exitCode: number;
|
|
33
|
+
executionTime: number;
|
|
34
|
+
truncated: boolean;
|
|
35
|
+
killed: boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare function executeCommand(input: ExecuteCommandInput): Promise<ExecuteCommandResult>;
|
|
38
|
+
export declare const runNpmScriptSchema: z.ZodObject<{
|
|
39
|
+
script: z.ZodString;
|
|
40
|
+
workingDirectory: z.ZodOptional<z.ZodString>;
|
|
41
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
timeout: number;
|
|
44
|
+
script: string;
|
|
45
|
+
workingDirectory?: string | undefined;
|
|
46
|
+
}, {
|
|
47
|
+
script: string;
|
|
48
|
+
workingDirectory?: string | undefined;
|
|
49
|
+
timeout?: number | undefined;
|
|
50
|
+
}>;
|
|
51
|
+
export type RunNpmScriptInput = z.infer<typeof runNpmScriptSchema>;
|
|
52
|
+
export declare function runNpmScript(input: RunNpmScriptInput): Promise<ExecuteCommandResult>;
|
|
53
|
+
export declare const gitCommandSchema: z.ZodObject<{
|
|
54
|
+
operation: z.ZodEnum<["status", "diff", "log", "branch", "stash-list"]>;
|
|
55
|
+
args: z.ZodOptional<z.ZodString>;
|
|
56
|
+
workingDirectory: z.ZodOptional<z.ZodString>;
|
|
57
|
+
}, "strip", z.ZodTypeAny, {
|
|
58
|
+
operation: "status" | "diff" | "log" | "branch" | "stash-list";
|
|
59
|
+
workingDirectory?: string | undefined;
|
|
60
|
+
args?: string | undefined;
|
|
61
|
+
}, {
|
|
62
|
+
operation: "status" | "diff" | "log" | "branch" | "stash-list";
|
|
63
|
+
workingDirectory?: string | undefined;
|
|
64
|
+
args?: string | undefined;
|
|
65
|
+
}>;
|
|
66
|
+
export type GitCommandInput = z.infer<typeof gitCommandSchema>;
|
|
67
|
+
export declare function gitCommand(input: GitCommandInput): Promise<ExecuteCommandResult>;
|
|
68
|
+
export declare const installDependenciesSchema: z.ZodObject<{
|
|
69
|
+
packages: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
70
|
+
dev: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
71
|
+
packageManager: z.ZodDefault<z.ZodOptional<z.ZodEnum<["npm", "yarn", "pnpm"]>>>;
|
|
72
|
+
workingDirectory: z.ZodOptional<z.ZodString>;
|
|
73
|
+
}, "strip", z.ZodTypeAny, {
|
|
74
|
+
dev: boolean;
|
|
75
|
+
packageManager: "npm" | "yarn" | "pnpm";
|
|
76
|
+
workingDirectory?: string | undefined;
|
|
77
|
+
packages?: string[] | undefined;
|
|
78
|
+
}, {
|
|
79
|
+
workingDirectory?: string | undefined;
|
|
80
|
+
packages?: string[] | undefined;
|
|
81
|
+
dev?: boolean | undefined;
|
|
82
|
+
packageManager?: "npm" | "yarn" | "pnpm" | undefined;
|
|
83
|
+
}>;
|
|
84
|
+
export type InstallDependenciesInput = z.infer<typeof installDependenciesSchema>;
|
|
85
|
+
export declare function installDependencies(input: InstallDependenciesInput): Promise<ExecuteCommandResult>;
|
|
86
|
+
declare const _default: {
|
|
87
|
+
executeCommand: typeof executeCommand;
|
|
88
|
+
executeCommandSchema: z.ZodObject<{
|
|
89
|
+
command: z.ZodString;
|
|
90
|
+
workingDirectory: z.ZodOptional<z.ZodString>;
|
|
91
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
92
|
+
shell: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
93
|
+
}, "strip", z.ZodTypeAny, {
|
|
94
|
+
command: string;
|
|
95
|
+
timeout: number;
|
|
96
|
+
shell: boolean;
|
|
97
|
+
workingDirectory?: string | undefined;
|
|
98
|
+
}, {
|
|
99
|
+
command: string;
|
|
100
|
+
workingDirectory?: string | undefined;
|
|
101
|
+
timeout?: number | undefined;
|
|
102
|
+
shell?: boolean | undefined;
|
|
103
|
+
}>;
|
|
104
|
+
runNpmScript: typeof runNpmScript;
|
|
105
|
+
runNpmScriptSchema: z.ZodObject<{
|
|
106
|
+
script: z.ZodString;
|
|
107
|
+
workingDirectory: z.ZodOptional<z.ZodString>;
|
|
108
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
109
|
+
}, "strip", z.ZodTypeAny, {
|
|
110
|
+
timeout: number;
|
|
111
|
+
script: string;
|
|
112
|
+
workingDirectory?: string | undefined;
|
|
113
|
+
}, {
|
|
114
|
+
script: string;
|
|
115
|
+
workingDirectory?: string | undefined;
|
|
116
|
+
timeout?: number | undefined;
|
|
117
|
+
}>;
|
|
118
|
+
gitCommand: typeof gitCommand;
|
|
119
|
+
gitCommandSchema: z.ZodObject<{
|
|
120
|
+
operation: z.ZodEnum<["status", "diff", "log", "branch", "stash-list"]>;
|
|
121
|
+
args: z.ZodOptional<z.ZodString>;
|
|
122
|
+
workingDirectory: z.ZodOptional<z.ZodString>;
|
|
123
|
+
}, "strip", z.ZodTypeAny, {
|
|
124
|
+
operation: "status" | "diff" | "log" | "branch" | "stash-list";
|
|
125
|
+
workingDirectory?: string | undefined;
|
|
126
|
+
args?: string | undefined;
|
|
127
|
+
}, {
|
|
128
|
+
operation: "status" | "diff" | "log" | "branch" | "stash-list";
|
|
129
|
+
workingDirectory?: string | undefined;
|
|
130
|
+
args?: string | undefined;
|
|
131
|
+
}>;
|
|
132
|
+
installDependencies: typeof installDependencies;
|
|
133
|
+
installDependenciesSchema: z.ZodObject<{
|
|
134
|
+
packages: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
135
|
+
dev: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
136
|
+
packageManager: z.ZodDefault<z.ZodOptional<z.ZodEnum<["npm", "yarn", "pnpm"]>>>;
|
|
137
|
+
workingDirectory: z.ZodOptional<z.ZodString>;
|
|
138
|
+
}, "strip", z.ZodTypeAny, {
|
|
139
|
+
dev: boolean;
|
|
140
|
+
packageManager: "npm" | "yarn" | "pnpm";
|
|
141
|
+
workingDirectory?: string | undefined;
|
|
142
|
+
packages?: string[] | undefined;
|
|
143
|
+
}, {
|
|
144
|
+
workingDirectory?: string | undefined;
|
|
145
|
+
packages?: string[] | undefined;
|
|
146
|
+
dev?: boolean | undefined;
|
|
147
|
+
packageManager?: "npm" | "yarn" | "pnpm" | undefined;
|
|
148
|
+
}>;
|
|
149
|
+
};
|
|
150
|
+
export default _default;
|
|
151
|
+
//# sourceMappingURL=executeCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executeCommand.d.ts","sourceRoot":"","sources":["../../src/tools/executeCommand.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;EAK/B,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEvE,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;CACjB;AAqCD,wBAAsB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAsE9F;AAMD,eAAO,MAAM,kBAAkB;;;;;;;;;;;;EAI7B,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEnE,wBAAsB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAgB1F;AAMD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;EAI3B,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE/D,wBAAsB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAyBtF;AAMD,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;EAKpC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAEjF,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAqCxG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAED,wBASE"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execute Command Tool
|
|
3
|
+
* Allows the agent to execute shell commands in the workspace
|
|
4
|
+
*
|
|
5
|
+
* Security considerations:
|
|
6
|
+
* - Commands run in the workspace directory by default
|
|
7
|
+
* - Timeout protection prevents runaway processes
|
|
8
|
+
* - Dangerous commands are blocked
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import { exec } from 'child_process';
|
|
12
|
+
import { promisify } from 'util';
|
|
13
|
+
import * as path from 'path';
|
|
14
|
+
import { logger } from '../utils/index.js';
|
|
15
|
+
const execAsync = promisify(exec);
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// EXECUTE COMMAND TOOL
|
|
18
|
+
// ============================================================================
|
|
19
|
+
export const executeCommandSchema = z.object({
|
|
20
|
+
command: z.string().describe('The shell command to execute'),
|
|
21
|
+
workingDirectory: z.string().optional().describe('Directory to run the command in (default: current directory)'),
|
|
22
|
+
timeout: z.number().optional().default(30000).describe('Timeout in milliseconds (default: 30s, max: 120s)'),
|
|
23
|
+
shell: z.boolean().optional().default(true).describe('Run in a shell (enables pipes, redirects)'),
|
|
24
|
+
});
|
|
25
|
+
// Commands that are blocked for safety
|
|
26
|
+
const BLOCKED_COMMANDS = [
|
|
27
|
+
// Destructive commands
|
|
28
|
+
'rm -rf /',
|
|
29
|
+
'rm -rf ~',
|
|
30
|
+
'rm -rf *',
|
|
31
|
+
'del /f /s /q',
|
|
32
|
+
'format',
|
|
33
|
+
'mkfs',
|
|
34
|
+
// System modification
|
|
35
|
+
'chmod 777 /',
|
|
36
|
+
'chown -R',
|
|
37
|
+
'dd if=',
|
|
38
|
+
// Network attacks
|
|
39
|
+
':(){:|:&};:',
|
|
40
|
+
// Credential theft
|
|
41
|
+
'cat /etc/passwd',
|
|
42
|
+
'cat /etc/shadow',
|
|
43
|
+
// Env manipulation
|
|
44
|
+
'export PATH=',
|
|
45
|
+
'unset PATH',
|
|
46
|
+
];
|
|
47
|
+
// Commands that require extra caution
|
|
48
|
+
const CAUTION_PATTERNS = [
|
|
49
|
+
/rm\s+-rf/,
|
|
50
|
+
/rmdir\s+\/s/,
|
|
51
|
+
/del\s+\/f/,
|
|
52
|
+
/sudo\s+/,
|
|
53
|
+
/chmod\s+-R\s+777/,
|
|
54
|
+
/>>\s*\/etc\//,
|
|
55
|
+
/curl.*\|\s*(bash|sh)/,
|
|
56
|
+
/wget.*\|\s*(bash|sh)/,
|
|
57
|
+
];
|
|
58
|
+
export async function executeCommand(input) {
|
|
59
|
+
const { command, workingDirectory, timeout, shell } = input;
|
|
60
|
+
// Enforce maximum timeout
|
|
61
|
+
const effectiveTimeout = Math.min(timeout, 120000);
|
|
62
|
+
logger.info('Executing command', { command, workingDirectory, timeout: effectiveTimeout });
|
|
63
|
+
// Security checks
|
|
64
|
+
for (const blocked of BLOCKED_COMMANDS) {
|
|
65
|
+
if (command.toLowerCase().includes(blocked.toLowerCase())) {
|
|
66
|
+
throw new Error(`Command blocked for safety: "${command}". This command could cause system damage.`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
for (const pattern of CAUTION_PATTERNS) {
|
|
70
|
+
if (pattern.test(command)) {
|
|
71
|
+
logger.warn('Executing potentially dangerous command', { command });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const startTime = Date.now();
|
|
75
|
+
const cwd = workingDirectory ? path.resolve(workingDirectory) : process.cwd();
|
|
76
|
+
try {
|
|
77
|
+
const shellOption = shell === false ? undefined : (process.platform === 'win32' ? 'cmd.exe' : '/bin/bash');
|
|
78
|
+
const { stdout, stderr } = await execAsync(command, {
|
|
79
|
+
cwd,
|
|
80
|
+
timeout: effectiveTimeout,
|
|
81
|
+
shell: shellOption,
|
|
82
|
+
maxBuffer: 1024 * 1024 * 5, // 5MB
|
|
83
|
+
});
|
|
84
|
+
const executionTime = Date.now() - startTime;
|
|
85
|
+
const MAX_OUTPUT = 50000; // 50KB limit
|
|
86
|
+
return {
|
|
87
|
+
command,
|
|
88
|
+
stdout: stdout.length > MAX_OUTPUT ? stdout.slice(0, MAX_OUTPUT) + '\n... (truncated)' : stdout,
|
|
89
|
+
stderr: stderr.length > MAX_OUTPUT ? stderr.slice(0, MAX_OUTPUT) + '\n... (truncated)' : stderr,
|
|
90
|
+
exitCode: 0,
|
|
91
|
+
executionTime,
|
|
92
|
+
truncated: stdout.length > MAX_OUTPUT || stderr.length > MAX_OUTPUT,
|
|
93
|
+
killed: false,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
const executionTime = Date.now() - startTime;
|
|
98
|
+
if (error.killed) {
|
|
99
|
+
return {
|
|
100
|
+
command,
|
|
101
|
+
stdout: error.stdout || '',
|
|
102
|
+
stderr: error.stderr || `Command killed after ${effectiveTimeout}ms timeout`,
|
|
103
|
+
exitCode: error.code || 1,
|
|
104
|
+
executionTime,
|
|
105
|
+
truncated: false,
|
|
106
|
+
killed: true,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
command,
|
|
111
|
+
stdout: error.stdout || '',
|
|
112
|
+
stderr: error.stderr || error.message,
|
|
113
|
+
exitCode: error.code || 1,
|
|
114
|
+
executionTime,
|
|
115
|
+
truncated: false,
|
|
116
|
+
killed: false,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// ============================================================================
|
|
121
|
+
// RUN NPM SCRIPT TOOL
|
|
122
|
+
// ============================================================================
|
|
123
|
+
export const runNpmScriptSchema = z.object({
|
|
124
|
+
script: z.string().describe('The npm script name to run (e.g., "build", "test", "lint")'),
|
|
125
|
+
workingDirectory: z.string().optional().describe('Directory containing package.json'),
|
|
126
|
+
timeout: z.number().optional().default(60000).describe('Timeout in milliseconds (default: 60s)'),
|
|
127
|
+
});
|
|
128
|
+
export async function runNpmScript(input) {
|
|
129
|
+
const { script, workingDirectory, timeout } = input;
|
|
130
|
+
// Validate script name (alphanumeric, hyphens, colons)
|
|
131
|
+
if (!/^[a-zA-Z0-9_:-]+$/.test(script)) {
|
|
132
|
+
throw new Error(`Invalid npm script name: "${script}"`);
|
|
133
|
+
}
|
|
134
|
+
const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
135
|
+
return executeCommand({
|
|
136
|
+
command: `${npmCommand} run ${script}`,
|
|
137
|
+
workingDirectory,
|
|
138
|
+
timeout,
|
|
139
|
+
shell: true,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
// ============================================================================
|
|
143
|
+
// GIT OPERATIONS
|
|
144
|
+
// ============================================================================
|
|
145
|
+
export const gitCommandSchema = z.object({
|
|
146
|
+
operation: z.enum(['status', 'diff', 'log', 'branch', 'stash-list']).describe('Git operation to perform'),
|
|
147
|
+
args: z.string().optional().describe('Additional arguments for the git command'),
|
|
148
|
+
workingDirectory: z.string().optional().describe('Git repository directory'),
|
|
149
|
+
});
|
|
150
|
+
export async function gitCommand(input) {
|
|
151
|
+
const { operation, args, workingDirectory } = input;
|
|
152
|
+
// Only allow safe read-only git commands
|
|
153
|
+
const safeOperations = {
|
|
154
|
+
'status': 'git status',
|
|
155
|
+
'diff': 'git diff',
|
|
156
|
+
'log': 'git log --oneline -20',
|
|
157
|
+
'branch': 'git branch -a',
|
|
158
|
+
'stash-list': 'git stash list',
|
|
159
|
+
};
|
|
160
|
+
const baseCommand = safeOperations[operation];
|
|
161
|
+
if (!baseCommand) {
|
|
162
|
+
throw new Error(`Unknown git operation: ${operation}`);
|
|
163
|
+
}
|
|
164
|
+
const command = args ? `${baseCommand} ${args}` : baseCommand;
|
|
165
|
+
return executeCommand({
|
|
166
|
+
command,
|
|
167
|
+
workingDirectory,
|
|
168
|
+
timeout: 10000,
|
|
169
|
+
shell: true,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
// ============================================================================
|
|
173
|
+
// INSTALL DEPENDENCIES
|
|
174
|
+
// ============================================================================
|
|
175
|
+
export const installDependenciesSchema = z.object({
|
|
176
|
+
packages: z.array(z.string()).optional().describe('Specific packages to install (empty = install all)'),
|
|
177
|
+
dev: z.boolean().optional().default(false).describe('Install as dev dependency'),
|
|
178
|
+
packageManager: z.enum(['npm', 'yarn', 'pnpm']).optional().default('npm').describe('Package manager to use'),
|
|
179
|
+
workingDirectory: z.string().optional().describe('Directory containing package.json'),
|
|
180
|
+
});
|
|
181
|
+
export async function installDependencies(input) {
|
|
182
|
+
const { packages, dev, packageManager, workingDirectory } = input;
|
|
183
|
+
let command;
|
|
184
|
+
switch (packageManager) {
|
|
185
|
+
case 'yarn':
|
|
186
|
+
if (packages && packages.length > 0) {
|
|
187
|
+
command = `yarn add ${dev ? '-D ' : ''}${packages.join(' ')}`;
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
command = 'yarn install';
|
|
191
|
+
}
|
|
192
|
+
break;
|
|
193
|
+
case 'pnpm':
|
|
194
|
+
if (packages && packages.length > 0) {
|
|
195
|
+
command = `pnpm add ${dev ? '-D ' : ''}${packages.join(' ')}`;
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
command = 'pnpm install';
|
|
199
|
+
}
|
|
200
|
+
break;
|
|
201
|
+
case 'npm':
|
|
202
|
+
default:
|
|
203
|
+
if (packages && packages.length > 0) {
|
|
204
|
+
command = `npm install ${dev ? '--save-dev ' : ''}${packages.join(' ')}`;
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
command = 'npm install';
|
|
208
|
+
}
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
// Longer timeout for installations
|
|
212
|
+
return executeCommand({
|
|
213
|
+
command,
|
|
214
|
+
workingDirectory,
|
|
215
|
+
timeout: 120000, // 2 minutes
|
|
216
|
+
shell: true,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
export default {
|
|
220
|
+
executeCommand,
|
|
221
|
+
executeCommandSchema,
|
|
222
|
+
runNpmScript,
|
|
223
|
+
runNpmScriptSchema,
|
|
224
|
+
gitCommand,
|
|
225
|
+
gitCommandSchema,
|
|
226
|
+
installDependencies,
|
|
227
|
+
installDependenciesSchema,
|
|
228
|
+
};
|
|
229
|
+
//# sourceMappingURL=executeCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executeCommand.js","sourceRoot":"","sources":["../../src/tools/executeCommand.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE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ACR,KAAK,KAAK,CAAC;QACX;YACE,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACpC,OAAO,GAAG,eAAe,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3E,CAAC;iBAAM,CAAC;gBACN,OAAO,GAAG,aAAa,CAAC;YAC1B,CAAC;YACD,MAAM;IACV,CAAC;IAED,mCAAmC;IACnC,OAAO,cAAc,CAAC;QACpB,OAAO;QACP,gBAAgB;QAChB,OAAO,EAAE,MAAM,EAAE,YAAY;QAC7B,KAAK,EAAE,IAAI;KACZ,CAAC,CAAC;AACL,CAAC;AAED,eAAe;IACb,cAAc;IACd,oBAAoB;IACpB,YAAY;IACZ,kBAAkB;IAClB,UAAU;IACV,gBAAgB;IAChB,mBAAmB;IACnB,yBAAyB;CAC1B,CAAC"}
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -5,4 +5,7 @@
|
|
|
5
5
|
export { generatePrompt, generatePromptSchema, type GeneratePromptInput, } from './generatePrompt.js';
|
|
6
6
|
export { refinePrompt, refinePromptSchema, type RefinePromptInput, } from './refinePrompt.js';
|
|
7
7
|
export { analyzePrompt, analyzePromptSchema, type AnalyzePromptInput, type AnalysisResult, } from './analyzePrompt.js';
|
|
8
|
+
export { readFile, readFileSchema, type ReadFileInput, type ReadFileResult, writeFile, writeFileSchema, type WriteFileInput, type WriteFileResult, listFiles, listFilesSchema, type ListFilesInput, type ListFilesResult, searchFiles, searchFilesSchema, type SearchFilesInput, type SearchFilesResult, getWorkspaceContext, getWorkspaceContextSchema, type GetWorkspaceContextInput, type WorkspaceContext, } from './workspaceTools.js';
|
|
9
|
+
export { executeCommand, executeCommandSchema, type ExecuteCommandInput, type ExecuteCommandResult, runNpmScript, runNpmScriptSchema, type RunNpmScriptInput, gitCommand, gitCommandSchema, type GitCommandInput, installDependencies, installDependenciesSchema, type InstallDependenciesInput, } from './executeCommand.js';
|
|
10
|
+
export { executePromptWorkflow, promptWorkflowSchema, type PromptWorkflowInput, type PromptWorkflowResult, executeCustomWorkflow, customWorkflowSchema, type CustomWorkflowInput, type WorkflowResult, } from './workflowTools.js';
|
|
8
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,KAAK,mBAAmB,GACzB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,KAAK,iBAAiB,GACvB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,KAAK,kBAAkB,EACvB,KAAK,cAAc,GACpB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,QAAQ,EACR,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,SAAS,EACT,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,SAAS,EACT,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,WAAW,EACX,iBAAiB,EACjB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,mBAAmB,EACnB,yBAAyB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,YAAY,EACZ,kBAAkB,EAClB,KAAK,iBAAiB,EACtB,UAAU,EACV,gBAAgB,EAChB,KAAK,eAAe,EACpB,mBAAmB,EACnB,yBAAyB,EACzB,KAAK,wBAAwB,GAC9B,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,KAAK,cAAc,GACpB,MAAM,oBAAoB,CAAC"}
|
package/dist/tools/index.js
CHANGED
|
@@ -2,7 +2,14 @@
|
|
|
2
2
|
* Tools Index
|
|
3
3
|
* Exports all MCP tools with their schemas and handlers
|
|
4
4
|
*/
|
|
5
|
+
// Prompt Engineering Tools
|
|
5
6
|
export { generatePrompt, generatePromptSchema, } from './generatePrompt.js';
|
|
6
7
|
export { refinePrompt, refinePromptSchema, } from './refinePrompt.js';
|
|
7
8
|
export { analyzePrompt, analyzePromptSchema, } from './analyzePrompt.js';
|
|
9
|
+
// Workspace & File System Tools
|
|
10
|
+
export { readFile, readFileSchema, writeFile, writeFileSchema, listFiles, listFilesSchema, searchFiles, searchFilesSchema, getWorkspaceContext, getWorkspaceContextSchema, } from './workspaceTools.js';
|
|
11
|
+
// Command Execution Tools
|
|
12
|
+
export { executeCommand, executeCommandSchema, runNpmScript, runNpmScriptSchema, gitCommand, gitCommandSchema, installDependencies, installDependenciesSchema, } from './executeCommand.js';
|
|
13
|
+
// Workflow & Composition Tools
|
|
14
|
+
export { executePromptWorkflow, promptWorkflowSchema, executeCustomWorkflow, customWorkflowSchema, } from './workflowTools.js';
|
|
8
15
|
//# sourceMappingURL=index.js.map
|
package/dist/tools/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,cAAc,EACd,oBAAoB,GAErB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,YAAY,EACZ,kBAAkB,GAEnB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,aAAa,EACb,mBAAmB,GAGpB,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,2BAA2B;AAC3B,OAAO,EACL,cAAc,EACd,oBAAoB,GAErB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,YAAY,EACZ,kBAAkB,GAEnB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,aAAa,EACb,mBAAmB,GAGpB,MAAM,oBAAoB,CAAC;AAE5B,gCAAgC;AAChC,OAAO,EACL,QAAQ,EACR,cAAc,EAGd,SAAS,EACT,eAAe,EAGf,SAAS,EACT,eAAe,EAGf,WAAW,EACX,iBAAiB,EAGjB,mBAAmB,EACnB,yBAAyB,GAG1B,MAAM,qBAAqB,CAAC;AAE7B,0BAA0B;AAC1B,OAAO,EACL,cAAc,EACd,oBAAoB,EAGpB,YAAY,EACZ,kBAAkB,EAElB,UAAU,EACV,gBAAgB,EAEhB,mBAAmB,EACnB,yBAAyB,GAE1B,MAAM,qBAAqB,CAAC;AAE7B,+BAA+B;AAC/B,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EAGpB,qBAAqB,EACrB,oBAAoB,GAGrB,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow Tools
|
|
3
|
+
* Enables tool composition and multi-step workflows
|
|
4
|
+
*
|
|
5
|
+
* These tools allow chaining multiple operations together:
|
|
6
|
+
* - Analyze → Refine → Save workflow
|
|
7
|
+
* - Read → Generate → Write workflow
|
|
8
|
+
* - Search → Read → Modify → Write workflow
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import { AnalysisResult } from './analyzePrompt.js';
|
|
12
|
+
export interface WorkflowStep {
|
|
13
|
+
tool: string;
|
|
14
|
+
params: Record<string, any>;
|
|
15
|
+
outputVar?: string;
|
|
16
|
+
condition?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface WorkflowResult {
|
|
19
|
+
success: boolean;
|
|
20
|
+
steps: {
|
|
21
|
+
tool: string;
|
|
22
|
+
success: boolean;
|
|
23
|
+
result?: any;
|
|
24
|
+
error?: string;
|
|
25
|
+
duration: number;
|
|
26
|
+
}[];
|
|
27
|
+
finalOutput: any;
|
|
28
|
+
totalDuration: number;
|
|
29
|
+
variables: Record<string, any>;
|
|
30
|
+
}
|
|
31
|
+
export declare const promptWorkflowSchema: z.ZodObject<{
|
|
32
|
+
workflow: z.ZodEnum<["analyze_and_refine", "generate_and_analyze", "full_optimization", "context_aware_generate"]>;
|
|
33
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
34
|
+
idea: z.ZodOptional<z.ZodString>;
|
|
35
|
+
template: z.ZodOptional<z.ZodString>;
|
|
36
|
+
targetModel: z.ZodOptional<z.ZodString>;
|
|
37
|
+
feedback: z.ZodOptional<z.ZodString>;
|
|
38
|
+
saveToFile: z.ZodOptional<z.ZodString>;
|
|
39
|
+
workspaceContext: z.ZodOptional<z.ZodString>;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
workflow: "analyze_and_refine" | "generate_and_analyze" | "full_optimization" | "context_aware_generate";
|
|
42
|
+
template?: string | undefined;
|
|
43
|
+
idea?: string | undefined;
|
|
44
|
+
targetModel?: string | undefined;
|
|
45
|
+
workspaceContext?: string | undefined;
|
|
46
|
+
prompt?: string | undefined;
|
|
47
|
+
feedback?: string | undefined;
|
|
48
|
+
saveToFile?: string | undefined;
|
|
49
|
+
}, {
|
|
50
|
+
workflow: "analyze_and_refine" | "generate_and_analyze" | "full_optimization" | "context_aware_generate";
|
|
51
|
+
template?: string | undefined;
|
|
52
|
+
idea?: string | undefined;
|
|
53
|
+
targetModel?: string | undefined;
|
|
54
|
+
workspaceContext?: string | undefined;
|
|
55
|
+
prompt?: string | undefined;
|
|
56
|
+
feedback?: string | undefined;
|
|
57
|
+
saveToFile?: string | undefined;
|
|
58
|
+
}>;
|
|
59
|
+
export type PromptWorkflowInput = z.infer<typeof promptWorkflowSchema>;
|
|
60
|
+
export interface PromptWorkflowResult {
|
|
61
|
+
workflow: string;
|
|
62
|
+
steps: {
|
|
63
|
+
name: string;
|
|
64
|
+
success: boolean;
|
|
65
|
+
output?: any;
|
|
66
|
+
error?: string;
|
|
67
|
+
}[];
|
|
68
|
+
finalPrompt: string;
|
|
69
|
+
analysis?: AnalysisResult;
|
|
70
|
+
savedTo?: string;
|
|
71
|
+
improvements?: string[];
|
|
72
|
+
}
|
|
73
|
+
export declare function executePromptWorkflow(input: PromptWorkflowInput): Promise<PromptWorkflowResult>;
|
|
74
|
+
export declare const customWorkflowSchema: z.ZodObject<{
|
|
75
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
76
|
+
tool: z.ZodEnum<["generate_prompt", "refine_prompt", "analyze_prompt", "read_file", "write_file", "execute_command", "get_workspace_context"]>;
|
|
77
|
+
params: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
78
|
+
outputVar: z.ZodOptional<z.ZodString>;
|
|
79
|
+
condition: z.ZodOptional<z.ZodString>;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
tool: "generate_prompt" | "refine_prompt" | "analyze_prompt" | "read_file" | "write_file" | "execute_command" | "get_workspace_context";
|
|
82
|
+
params: Record<string, any>;
|
|
83
|
+
outputVar?: string | undefined;
|
|
84
|
+
condition?: string | undefined;
|
|
85
|
+
}, {
|
|
86
|
+
tool: "generate_prompt" | "refine_prompt" | "analyze_prompt" | "read_file" | "write_file" | "execute_command" | "get_workspace_context";
|
|
87
|
+
params: Record<string, any>;
|
|
88
|
+
outputVar?: string | undefined;
|
|
89
|
+
condition?: string | undefined;
|
|
90
|
+
}>, "many">;
|
|
91
|
+
stopOnError: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
92
|
+
}, "strip", z.ZodTypeAny, {
|
|
93
|
+
steps: {
|
|
94
|
+
tool: "generate_prompt" | "refine_prompt" | "analyze_prompt" | "read_file" | "write_file" | "execute_command" | "get_workspace_context";
|
|
95
|
+
params: Record<string, any>;
|
|
96
|
+
outputVar?: string | undefined;
|
|
97
|
+
condition?: string | undefined;
|
|
98
|
+
}[];
|
|
99
|
+
stopOnError: boolean;
|
|
100
|
+
}, {
|
|
101
|
+
steps: {
|
|
102
|
+
tool: "generate_prompt" | "refine_prompt" | "analyze_prompt" | "read_file" | "write_file" | "execute_command" | "get_workspace_context";
|
|
103
|
+
params: Record<string, any>;
|
|
104
|
+
outputVar?: string | undefined;
|
|
105
|
+
condition?: string | undefined;
|
|
106
|
+
}[];
|
|
107
|
+
stopOnError?: boolean | undefined;
|
|
108
|
+
}>;
|
|
109
|
+
export type CustomWorkflowInput = z.infer<typeof customWorkflowSchema>;
|
|
110
|
+
export declare function executeCustomWorkflow(input: CustomWorkflowInput): Promise<WorkflowResult>;
|
|
111
|
+
declare const _default: {
|
|
112
|
+
executePromptWorkflow: typeof executePromptWorkflow;
|
|
113
|
+
promptWorkflowSchema: z.ZodObject<{
|
|
114
|
+
workflow: z.ZodEnum<["analyze_and_refine", "generate_and_analyze", "full_optimization", "context_aware_generate"]>;
|
|
115
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
116
|
+
idea: z.ZodOptional<z.ZodString>;
|
|
117
|
+
template: z.ZodOptional<z.ZodString>;
|
|
118
|
+
targetModel: z.ZodOptional<z.ZodString>;
|
|
119
|
+
feedback: z.ZodOptional<z.ZodString>;
|
|
120
|
+
saveToFile: z.ZodOptional<z.ZodString>;
|
|
121
|
+
workspaceContext: z.ZodOptional<z.ZodString>;
|
|
122
|
+
}, "strip", z.ZodTypeAny, {
|
|
123
|
+
workflow: "analyze_and_refine" | "generate_and_analyze" | "full_optimization" | "context_aware_generate";
|
|
124
|
+
template?: string | undefined;
|
|
125
|
+
idea?: string | undefined;
|
|
126
|
+
targetModel?: string | undefined;
|
|
127
|
+
workspaceContext?: string | undefined;
|
|
128
|
+
prompt?: string | undefined;
|
|
129
|
+
feedback?: string | undefined;
|
|
130
|
+
saveToFile?: string | undefined;
|
|
131
|
+
}, {
|
|
132
|
+
workflow: "analyze_and_refine" | "generate_and_analyze" | "full_optimization" | "context_aware_generate";
|
|
133
|
+
template?: string | undefined;
|
|
134
|
+
idea?: string | undefined;
|
|
135
|
+
targetModel?: string | undefined;
|
|
136
|
+
workspaceContext?: string | undefined;
|
|
137
|
+
prompt?: string | undefined;
|
|
138
|
+
feedback?: string | undefined;
|
|
139
|
+
saveToFile?: string | undefined;
|
|
140
|
+
}>;
|
|
141
|
+
executeCustomWorkflow: typeof executeCustomWorkflow;
|
|
142
|
+
customWorkflowSchema: z.ZodObject<{
|
|
143
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
144
|
+
tool: z.ZodEnum<["generate_prompt", "refine_prompt", "analyze_prompt", "read_file", "write_file", "execute_command", "get_workspace_context"]>;
|
|
145
|
+
params: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
146
|
+
outputVar: z.ZodOptional<z.ZodString>;
|
|
147
|
+
condition: z.ZodOptional<z.ZodString>;
|
|
148
|
+
}, "strip", z.ZodTypeAny, {
|
|
149
|
+
tool: "generate_prompt" | "refine_prompt" | "analyze_prompt" | "read_file" | "write_file" | "execute_command" | "get_workspace_context";
|
|
150
|
+
params: Record<string, any>;
|
|
151
|
+
outputVar?: string | undefined;
|
|
152
|
+
condition?: string | undefined;
|
|
153
|
+
}, {
|
|
154
|
+
tool: "generate_prompt" | "refine_prompt" | "analyze_prompt" | "read_file" | "write_file" | "execute_command" | "get_workspace_context";
|
|
155
|
+
params: Record<string, any>;
|
|
156
|
+
outputVar?: string | undefined;
|
|
157
|
+
condition?: string | undefined;
|
|
158
|
+
}>, "many">;
|
|
159
|
+
stopOnError: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
160
|
+
}, "strip", z.ZodTypeAny, {
|
|
161
|
+
steps: {
|
|
162
|
+
tool: "generate_prompt" | "refine_prompt" | "analyze_prompt" | "read_file" | "write_file" | "execute_command" | "get_workspace_context";
|
|
163
|
+
params: Record<string, any>;
|
|
164
|
+
outputVar?: string | undefined;
|
|
165
|
+
condition?: string | undefined;
|
|
166
|
+
}[];
|
|
167
|
+
stopOnError: boolean;
|
|
168
|
+
}, {
|
|
169
|
+
steps: {
|
|
170
|
+
tool: "generate_prompt" | "refine_prompt" | "analyze_prompt" | "read_file" | "write_file" | "execute_command" | "get_workspace_context";
|
|
171
|
+
params: Record<string, any>;
|
|
172
|
+
outputVar?: string | undefined;
|
|
173
|
+
condition?: string | undefined;
|
|
174
|
+
}[];
|
|
175
|
+
stopOnError?: boolean | undefined;
|
|
176
|
+
}>;
|
|
177
|
+
};
|
|
178
|
+
export default _default;
|
|
179
|
+
//# sourceMappingURL=workflowTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflowTools.d.ts","sourceRoot":"","sources":["../../src/tools/workflowTools.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,EAAqC,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAavF,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,CAAC,EAAE,GAAG,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;KAClB,EAAE,CAAC;IACJ,WAAW,EAAE,GAAG,CAAC;IACjB,aAAa,EAAE,MAAM,CAA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