@dainprotocol/cli 1.0.9 → 1.0.11

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.
@@ -139,11 +139,15 @@ function dev(options) {
139
139
  if (proxyServer) {
140
140
  proxyServer.close(function () {
141
141
  (0, utils_1.logInfo)('Proxy server closed.');
142
- process.exit(0);
142
+ setTimeout(function () {
143
+ process.exit(0);
144
+ }, 500);
143
145
  });
144
146
  }
145
147
  else {
146
- process.exit(0);
148
+ setTimeout(function () {
149
+ process.exit(0);
150
+ }, 500);
147
151
  }
148
152
  });
149
153
  process.on('SIGTERM', function () {
@@ -151,11 +155,15 @@ function dev(options) {
151
155
  if (proxyServer) {
152
156
  proxyServer.close(function () {
153
157
  (0, utils_1.logInfo)('Proxy server closed.');
154
- process.exit(0);
158
+ setTimeout(function () {
159
+ process.exit(0);
160
+ }, 500);
155
161
  });
156
162
  }
157
163
  else {
158
- process.exit(0);
164
+ setTimeout(function () {
165
+ process.exit(0);
166
+ }, 500);
159
167
  }
160
168
  });
161
169
  // Handle uncaught exceptions and unhandled rejections
@@ -164,14 +172,18 @@ function dev(options) {
164
172
  cleanup();
165
173
  if (proxyServer)
166
174
  proxyServer.close();
167
- process.exit(1);
175
+ setTimeout(function () {
176
+ process.exit(1);
177
+ }, 500);
168
178
  });
169
179
  process.on('unhandledRejection', function (reason, promise) {
170
180
  (0, utils_1.logError)('Unhandled Rejection at:', promise + '\n\nreason:' + reason);
171
181
  cleanup();
172
182
  if (proxyServer)
173
183
  proxyServer.close();
174
- process.exit(1);
184
+ setTimeout(function () {
185
+ process.exit(1);
186
+ }, 500);
175
187
  });
176
188
  return [3 /*break*/, 5];
177
189
  case 4:
@@ -180,7 +192,9 @@ function dev(options) {
180
192
  cleanup();
181
193
  if (proxyServer)
182
194
  proxyServer.close();
183
- process.exit(1);
195
+ setTimeout(function () {
196
+ process.exit(1);
197
+ }, 500);
184
198
  return [3 /*break*/, 5];
185
199
  case 5: return [2 /*return*/];
186
200
  }
@@ -1,8 +1,10 @@
1
+ //File: example/example-node.ts
2
+
1
3
  import { z } from "zod";
2
4
 
3
- import { DAINService } from "@dainprotocol/service-sdk";
5
+ import {defineDAINService, ToolConfig, ServiceConfig, ToolboxConfig} from "@dainprotocol/service-sdk";
4
6
 
