@dainprotocol/cli 1.0.29 → 1.0.31

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.
@@ -148,6 +148,10 @@ function build(options) {
148
148
  case 11:
149
149
  spinner.succeed('Build completed successfully.');
150
150
  (0, utils_1.logSuccess)("Project built and ready for ".concat(runtime, " runtime in ").concat(options.watch ? dainDir : outDir, "."));
151
+ // Explicitly exit with success if not in watch mode
152
+ if (!options.watch) {
153
+ process.exit(0);
154
+ }
151
155
  return [3 /*break*/, 13];
152
156
  case 12:
153
157
  error_1 = _a.sent();
@@ -63,30 +63,34 @@ function config(action, key, value) {
63
63
  else {
64
64
  console.log(JSON.stringify(config_1, null, 2));
65
65
  }
66
+ process.exit(0);
66
67
  return [3 /*break*/, 6];
67
68
  case 3:
68
69
  if (!(action === 'edit' && key && value)) return [3 /*break*/, 5];
69
70
  if (key === 'runtime' && !['node', 'workers'].includes(value)) {
70
71
  (0, utils_1.logError)('Invalid runtime. Use "node" or "workers"');
71
- return [2 /*return*/];
72
+ process.exit(1);
72
73
  }
73
74
  if (key === 'platform-base-url' && !value.startsWith('http')) {
74
75
  (0, utils_1.logError)('Invalid platform-base-url. It should start with http:// or https://');
75
- return [2 /*return*/];
76
+ process.exit(1);
76
77
  }
77
78
  config_1[key] = value;
78
79
  return [4 /*yield*/, fs_extra_1.default.writeJSON(configPath, config_1, { spaces: 2 })];
79
80
  case 4:
80
81
  _a.sent();
81
82
  (0, utils_1.logSuccess)("Updated ".concat(key, " to ").concat(value));
83
+ process.exit(0);
82
84
  return [3 /*break*/, 6];
83
85
  case 5:
84
86
  (0, utils_1.logError)('Invalid command. Use "view" or "edit <key> <value>"');
87
+ process.exit(1);
85
88
  _a.label = 6;
86
89
  case 6: return [3 /*break*/, 8];
87
90
  case 7:
88
91
  error_1 = _a.sent();
89
92
  (0, utils_1.logError)('Error accessing configuration', error_1);
93
+ process.exit(1);
90
94
  return [3 /*break*/, 8];
91
95
  case 8: return [2 /*return*/];
92
96
  }
@@ -53,6 +53,7 @@ function deploy(options) {
53
53
  switch (_a.label) {
54
54
  case 0:
55
55
  config = (0, utils_1.getDainConfig)(options.config);
56
+ // disable for now only availible for internal testing for now
56
57
  if (config.runtime !== 'workers') {
57
58
  (0, utils_1.logError)("Deployment is only supported for 'workers' runtime.");
58
59
  process.exit(1);
@@ -6,15 +6,18 @@ var utils_1 = require("../utils");
6
6
  function start(options) {
7
7
  process.env.PORT = options.port;
8
8
  var command = "node ".concat((0, utils_1.getDainConfig)()['main-file']);
9
- (0, child_process_1.exec)(command, function (error, stdout, stderr) {
10
- if (error) {
11
- console.error("Error: ".concat(error.message));
12
- return;
13
- }
14
- if (stderr) {
15
- console.error("Stderr: ".concat(stderr));
16
- return;
9
+ var child = (0, child_process_1.spawn)('node', [(0, utils_1.getDainConfig)()['main-file']], {
10
+ stdio: 'inherit' // This pipes stdout/stderr directly to parent process
11
+ });
12
+ child.on('error', function (error) {
13
+ console.error("Error: ".concat(error.message));
14
+ process.exit(1);
15
+ });
16
+ child.on('exit', function (code) {
17
+ if (code !== 0) {
18
+ console.error("Process exited with code ".concat(code));
19
+ process.exit(code || 1);
17
20
  }
18
- console.log("Stdout: ".concat(stdout));
21
+ process.exit(0);
19
22
  });
20
23
  }
@@ -30,7 +30,7 @@ const getWeatherConfig: ToolConfig = {
30
30
  pricing: { pricePerUse: 0, currency: "USD" },
31
31
  handler: async ({ latitude, longitude }, agentInfo) => {
32
32
  console.log(
33
- `Agent ${agentInfo.agentId} requested weather at ${latitude},${longitude}`
33
+ `User / Agent ${agentInfo.id} requested weather at ${latitude},${longitude}`
34
34
  );
35
35
 
36
36
  const response = await axios.get(
@@ -75,7 +75,7 @@ const getWeatherForecastConfig: ToolConfig = {
75
75
  pricing: { pricePerUse: 0, currency: "USD" },
76
76
  handler: async ({ latitude, longitude }, agentInfo) => {
77
77
  console.log(
78
- `Agent ${agentInfo.agentId} requested forecast at ${latitude},${longitude}`
78
+ `User / Agent ${agentInfo.id} requested forecast at ${latitude},${longitude}`
79
79
  );
80
80
 
81
81
  const response = await axios.get(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dainprotocol/cli",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "description": "CLI for Dain Protocol",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -30,7 +30,7 @@ const getWeatherConfig: ToolConfig = {
30
30
  pricing: { pricePerUse: 0, currency: "USD" },
31
31
  handler: async ({ latitude, longitude }, agentInfo) => {
32
32
  console.log(
33
- `Agent ${agentInfo.agentId} requested weather at ${latitude},${longitude}`
33
+ `User / Agent ${agentInfo.id} requested weather at ${latitude},${longitude}`
34
34
  );
35
35
 
36
36
  const response = await axios.get(
@@ -75,7 +75,7 @@ const getWeatherForecastConfig: ToolConfig = {
75
75
  pricing: { pricePerUse: 0, currency: "USD" },
76
76
  handler: async ({ latitude, longitude }, agentInfo) => {
77
77
  console.log(
78
- `Agent ${agentInfo.agentId} requested forecast at ${latitude},${longitude}`
78
+ `User / Agent ${agentInfo.id} requested forecast at ${latitude},${longitude}`
79
79
  );
80
80
 
81
81
  const response = await axios.get(