genlayer 0.0.22 → 0.0.23

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
 
2
2
 
3
+ ## 0.0.23 (2024-05-01)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * windows installation ([#19](https://github.com/yeagerai/genlayer-cli/issues/19)) ([3eafe6d](https://github.com/yeagerai/genlayer-cli/commit/3eafe6df9f5f657139177a588d6d53a652a25bd3))
9
+
3
10
  ## 0.0.22 (2024-04-30)
4
11
 
5
12
 
package/README.md CHANGED
@@ -26,6 +26,21 @@ This command will download the necessary components and start the simulator. Onc
26
26
 
27
27
  Contributions to the GenLayer CLI are welcome! Please feel free to fork the repository, make your changes, and submit a pull request. We appreciate your efforts to improve the software.
28
28
 
29
+ ### Running the CLI from the repository
30
+
31
+ First, install the dependencies and start the build process
32
+ ```bash
33
+ npm install
34
+ npm run dev
35
+ ```
36
+ This will continuously rebuild the CLI from the source
37
+
38
+ Then in another window execute the CLI commands like so:
39
+
40
+ ```bash
41
+ node dist/index.js init
42
+ ```
43
+
29
44
  ## License
30
45
 
31
46
  This project is licensed under the ... License - see the [LICENSE](LICENSE) file for details.
package/dist/index.js CHANGED
@@ -1051,7 +1051,7 @@ var require_command = __commonJS({
1051
1051
  "use strict";
1052
1052
  var EventEmitter = require("events").EventEmitter;
1053
1053
  var childProcess = require("child_process");
1054
- var path = require("path");
1054
+ var path2 = require("path");
1055
1055
  var fs3 = require("fs");
1056
1056
  var process4 = require("process");
1057
1057
  var { Argument: Argument2, humanReadableArgName } = require_argument();
@@ -1950,10 +1950,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
1950
1950
  let launchWithNode = false;
1951
1951
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1952
1952
  function findFile(baseDir, baseName) {
1953
- const localBin = path.resolve(baseDir, baseName);
1953
+ const localBin = path2.resolve(baseDir, baseName);
1954
1954
  if (fs3.existsSync(localBin))
1955
1955
  return localBin;
1956
- if (sourceExt.includes(path.extname(baseName)))
1956
+ if (sourceExt.includes(path2.extname(baseName)))
1957
1957
  return void 0;
1958
1958
  const foundExt = sourceExt.find((ext) => fs3.existsSync(`${localBin}${ext}`));
1959
1959
  if (foundExt)
@@ -1971,19 +1971,19 @@ Expecting one of '${allowedValues.join("', '")}'`);
1971
1971
  } catch (err) {
1972
1972
  resolvedScriptPath = this._scriptPath;
1973
1973
  }
1974
- executableDir = path.resolve(path.dirname(resolvedScriptPath), executableDir);
1974
+ executableDir = path2.resolve(path2.dirname(resolvedScriptPath), executableDir);
1975
1975
  }
1976
1976
  if (executableDir) {
1977
1977
  let localFile = findFile(executableDir, executableFile);
1978
1978
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
1979
- const legacyName = path.basename(this._scriptPath, path.extname(this._scriptPath));
1979
+ const legacyName = path2.basename(this._scriptPath, path2.extname(this._scriptPath));
1980
1980
  if (legacyName !== this._name) {
1981
1981
  localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`);
1982
1982
  }
1983
1983
  }
1984
1984
  executableFile = localFile || executableFile;
1985
1985
  }
1986
- launchWithNode = sourceExt.includes(path.extname(executableFile));
1986
+ launchWithNode = sourceExt.includes(path2.extname(executableFile));
1987
1987
  let proc;