5
- const getWeatherConfig: DAINService.ToolConfig = {
7
+ const getWeatherConfig: ToolConfig = {
6
8
  id: "get-weather",
7
9
  name: "Get Weather",
8
10
  description: "Fetches current weather for a city",
@@ -21,7 +23,12 @@ const getWeatherConfig: DAINService.ToolConfig = {
21
23
  .describe("Weather information for the requested city"),
22
24
  pricing: { pricePerUse: 0.01, currency: "USD" },
23
25
  handler: async ({ city }, agentInfo) => {
26
+
27
+
24
28
  console.log(`Agent ${agentInfo.agentId} requested weather for ${city}`);
29
+
30
+
31
+
25
32
  return {
26
33
  text: `The current weather in ${city} is 22°C and Sunny`,
27
34
  data: { temperature: 22, condition: "Sunny" },
@@ -33,7 +40,7 @@ const getWeatherConfig: DAINService.ToolConfig = {
33
40
  },
34
41
  };
35
42
 
36
- const getWeatherForecastConfig: DAINService.ToolConfig = {
43
+ const getWeatherForecastConfig: ToolConfig = {
37
44
  id: "get-weather-forecast",
38
45
  name: "Get Weather Forecast",
39
46
  description: "Fetches a 5-day weather forecast for a city",
@@ -70,7 +77,7 @@ const getWeatherForecastConfig: DAINService.ToolConfig = {
70
77
  },
71
78
  };
72
79
 
73
- const getAirQualityConfig: DAINService.ToolConfig = {
80
+ const getAirQualityConfig: ToolConfig = {
74
81
  id: "get-air-quality",
75
82
  name: "Get Air Quality",
76
83
  description: "Fetches air quality information for a city",
@@ -99,7 +106,7 @@ const getAirQualityConfig: DAINService.ToolConfig = {
99
106
  },
100
107
  };
101
108
 
102
- const getHistoricalWeatherConfig: DAINService.ToolConfig = {
109
+ const getHistoricalWeatherConfig: ToolConfig = {
103
110
  id: "get-historical-weather",
104
111
  name: "Get Historical Weather",
105
112
  description: "Retrieves historical weather data for a specific date and city",
@@ -129,7 +136,7 @@ const getHistoricalWeatherConfig: DAINService.ToolConfig = {
129
136
  },
130
137
  };
131
138
 
132
- const weatherServiceConfig: DAINService.ServiceConfig = {
139
+ const weatherServiceConfig: ServiceConfig = {
133
140
  id: "weather-service",
134
141
  name: "Weather Service",
135
142
  description: "Provides comprehensive weather information",
@@ -152,7 +159,7 @@ const weatherServiceConfig: DAINService.ServiceConfig = {
152
159
  ],
153
160
  };
154
161
 
155
- const weatherToolboxConfig: DAINService.ToolboxConfig = {
162
+ const weatherToolboxConfig: ToolboxConfig = {
156
163
  id: "weather-toolbox",
157
164
  name: "Weather Toolbox",
158
165
  description: "Collection of weather-related tools",
@@ -170,7 +177,7 @@ const weatherToolboxConfig: DAINService.ToolboxConfig = {
170
177
  "Use these tools for various weather-related tasks and analyses",
171
178
  };
172
179
 
173
- const dainService = DAINService.defineDAINService({
180
+ const dainService = defineDAINService({
174
181
  metadata: {
175
182
  title: "Comprehensive Weather DAIN Service",
176
183
  description:
@@ -181,7 +188,7 @@ const dainService = DAINService.defineDAINService({
181
188
  },
182
189
  identity: {
183
190
  apiKey:
184
- "sk_agent_3_0_49bhyNKMYYH3TtjqycgKQCBhUuTu4bnYvKzStv3bBmKaY55LMBmLVQR1wAtkizdGPM3wBAA2X6rfYpfpEuisx5Cc",
191
+ process.env.DAIN_API_KEY,
185
192
  },
186
193
  services: [weatherServiceConfig],
187
194
  tools: [
package/dist/utils.js CHANGED
@@ -87,7 +87,7 @@ function getDainConfig(configFile) {
87
87
  config["version"] = config["version"] || "1.0.0";
88
88
  config["out-dir"] = config["out-dir"] || "dist"; // Default to 'dist' if not specified
89
89
  config["tunnel-base-url"] =
90
- config["tunnel-base-url"] || "wss:///devtunnel.dain-local.com"; // Default value if not specified
90
+ config["tunnel-base-url"] || "wss:///tunnel.dain-local.com"; // Default value if not specified
91
91
  // Handle API key
92
92
  if (!config["api-key"] || config["api-key"] === "env" || config["api-key"] === "MUST PUT IN .env.development as DAIN_API_KEY=YOUR_API_KEY") {
93
93
  config["api-key"] = process.env.DAIN_API_KEY;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dainprotocol/cli",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "CLI for Dain Protocol",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -1,8 +1,10 @@
1
+ //File: example/example-node.ts
2
+
1
3
  import { z } from "zod";
2
4
 
3
- import { DAINService } from "@dainprotocol/service-sdk";
5
+ import {defineDAINService, ToolConfig, ServiceConfig, ToolboxConfig} from "@dainprotocol/service-sdk";
4
6
 
5
- const getWeatherConfig: DAINService.ToolConfig = {
7
+ const getWeatherConfig: ToolConfig = {
6
8
  id: "get-weather",
7
9
  name: "Get Weather",
8
10
  description: "Fetches current weather for a city",
@@ -21,7 +23,12 @@ const getWeatherConfig: DAINService.ToolConfig = {
21
23
  .describe("Weather information for the requested city"),
22
24
  pricing: { pricePerUse: 0.01, currency: "USD" },
23
25
  handler: async ({ city }, agentInfo) => {
26
+
27
+
24
28
  console.log(`Agent ${agentInfo.agentId} requested weather for ${city}`);
29
+
30
+
31
+
25
32
  return {
26
33
  text: `The current weather in ${city} is 22°C and Sunny`,
27
34
  data: { temperature: 22, condition: "Sunny" },
@@ -33,7 +40,7 @@ const getWeatherConfig: DAINService.ToolConfig = {
33
40
  },
34
41
  };
35
42
 
36
- const getWeatherForecastConfig: DAINService.ToolConfig = {
43
+ const getWeatherForecastConfig: ToolConfig = {
37
44
  id: "get-weather-forecast",
38
45
  name: "Get Weather Forecast",
39
46
  description: "Fetches a 5-day weather forecast for a city",
@@ -70,7 +77,7 @@ const getWeatherForecastConfig: DAINService.ToolConfig = {
70
77
  },
71
78
  };
72
79
 
73
- const getAirQualityConfig: DAINService.ToolConfig = {
80
+ const getAirQualityConfig: ToolConfig = {
74
81
  id: "get-air-quality",
75
82
  name: "Get Air Quality",
76
83
  description: "Fetches air quality information for a city",
@@ -99,7 +106,7 @@ const getAirQualityConfig: DAINService.ToolConfig = {
99
106
  },
100
107
  };
101
108
 
102
- const getHistoricalWeatherConfig: DAINService.ToolConfig = {
109
+ const getHistoricalWeatherConfig: ToolConfig = {
103
110
  id: "get-historical-weather",
104
111
  name: "Get Historical Weather",
105
112
  description: "Retrieves historical weather data for a specific date and city",
@@ -129,7 +136,7 @@ const getHistoricalWeatherConfig: DAINService.ToolConfig = {
129
136
  },
130
137
  };
131
138
 
132
- const weatherServiceConfig: DAINService.ServiceConfig = {
139
+ const weatherServiceConfig: ServiceConfig = {
133
140
  id: "weather-service",
134
141
  name: "Weather Service",
135
142
  description: "Provides comprehensive weather information",
@@ -152,7 +159,7 @@ const weatherServiceConfig: DAINService.ServiceConfig = {
152
159
  ],
153
160
  };
154
161
 
155
- const weatherToolboxConfig: DAINService.ToolboxConfig = {
162
+ const weatherToolboxConfig: ToolboxConfig = {
156
163
  id: "weather-toolbox",
157
164
  name: "Weather Toolbox",
158
165
  description: "Collection of weather-related tools",
@@ -170,7 +177,7 @@ const weatherToolboxConfig: DAINService.ToolboxConfig = {
170
177
  "Use these tools for various weather-related tasks and analyses",
171
178
  };
172
179
 
173
- const dainService = DAINService.defineDAINService({
180
+ const dainService = defineDAINService({
174
181
  metadata: {
175
182
  title: "Comprehensive Weather DAIN Service",
176
183
  description:
@@ -181,7 +188,7 @@ const dainService = DAINService.defineDAINService({
181
188
  },
182
189
  identity: {
183
190
  apiKey:
184
- "sk_agent_3_0_49bhyNKMYYH3TtjqycgKQCBhUuTu4bnYvKzStv3bBmKaY55LMBmLVQR1wAtkizdGPM3wBAA2X6rfYpfpEuisx5Cc",
191
+ process.env.DAIN_API_KEY,
185
192
  },
186
193
  services: [weatherServiceConfig],
187
194
  tools: [