1988
1988
  if (process4.platform !== "win32") {
1989
1989
  if (launchWithNode) {
@@ -2793,7 +2793,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2793
2793
  * @return {Command}
2794
2794
  */
2795
2795
  nameFromFilename(filename) {
2796
- this._name = path.basename(filename, path.extname(filename));
2796
+ this._name = path2.basename(filename, path2.extname(filename));
2797
2797
  return this;
2798
2798
  }
2799
2799
  /**
@@ -2807,10 +2807,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
2807
2807
  * @param {string} [path]
2808
2808
  * @return {(string|null|Command)}
2809
2809
  */
2810
- executableDir(path2) {
2811
- if (path2 === void 0)
2810
+ executableDir(path3) {
2811
+ if (path3 === void 0)
2812
2812
  return this._executableDir;
2813
- this._executableDir = path2;
2813
+ this._executableDir = path3;
2814
2814
  return this;
2815
2815
  }
2816
2816
  /**
@@ -15913,11 +15913,11 @@ var require_baseGet = __commonJS({
15913
15913
  "use strict";
15914
15914
  var castPath = require_castPath();
15915
15915
  var toKey = require_toKey();
15916
- function baseGet(object, path) {
15917
- path = castPath(path, object);
15918
- var index = 0, length = path.length;
15916
+ function baseGet(object, path2) {
15917
+ path2 = castPath(path2, object);
15918
+ var index = 0, length = path2.length;
15919
15919
  while (object != null && index < length) {
15920
- object = object[toKey(path[index++])];
15920
+ object = object[toKey(path2[index++])];
15921
15921
  }
15922
15922
  return index && index == length ? object : void 0;
15923
15923
  }
@@ -15930,8 +15930,8 @@ var require_get = __commonJS({
15930
15930
  "node_modules/lodash/get.js"(exports2, module2) {
15931
15931
  "use strict";
15932
15932
  var baseGet = require_baseGet();
15933
- function get2(object, path, defaultValue) {
15934
- var result = object == null ? void 0 : baseGet(object, path);
15933
+ function get2(object, path2, defaultValue) {
15934
+ var result = object == null ? void 0 : baseGet(object, path2);
15935
15935
  return result === void 0 ? defaultValue : result;
15936
15936
  }
15937
15937
  module2.exports = get2;
@@ -15959,11 +15959,11 @@ var require_hasPath = __commonJS({
15959
15959
  var isIndex = require_isIndex();
15960
15960
  var isLength = require_isLength();
15961
15961
  var toKey = require_toKey();
15962
- function hasPath(object, path, hasFunc) {
15963
- path = castPath(path, object);
15964
- var index = -1, length = path.length, result = false;
15962
+ function hasPath(object, path2, hasFunc) {
15963
+ path2 = castPath(path2, object);
15964
+ var index = -1, length = path2.length, result = false;
15965
15965
  while (++index < length) {
15966
- var key = toKey(path[index]);
15966
+ var key = toKey(path2[index]);
15967
15967
  if (!(result = object != null && hasFunc(object, key))) {
15968
15968
  break;
15969
15969
  }
@@ -15985,8 +15985,8 @@ var require_hasIn = __commonJS({
15985
15985
  "use strict";
15986
15986
  var baseHasIn = require_baseHasIn();
15987
15987
  var hasPath = require_hasPath();
15988
- function hasIn(object, path) {
15989
- return object != null && hasPath(object, path, baseHasIn);
15988
+ function hasIn(object, path2) {
15989
+ return object != null && hasPath(object, path2, baseHasIn);
15990
15990
  }
15991
15991
  module2.exports = hasIn;
15992
15992
  }
@@ -16005,13 +16005,13 @@ var require_baseMatchesProperty = __commonJS({
16005
16005
  var toKey = require_toKey();
16006
16006
  var COMPARE_PARTIAL_FLAG = 1;
16007
16007
  var COMPARE_UNORDERED_FLAG = 2;
16008
- function baseMatchesProperty(path, srcValue) {
16009
- if (isKey(path) && isStrictComparable(srcValue)) {
16010
- return matchesStrictComparable(toKey(path), srcValue);
16008
+ function baseMatchesProperty(path2, srcValue) {
16009
+ if (isKey(path2) && isStrictComparable(srcValue)) {
16010
+ return matchesStrictComparable(toKey(path2), srcValue);
16011
16011
  }
16012
16012
  return function(object) {
16013
- var objValue = get2(object, path);
16014
- return objValue === void 0 && objValue === srcValue ? hasIn(object, path) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
16013
+ var objValue = get2(object, path2);
16014
+ return objValue === void 0 && objValue === srcValue ? hasIn(object, path2) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
16015
16015
  };
16016
16016
  }
16017
16017
  module2.exports = baseMatchesProperty;
@@ -16036,9 +16036,9 @@ var require_basePropertyDeep = __commonJS({
16036
16036
  "node_modules/lodash/_basePropertyDeep.js"(exports2, module2) {
16037
16037
  "use strict";
16038
16038
  var baseGet = require_baseGet();
16039
- function basePropertyDeep(path) {
16039
+ function basePropertyDeep(path2) {
16040
16040
  return function(object) {
16041
- return baseGet(object, path);
16041
+ return baseGet(object, path2);
16042
16042
  };
16043
16043
  }
16044
16044
  module2.exports = basePropertyDeep;
@@ -16053,8 +16053,8 @@ var require_property = __commonJS({
16053
16053
  var basePropertyDeep = require_basePropertyDeep();
16054
16054
  var isKey = require_isKey();
16055
16055
  var toKey = require_toKey();
16056
- function property(path) {
16057
- return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
16056
+ function property(path2) {
16057
+ return isKey(path2) ? baseProperty(toKey(path2)) : basePropertyDeep(path2);
16058
16058
  }
16059
16059
  module2.exports = property;
16060
16060
  }
@@ -17152,15 +17152,15 @@ var require_route = __commonJS({
17152
17152
  };
17153
17153
  }
17154
17154
  function wrapConversion(toModel, graph) {
17155
- const path = [graph[toModel].parent, toModel];
17155
+ const path2 = [graph[toModel].parent, toModel];
17156
17156
  let fn = conversions[graph[toModel].parent][toModel];
17157
17157
  let cur = graph[toModel].parent;
17158
17158
  while (graph[cur].parent) {
17159
- path.unshift(graph[cur].parent);
17159
+ path2.unshift(graph[cur].parent);
17160
17160
  fn = link(conversions[graph[cur].parent][cur], fn);
17161
17161
  cur = graph[cur].parent;
17162
17162
  }
17163
- fn.conversion = path;
17163
+ fn.conversion = path2;
17164
17164
  return fn;
17165
17165
  }
17166
17166
  module2.exports = function(fromModel) {
@@ -20159,7 +20159,7 @@ var require_buffer_list = __commonJS({
20159
20159
  }
20160
20160
  }, {
20161
20161
  key: "join",
20162
- value: function join(s2) {
20162
+ value: function join2(s2) {
20163
20163
  if (this.length === 0)
20164
20164
  return "";
20165
20165
  var p = this.head;
@@ -32681,16 +32681,16 @@ var require_os_tmpdir = __commonJS({
32681
32681
  var isWindows = process.platform === "win32";
32682
32682
  var trailingSlashRe = isWindows ? /[^:]\\$/ : /.\/$/;
32683
32683
  module2.exports = function() {
32684
- var path;
32684
+ var path2;
32685
32685
  if (isWindows) {
32686
- path = process.env.TEMP || process.env.TMP || (process.env.SystemRoot || process.env.windir) + "\\temp";
32686
+ path2 = process.env.TEMP || process.env.TMP || (process.env.SystemRoot || process.env.windir) + "\\temp";
32687
32687
  } else {
32688
- path = process.env.TMPDIR || process.env.TMP || process.env.TEMP || "/tmp";
32688
+ path2 = process.env.TMPDIR || process.env.TMP || process.env.TEMP || "/tmp";
32689
32689
  }
32690
- if (trailingSlashRe.test(path)) {
32691
- path = path.slice(0, -1);
32690
+ if (trailingSlashRe.test(path2)) {
32691
+ path2 = path2.slice(0, -1);
32692
32692
  }
32693
- return path;
32693
+ return path2;
32694
32694
  };
32695
32695
  }
32696
32696
  });
@@ -32700,7 +32700,7 @@ var require_tmp = __commonJS({
32700
32700
  "node_modules/tmp/lib/tmp.js"(exports2, module2) {
32701
32701
  "use strict";
32702
32702
  var fs3 = require("fs");
32703
- var path = require("path");
32703
+ var path2 = require("path");
32704
32704
  var crypto3 = require("crypto");
32705
32705
  var osTmpDir = require_os_tmpdir();
32706
32706
  var _c = process.binding("constants");
@@ -32742,7 +32742,7 @@ var require_tmp = __commonJS({
32742
32742
  }
32743
32743
  function _generateTmpName(opts) {
32744
32744
  if (opts.name) {
32745
- return path.join(opts.dir || tmpDir, opts.name);
32745
+ return path2.join(opts.dir || tmpDir, opts.name);
32746
32746
  }
32747
32747
  if (opts.template) {
32748
32748
  return opts.template.replace(TEMPLATE_PATTERN, _randomChars(6));
@@ -32753,7 +32753,7 @@ var require_tmp = __commonJS({
32753
32753
  _randomChars(12),
32754
32754
  opts.postfix || ""
32755
32755
  ].join("");
32756
- return path.join(opts.dir || tmpDir, name);
32756
+ return path2.join(opts.dir || tmpDir, name);
32757
32757
  }
32758
32758
  function tmpName(options, callback) {
32759
32759
  var args = _parseArguments(options, callback), opts = args[0], cb = args[1], tries = opts.name ? 1 : opts.tries || DEFAULT_TRIES;
@@ -32841,7 +32841,7 @@ var require_tmp = __commonJS({
32841
32841
  do {
32842
32842
  var dir2 = dirs.pop(), deferred = false, files = fs3.readdirSync(dir2);
32843
32843
  for (var i2 = 0, length = files.length; i2 < length; i2++) {
32844
- var file2 = path.join(dir2, files[i2]), stat2 = fs3.lstatSync(file2);
32844
+ var file2 = path2.join(dir2, files[i2]), stat2 = fs3.lstatSync(file2);
32845
32845
  if (stat2.isDirectory()) {
32846
32846
  if (!deferred) {
32847
32847
  deferred = true;
@@ -34377,14 +34377,14 @@ var require_baseSet = __commonJS({
34377
34377
  var isIndex = require_isIndex();
34378
34378
  var isObject = require_isObject();
34379
34379
  var toKey = require_toKey();
34380
- function baseSet(object, path, value, customizer) {
34380
+ function baseSet(object, path2, value, customizer) {
34381
34381
  if (!isObject(object)) {
34382
34382
  return object;
34383
34383
  }
34384
- path = castPath(path, object);
34385
- var index = -1, length = path.length, lastIndex = length - 1, nested = object;
34384
+ path2 = castPath(path2, object);
34385
+ var index = -1, length = path2.length, lastIndex = length - 1, nested = object;
34386
34386
  while (nested != null && ++index < length) {
34387
- var key = toKey(path[index]), newValue = value;
34387
+ var key = toKey(path2[index]), newValue = value;
34388
34388
  if (key === "__proto__" || key === "constructor" || key === "prototype") {
34389
34389
  return object;
34390
34390
  }
@@ -34392,7 +34392,7 @@ var require_baseSet = __commonJS({
34392
34392
  var objValue = nested[key];
34393
34393
  newValue = customizer ? customizer(objValue, key, nested) : void 0;
34394
34394
  if (newValue === void 0) {
34395
- newValue = isObject(objValue) ? objValue : isIndex(path[index + 1]) ? [] : {};
34395
+ newValue = isObject(objValue) ? objValue : isIndex(path2[index + 1]) ? [] : {};
34396
34396
  }
34397
34397
  }
34398
34398
  assignValue(nested, key, newValue);
@@ -34409,8 +34409,8 @@ var require_set = __commonJS({
34409
34409
  "node_modules/lodash/set.js"(exports2, module2) {
34410
34410
  "use strict";
34411
34411
  var baseSet = require_baseSet();
34412
- function set2(object, path, value) {
34413
- return object == null ? object : baseSet(object, path, value);
34412
+ function set2(object, path2, value) {
34413
+ return object == null ? object : baseSet(object, path2, value);
34414
34414
  }
34415
34415
  module2.exports = set2;
34416
34416
  }
@@ -34492,7 +34492,7 @@ var require_main2 = __commonJS({
34492
34492
  "node_modules/dotenv/lib/main.js"(exports2, module2) {
34493
34493
  "use strict";
34494
34494
  var fs3 = require("fs");
34495
- var path = require("path");
34495
+ var path2 = require("path");
34496
34496
  var os3 = require("os");
34497
34497
  var crypto3 = require("crypto");
34498
34498
  var packageJson = require_package();
@@ -34606,7 +34606,7 @@ var require_main2 = __commonJS({
34606
34606
  possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
34607
34607
  }
34608
34608
  } else {
34609
- possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
34609
+ possibleVaultPath = path2.resolve(process.cwd(), ".env.vault");
34610
34610
  }
34611
34611
  if (fs3.existsSync(possibleVaultPath)) {
34612
34612
  return possibleVaultPath;
@@ -34614,7 +34614,7 @@ var require_main2 = __commonJS({
34614
34614
  return null;
34615
34615
  }
34616
34616
  function _resolveHome(envPath) {
34617
- return envPath[0] === "~" ? path.join(os3.homedir(), envPath.slice(1)) : envPath;
34617
+ return envPath[0] === "~" ? path2.join(os3.homedir(), envPath.slice(1)) : envPath;
34618
34618
  }
34619
34619
  function _configVault(options) {
34620
34620
  _log("Loading env from encrypted .env.vault");
@@ -34627,7 +34627,7 @@ var require_main2 = __commonJS({
34627
34627
  return { parsed };
34628
34628
  }
34629
34629
  function configDotenv(options) {
34630
- const dotenvPath = path.resolve(process.cwd(), ".env");
34630
+ const dotenvPath = path2.resolve(process.cwd(), ".env");
34631
34631
  let encoding = "utf8";
34632
34632
  const debug = Boolean(options && options.debug);
34633
34633
  if (options && options.encoding) {
@@ -34650,13 +34650,13 @@ var require_main2 = __commonJS({
34650
34650
  }
34651
34651
  let lastError;
34652
34652
  const parsedAll = {};
34653
- for (const path2 of optionPaths) {
34653
+ for (const path3 of optionPaths) {
34654
34654
  try {
34655
- const parsed = DotenvModule.parse(fs3.readFileSync(path2, { encoding }));
34655
+ const parsed = DotenvModule.parse(fs3.readFileSync(path3, { encoding }));
34656
34656
  DotenvModule.populate(parsedAll, parsed, options);
34657
34657
  } catch (e2) {
34658
34658
  if (debug) {
34659
- _debug(`Failed to load ${path2} ${e2.message}`);
34659
+ _debug(`Failed to load ${path3} ${e2.message}`);
34660
34660
  }
34661
34661
  lastError = e2;
34662
34662
  }
@@ -39895,7 +39895,7 @@ var {
39895
39895
  } = import_index.default;
39896
39896
 
39897
39897
  // package.json
39898
- var version = "0.0.22";
39898
+ var version = "0.0.23";
39899
39899
 
39900
39900
  // src/lib/config/text.ts
39901
39901
  var CLI_DESCRIPTION = "GenLayer CLI is a development environment for the GenLayer ecosystem. It allows developers to interact with the protocol by creating accounts, sending transactions, and working with Intelligent Contracts by testing, debugging, and deploying them.";
@@ -42489,33 +42489,29 @@ var inquirer_default = inquirer;
42489
42489
 
42490
42490
  // src/lib/config/simulator.ts
42491
42491
  var DEFAULT_JSON_RPC_URL = "http://localhost:4000/api";
42492
- var DEFAULT_REPO_GH_URL = "git@github.com:yeagerai/genlayer-simulator.git";
42493
- var DEFAULT_CONFIG_SIMULATOR_COMMAND = (simulatorLocation) => ({
42494
- darwin: `cd ${simulatorLocation} && cp .env.example .env`,
42495
- win32: `cd /d ${simulatorLocation} && xcopy .env.example .env /Y`,
42496
- linux: `cd ${simulatorLocation} && cp .env.example .env`
42497
- });
42492
+ var DEFAULT_REPO_GH_URL = "https://github.com/yeagerai/genlayer-simulator.git";
42498
42493
  var DEFAULT_RUN_SIMULATOR_COMMAND = (simulatorLocation) => ({
42499
42494
  darwin: `osascript -e 'tell application "Terminal" to do script "cd ${simulatorLocation} && docker compose build && docker compose up"'`,
42500
- win32: `start cmd.exe /c "cd /d ${simulatorLocation} && docker compose build && docker compose up"`,
42495
+ win32: `start cmd.exe /c "cd /d ${simulatorLocation} && docker compose build && docker compose up && pause"`,
42501
42496
  linux: `x-terminal-emulator -e bash -c 'cd ${simulatorLocation} && docker compose build && docker compose up; echo "Press enter to exit"; read'`
42502
42497
  });
42503
- var DEFAULT_RUN_OLLAMA_COMMAND = (simulatorLocation) => ({
42504
- darwin: `osascript -e 'tell application "Terminal" to do script "cd ${simulatorLocation} && docker exec -it ollama ollama run llama2"'`,
42505
- win32: `start cmd.exe /k "cd /d ${simulatorLocation} && docker exec -it ollama ollama run llama2"`,
42506
- linux: `x-terminal-emulator -e bash -c 'cd ${simulatorLocation} && docker exec -it ollama ollama run llama2; echo "Press enter to exit"; read'`
42498
+ var DEFAULT_PULL_OLLAMA_COMMAND = (simulatorLocation) => ({
42499
+ darwin: `osascript -e 'tell application "Terminal" to do script "cd ${simulatorLocation} && docker exec ollama ollama pull llama2"'`,
42500
+ win32: `start cmd.exe /c "cd /d ${simulatorLocation} && docker exec ollama ollama pull llama2"`,
42501
+ linux: `x-terminal-emulator -e bash -c 'cd ${simulatorLocation} && docker exec ollama ollama pull llama2'`
42507
42502
  });
42508
42503
  var AVAILABLE_PLATFORMS = ["darwin", "win32", "linux"];
42509
42504
  var STARTING_TIMEOUT_WAIT_CYLCE = 2e3;
42510
42505
  var STARTING_TIMEOUT_ATTEMPTS = 120;
42511
42506
  var AI_PROVIDERS_CONFIG = {
42512
- ollama: { name: "Ollama", envVar: "ollama", cliOptionValue: "ollama" },
42513
- openai: { name: "OpenAI", envVar: "GENVMOPENAIKEY", cliOptionValue: "openai" }
42507
+ ollama: { name: "Ollama (This will download and run a local instance of Llama 2)", envVar: "ollama", cliOptionValue: "ollama" },
42508
+ openai: { name: "OpenAI (You will need to provide an OpenAI API key)", envVar: "GENVMOPENAIKEY", cliOptionValue: "openai" }
42514
42509
  };
42515
42510
 
42516
42511
  // src/lib/services/simulator.ts
42517
42512
  var fs2 = __toESM(require("fs"));
42518
42513
  var dotenv = __toESM(require_main2());
42514
+ var path = __toESM(require("path"));
42519
42515
 
42520
42516
  // node_modules/node-fetch/src/index.js
42521
42517
  var import_node_http2 = __toESM(require("http"), 1);
@@ -43958,14 +43954,20 @@ function getPlatform() {
43958
43954
 
43959
43955
  // src/lib/services/simulator.ts
43960
43956
  function getSimulatorLocation() {
43961
- return `${getHomeDirectory()}/genlayer-simulator`;
43957
+ return path.join(getHomeDirectory(), "genlayer-simulator");
43958
+ }
43959
+ function readEnvConfigValue(key) {
43960
+ const simulatorLocation = getSimulatorLocation();
43961
+ const envFilePath = path.join(simulatorLocation, ".env");
43962
+ const envConfig = dotenv.parse(fs2.readFileSync(envFilePath, "utf8"));
43963
+ return envConfig[key];
43962
43964
  }
43963
43965
  function sleep(millliseconds) {
43964
43966
  return new Promise((resolve) => setTimeout(resolve, millliseconds));
43965
43967
  }
43966
43968
  function addConfigToEnvFile(newConfig) {
43967
43969
  const simulatorLocation = getSimulatorLocation();
43968
- const envFilePath = `${simulatorLocation}/.env`;
43970
+ const envFilePath = path.join(simulatorLocation, ".env");
43969
43971
  fs2.writeFileSync(`${envFilePath}.bak`, fs2.readFileSync(envFilePath));
43970
43972
  const envConfig = dotenv.parse(fs2.readFileSync(envFilePath, "utf8"));
43971
43973
  Object.keys(newConfig).forEach((key) => {
@@ -44021,16 +44023,16 @@ function downloadSimulator() {
44021
44023
  function updateSimulator() {
44022
44024
  return __async(this, null, function* () {
44023
44025
  const simulatorLocation = getSimulatorLocation();
44024
- const gitCommand = `cd ${simulatorLocation} && git pull`;
44026
+ const gitCommand = `git -C "${simulatorLocation}" pull`;
44025
44027
  const cmdsByPlatform = { darwin: gitCommand, win32: gitCommand, linux: gitCommand };
44026
44028
  yield executeCommand(cmdsByPlatform, "git");
44027
44029
  return { wasInstalled: false };
44028
44030
  });
44029
44031
  }
44030
- function runOllamaModel() {
44032
+ function pullOllamaModel() {
44031
44033
  return __async(this, null, function* () {
44032
44034
  const simulatorLocation = getSimulatorLocation();
44033
- const cmdsByPlatform = DEFAULT_RUN_OLLAMA_COMMAND(simulatorLocation);
44035
+ const cmdsByPlatform = DEFAULT_PULL_OLLAMA_COMMAND(simulatorLocation);
44034
44036
  yield executeCommandInNewTerminal(cmdsByPlatform);
44035
44037
  return true;
44036
44038
  });
@@ -44038,8 +44040,9 @@ function runOllamaModel() {
44038
44040
  function configSimulator(newConfig) {
44039
44041
  return __async(this, null, function* () {
44040
44042
  const simulatorLocation = getSimulatorLocation();
44041
- const commandsByPlatform = DEFAULT_CONFIG_SIMULATOR_COMMAND(simulatorLocation);
44042
- yield executeCommand(commandsByPlatform, "copy (cp)");
44043
+ const envExample = path.join(simulatorLocation, ".env.example");
44044
+ const envFilePath = path.join(simulatorLocation, ".env");
44045
+ fs2.copyFileSync(envExample, envFilePath);
44043
44046
  addConfigToEnvFile(newConfig);
44044
44047
  return true;
44045
44048
  });
@@ -44051,7 +44054,7 @@ function runSimulator() {
44051
44054
  }
44052
44055
  function waitForSimulatorToBeReady() {
44053
44056
  return __async(this, arguments, function* (retries = STARTING_TIMEOUT_ATTEMPTS) {
44054
- console.log("Waiting for Simulator to be ready...:");
44057
+ console.log("Waiting for the simulator to start up...");
44055
44058
  try {
44056
44059
  const response = yield rpcClient.request({ method: "ping", params: [] });
44057
44060
  if (response && response.result.status === "OK") {
@@ -44124,7 +44127,7 @@ function initAction(options) {
44124
44127
  {
44125
44128
  type: "confirm",
44126
44129
  name: "confirmDownload",
44127
- message: `This action is going to download the GenLayer Simulator from GitHub. Do you want to continue?`,
44130
+ message: `This action is going to download the GenLayer Simulator from GitHub into "${getSimulatorLocation()}". Do you want to continue?`,
44128
44131
  default: true
44129
44132
  }
44130
44133
  ]);
@@ -44211,7 +44214,8 @@ function initAction(options) {
44211
44214
  return;
44212
44215
  }
44213
44216
  if (selectedLlmProviders.includes("ollama")) {
44214
- runOllamaModel();
44217
+ console.log("Pulling llama2 from Ollama...");
44218
+ yield pullOllamaModel();
44215
44219
  }
44216
44220
  console.log("Initializing the database...");
44217
44221
  try {
@@ -44234,7 +44238,8 @@ function initAction(options) {
44234
44238
  console.error(error);
44235
44239
  return;
44236
44240
  }
44237
- console.log("GenLayer simulator initialized successfully!");
44241
+ const frontendPort = readEnvConfigValue("FRONTEND_PORT");
44242
+ console.log(`GenLayer simulator initialized successfully! Go to http://localhost:${frontendPort} in your browser to access it.`);
44238
44243
  });
44239
44244
  }
44240
44245
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genlayer",
3
- "version": "0.0.22",
3
+ "version": "0.0.23",
4
4
  "description": "GenLayer Command Line Tool",
5
5
  "main": "src/index.ts",
6
6
  "bin": {
@@ -12,8 +12,10 @@ import {
12
12
  clearDatabaseTables,
13
13
  createRandomValidators,
14
14
  deleteAllValidators,
15
- runOllamaModel,
15
+ pullOllamaModel,
16
16
  getAiProvidersOptions,
17
+ getSimulatorLocation,
18
+ readEnvConfigValue,
17
19
  } from "@/lib/services/simulator";
18
20
  export interface InitActionOptions {
19
21
  numValidators: number;
@@ -53,7 +55,7 @@ export async function initAction(options: InitActionOptions) {
53
55
  {
54
56
  type: "confirm",
55
57
  name: "confirmDownload",
56
- message: `This action is going to download the GenLayer Simulator from GitHub. Do you want to continue?`,
58
+ message: `This action is going to download the GenLayer Simulator from GitHub into "${getSimulatorLocation()}". Do you want to continue?`,
57
59
  default: true,
58
60
  },
59
61
  ]);
@@ -156,7 +158,8 @@ export async function initAction(options: InitActionOptions) {
156
158
 
157
159
  // Ollama doesn't need changes in configuration, we just run it
158
160
  if (selectedLlmProviders.includes("ollama")) {
159
- runOllamaModel();
161
+ console.log("Pulling llama2 from Ollama...")
162
+ await pullOllamaModel();
160
163
  }
161
164
 
162
165
  // Initialize the database
@@ -187,6 +190,7 @@ export async function initAction(options: InitActionOptions) {
187
190
  console.error(error);
188
191
  return;
189
192
  }
190
-
191
- console.log("GenLayer simulator initialized successfully!");
193
+
194
+ const frontendPort = readEnvConfigValue('FRONTEND_PORT');
195
+ console.log(`GenLayer simulator initialized successfully! Go to http://localhost:${frontendPort} in your browser to access it.`);
192
196
  }
@@ -1,19 +1,14 @@
1
1
  export const DEFAULT_JSON_RPC_URL = "http://localhost:4000/api";
2
- export const DEFAULT_REPO_GH_URL = "git@github.com:yeagerai/genlayer-simulator.git";
3
- export const DEFAULT_CONFIG_SIMULATOR_COMMAND = (simulatorLocation: string) => ({
4
- darwin: `cd ${simulatorLocation} && cp .env.example .env`,
5
- win32: `cd /d ${simulatorLocation} && xcopy .env.example .env /Y`,
6
- linux: `cd ${simulatorLocation} && cp .env.example .env`,
7
- });
2
+ export const DEFAULT_REPO_GH_URL = "https://github.com/yeagerai/genlayer-simulator.git";
8
3
  export const DEFAULT_RUN_SIMULATOR_COMMAND = (simulatorLocation: string) => ({
9
4
  darwin: `osascript -e 'tell application "Terminal" to do script "cd ${simulatorLocation} && docker compose build && docker compose up"'`,
10
- win32: `start cmd.exe /c "cd /d ${simulatorLocation} && docker compose build && docker compose up"`,
5
+ win32: `start cmd.exe /c "cd /d ${simulatorLocation} && docker compose build && docker compose up && pause"`,
11
6
  linux: `x-terminal-emulator -e bash -c 'cd ${simulatorLocation} && docker compose build && docker compose up; echo "Press enter to exit"; read'`,
12
7
  });
13
- export const DEFAULT_RUN_OLLAMA_COMMAND = (simulatorLocation: string) => ({
14
- darwin: `osascript -e 'tell application "Terminal" to do script "cd ${simulatorLocation} && docker exec -it ollama ollama run llama2"'`,
15
- win32: `start cmd.exe /k "cd /d ${simulatorLocation} && docker exec -it ollama ollama run llama2"`,
16
- linux: `x-terminal-emulator -e bash -c 'cd ${simulatorLocation} && docker exec -it ollama ollama run llama2; echo "Press enter to exit"; read'`,
8
+ export const DEFAULT_PULL_OLLAMA_COMMAND = (simulatorLocation: string) => ({
9
+ darwin: `osascript -e 'tell application "Terminal" to do script "cd ${simulatorLocation} && docker exec ollama ollama pull llama2"'`,
10
+ win32: `start cmd.exe /c "cd /d ${simulatorLocation} && docker exec ollama ollama pull llama2"`,
11
+ linux: `x-terminal-emulator -e bash -c 'cd ${simulatorLocation} && docker exec ollama ollama pull llama2'`,
17
12
  });
18
13
  export const AVAILABLE_PLATFORMS = ["darwin", "win32", "linux"] as const;
19
14
  export type RunningPlatform = (typeof AVAILABLE_PLATFORMS)[number];
@@ -27,6 +22,6 @@ export type AiProvidersConfigType = {
27
22
  };
28
23
 
29
24
  export const AI_PROVIDERS_CONFIG: AiProvidersConfigType = {
30
- ollama: {name: "Ollama", envVar: "ollama", cliOptionValue: "ollama"},
31
- openai: {name: "OpenAI", envVar: "GENVMOPENAIKEY", cliOptionValue: "openai"},
25
+ ollama: {name: "Ollama (This will download and run a local instance of Llama 2)", envVar: "ollama", cliOptionValue: "ollama"},
26
+ openai: {name: "OpenAI (You will need to provide an OpenAI API key)", envVar: "GENVMOPENAIKEY", cliOptionValue: "openai"},
32
27
  };
@@ -1,12 +1,12 @@
1
1
  import * as fs from "fs";
2
2
  import * as dotenv from "dotenv";
3
+ import * as path from "path";
3
4
 
4
5
  import {rpcClient} from "@/lib/clients/jsonRpcClient";
5
6
  import {
6
7
  DEFAULT_REPO_GH_URL,
7
8
  DEFAULT_RUN_SIMULATOR_COMMAND,
8
- DEFAULT_CONFIG_SIMULATOR_COMMAND,
9
- DEFAULT_RUN_OLLAMA_COMMAND,
9
+ DEFAULT_PULL_OLLAMA_COMMAND,
10
10
  STARTING_TIMEOUT_WAIT_CYLCE,
11
11
  STARTING_TIMEOUT_ATTEMPTS,
12
12
  AI_PROVIDERS_CONFIG,
@@ -20,8 +20,16 @@ import {
20
20
  import {MissingRequirementError} from "../errors/missingRequirement";
21
21
 
22
22
  // Private helper functions
23
- function getSimulatorLocation(): string {
24
- return `${getHomeDirectory()}/genlayer-simulator`;
23
+ export function getSimulatorLocation(): string {
24
+ return path.join(getHomeDirectory(), 'genlayer-simulator');
25
+ }
26
+
27
+ export function readEnvConfigValue(key: string): string {
28
+ const simulatorLocation = getSimulatorLocation();
29
+ const envFilePath = path.join(simulatorLocation, '.env');
30
+ // Transform the config string to object
31
+ const envConfig = dotenv.parse(fs.readFileSync(envFilePath, "utf8"));
32
+ return envConfig[key];
25
33
  }
26
34
 
27
35
  function sleep(millliseconds: number): Promise<void> {
@@ -30,7 +38,7 @@ function sleep(millliseconds: number): Promise<void> {
30
38
 
31
39
  function addConfigToEnvFile(newConfig: Record<string, string>): void {
32
40
  const simulatorLocation = getSimulatorLocation();
33
- const envFilePath = `${simulatorLocation}/.env`;
41
+ const envFilePath = path.join(simulatorLocation, '.env');
34
42
 
35
43
  // Create a backup of the original .env file
36
44
  fs.writeFileSync(`${envFilePath}.bak`, fs.readFileSync(envFilePath));
@@ -102,23 +110,24 @@ export async function downloadSimulator(): Promise<DownloadSimulatorResultType>
102
110
 
103
111
  export async function updateSimulator(): Promise<DownloadSimulatorResultType> {
104
112
  const simulatorLocation = getSimulatorLocation();
105
- const gitCommand = `cd ${simulatorLocation} && git pull`;
113
+ const gitCommand = `git -C "${simulatorLocation}" pull`;
106
114
  const cmdsByPlatform = {darwin: gitCommand, win32: gitCommand, linux: gitCommand};
107
115
  await executeCommand(cmdsByPlatform, "git");
108
116
  return {wasInstalled: false};
109
117
  }
110
118
 
111
- export async function runOllamaModel(): Promise<boolean> {
119
+ export async function pullOllamaModel(): Promise<boolean> {
112
120
  const simulatorLocation = getSimulatorLocation();
113
- const cmdsByPlatform = DEFAULT_RUN_OLLAMA_COMMAND(simulatorLocation);
121
+ const cmdsByPlatform = DEFAULT_PULL_OLLAMA_COMMAND(simulatorLocation);
114
122
  await executeCommandInNewTerminal(cmdsByPlatform);
115
123
  return true;
116
124
  }
117
125
 
118
126
  export async function configSimulator(newConfig: Record<string, string>): Promise<boolean> {
119
127
  const simulatorLocation = getSimulatorLocation();
120
- const commandsByPlatform = DEFAULT_CONFIG_SIMULATOR_COMMAND(simulatorLocation);
121
- await executeCommand(commandsByPlatform, "copy (cp)");
128
+ const envExample = path.join(simulatorLocation, '.env.example');
129
+ const envFilePath = path.join(simulatorLocation, '.env');
130
+ fs.copyFileSync(envExample, envFilePath);
122
131
  addConfigToEnvFile(newConfig);
123
132
  return true;
124
133
  }
@@ -137,7 +146,7 @@ type WaitForSimulatorToBeReadyResultType = {
137
146
  export async function waitForSimulatorToBeReady(
138
147
  retries: number = STARTING_TIMEOUT_ATTEMPTS,
139
148
  ): Promise<WaitForSimulatorToBeReadyResultType> {
140
- console.log("Waiting for Simulator to be ready...:");
149
+ console.log("Waiting for the simulator to start up...");
141
150
  try {
142
151
  const response = await rpcClient.request({method: "ping", params: []});
143
152
  if (response && response.result.status === "OK") {