@dainprotocol/cli 1.0.45 → 1.0.46
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/commands/deploy.js +10 -5
- package/dist/index.js +0 -0
- package/dist/templates/default/.env.development +1 -0
- package/dist/templates/default/dain.json +11 -0
- package/dist/templates/default/package.json +23 -0
- package/dist/templates/default/src/index.ts +119 -0
- package/dist/templates/default/tsconfig.json +8 -0
- package/package.json +3 -3
- package/templates/default/package.json +2 -2
- package/dist/fsevents-X6WP4TKM.node +0 -0
- package/dist/index.js.map +0 -7
- package/templates/default/pnpm-lock.yaml +0 -3676
package/dist/commands/deploy.js
CHANGED
|
@@ -60,7 +60,7 @@ function deploy(options) {
|
|
|
60
60
|
deployPath = "".concat(basePath).concat(START_DEPLOY_URI);
|
|
61
61
|
_a.label = 1;
|
|
62
62
|
case 1:
|
|
63
|
-
_a.trys.push([1,
|
|
63
|
+
_a.trys.push([1, 7, , 8]);
|
|
64
64
|
return [4 /*yield*/, loadAndValidateEnvVariables()];
|
|
65
65
|
case 2:
|
|
66
66
|
envArray = _a.sent();
|
|
@@ -81,15 +81,20 @@ function deploy(options) {
|
|
|
81
81
|
spinner.succeed('Deployment completed successfully.');
|
|
82
82
|
spinner.info('You can access logs using `dain logs -w` command.');
|
|
83
83
|
console.log('-----------------------');
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
return [4 /*yield*/, fetch(result.service.url, {
|
|
85
|
+
method: 'GET',
|
|
86
|
+
})];
|
|
86
87
|
case 6:
|
|
88
|
+
_a.sent();
|
|
89
|
+
process.exit(0);
|
|
90
|
+
return [3 /*break*/, 8];
|
|
91
|
+
case 7:
|
|
87
92
|
error_1 = _a.sent();
|
|
88
93
|
spinner.fail('Deployment failed.');
|
|
89
94
|
(0, utils_1.logError)('Error during deployment: ', error_1);
|
|
90
95
|
process.exit(1);
|
|
91
|
-
return [3 /*break*/,
|
|
92
|
-
case
|
|
96
|
+
return [3 /*break*/, 8];
|
|
97
|
+
case 8: return [2 /*return*/];
|
|
93
98
|
}
|
|
94
99
|
});
|
|
95
100
|
});
|
package/dist/index.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
DAIN_API_KEY=NEED_TO_BE_SET
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"project-id": "",
|
|
3
|
+
"api-key": "MUST PUT IN .env.development as DAIN_API_KEY=YOUR_API_KEY",
|
|
4
|
+
"main-file": "src/index.ts",
|
|
5
|
+
"static-dir": "static",
|
|
6
|
+
"out-dir": "dist",
|
|
7
|
+
"environment": "development",
|
|
8
|
+
"version": "1.0.0",
|
|
9
|
+
"tunnel-base-url": "wss:///tunnel.dain-local.com",
|
|
10
|
+
"deployment-id": ""
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "example-dain-project",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A Dain Protocol project",
|
|
5
|
+
"main": "src/index.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "ts-node src/index.ts",
|
|
8
|
+
"dev": "dain dev",
|
|
9
|
+
"build": "dain build",
|
|
10
|
+
"deploy": "dain deploy"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@dainprotocol/service-sdk": "^1.0.85",
|
|
14
|
+
"zod": "^3.23.8",
|
|
15
|
+
"hono": "^4.6.3",
|
|
16
|
+
"ts-node": "^10.4.0",
|
|
17
|
+
"typescript": "^5.5.4",
|
|
18
|
+
"@types/express": "^4.17.13",
|
|
19
|
+
"@types/node": "^22.5.4",
|
|
20
|
+
"axios": "^1.7.5",
|
|
21
|
+
"@dainprotocol/cli": "^1.0.31"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
//File: example/example-node.ts
|
|
2
|
+
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import axios from "axios";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
defineDAINService,
|
|
8
|
+
ToolConfig,
|
|
9
|
+
ServiceConfig,
|
|
10
|
+
ToolboxConfig,
|
|
11
|
+
ServiceContext,
|
|
12
|
+
} from "@dainprotocol/service-sdk";
|
|
13
|
+
|
|
14
|
+
const getWeatherConfig: ToolConfig = {
|
|
15
|
+
id: "get-weather",
|
|
16
|
+
name: "Get Weather",
|
|
17
|
+
description: "Fetches current weather for a city",
|
|
18
|
+
input: z
|
|
19
|
+
.object({
|
|
20
|
+
latitude: z.number().describe("Latitude coordinate"),
|
|
21
|
+
longitude: z.number().describe("Longitude coordinate"),
|
|
22
|
+
})
|
|
23
|
+
.describe("Input parameters for the weather request"),
|
|
24
|
+
output: z
|
|
25
|
+
.object({
|
|
26
|
+
temperature: z.number().describe("Current temperature in Celsius"),
|
|
27
|
+
windSpeed: z.number().describe("Current wind speed in km/h"),
|
|
28
|
+
})
|
|
29
|
+
.describe("Current weather information"),
|
|
30
|
+
pricing: { pricePerUse: 0, currency: "USD" },
|
|
31
|
+
handler: async ({ latitude, longitude }, agentInfo) => {
|
|
32
|
+
console.log(
|
|
33
|
+
`User / Agent ${agentInfo.id} requested weather at ${latitude},${longitude}`
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const response = await axios.get(
|
|
37
|
+
`https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}¤t=temperature_2m,wind_speed_10m`
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const { temperature_2m, wind_speed_10m } = response.data.current;
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
text: `The current temperature is ${temperature_2m}°C with wind speed of ${wind_speed_10m} km/h`,
|
|
44
|
+
data: {
|
|
45
|
+
temperature: temperature_2m,
|
|
46
|
+
windSpeed: wind_speed_10m,
|
|
47
|
+
},
|
|
48
|
+
ui: {},
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const getWeatherForecastConfig: ToolConfig = {
|
|
54
|
+
id: "get-weather-forecast",
|
|
55
|
+
name: "Get Weather Forecast",
|
|
56
|
+
description: "Fetches hourly weather forecast",
|
|
57
|
+
input: z
|
|
58
|
+
.object({
|
|
59
|
+
latitude: z.number().describe("Latitude coordinate"),
|
|
60
|
+
longitude: z.number().describe("Longitude coordinate"),
|
|
61
|
+
})
|
|
62
|
+
.describe("Input parameters for the forecast request"),
|
|
63
|
+
output: z
|
|
64
|
+
.object({
|
|
65
|
+
times: z.array(z.string()).describe("Forecast times"),
|
|
66
|
+
temperatures: z
|
|
67
|
+
.array(z.number())
|
|
68
|
+
.describe("Temperature forecasts in Celsius"),
|
|
69
|
+
windSpeeds: z.array(z.number()).describe("Wind speed forecasts in km/h"),
|
|
70
|
+
humidity: z
|
|
71
|
+
.array(z.number())
|
|
72
|
+
.describe("Relative humidity forecasts in %"),
|
|
73
|
+
})
|
|
74
|
+
.describe("Hourly weather forecast"),
|
|
75
|
+
pricing: { pricePerUse: 0, currency: "USD" },
|
|
76
|
+
handler: async ({ latitude, longitude }, agentInfo) => {
|
|
77
|
+
console.log(
|
|
78
|
+
`User / Agent ${agentInfo.id} requested forecast at ${latitude},${longitude}`
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const response = await axios.get(
|
|
82
|
+
`https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&hourly=temperature_2m,relative_humidity_2m,wind_speed_10m`
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const { time, temperature_2m, wind_speed_10m, relative_humidity_2m } =
|
|
86
|
+
response.data.hourly;
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
text: `Weather forecast available for the next ${time.length} hours`,
|
|
90
|
+
data: {
|
|
91
|
+
times: time,
|
|
92
|
+
temperatures: temperature_2m,
|
|
93
|
+
windSpeeds: wind_speed_10m,
|
|
94
|
+
humidity: relative_humidity_2m,
|
|
95
|
+
},
|
|
96
|
+
ui: {},
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const dainService = defineDAINService({
|
|
102
|
+
metadata: {
|
|
103
|
+
title: "Weather DAIN Service",
|
|
104
|
+
description:
|
|
105
|
+
"A DAIN service for current weather and forecasts using Open-Meteo API",
|
|
106
|
+
version: "1.0.0",
|
|
107
|
+
author: "Your Name",
|
|
108
|
+
tags: ["weather", "forecast", "dain"],
|
|
109
|
+
logo: "https://cdn-icons-png.flaticon.com/512/252/252035.png"
|
|
110
|
+
},
|
|
111
|
+
identity: {
|
|
112
|
+
apiKey: process.env.DAIN_API_KEY,
|
|
113
|
+
},
|
|
114
|
+
tools: [getWeatherConfig, getWeatherForecastConfig],
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
dainService.startNode({ port: 2022 }).then(() => {
|
|
118
|
+
console.log("Weather DAIN Service is running on port 2022");
|
|
119
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dainprotocol/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.46",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dain": "./dist/index.js"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
|
-
"build": "tsc",
|
|
14
|
+
"build": "tsc && cp -r templates dist/",
|
|
15
15
|
"prepublishOnly": "pnpm run build"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@ai-sdk/anthropic": "^0.0.50",
|
|
24
|
-
"@dainprotocol/service-sdk": "^1.0.
|
|
24
|
+
"@dainprotocol/service-sdk": "^1.0.85",
|
|
25
25
|
"@dainprotocol/tunnel": "^1.0.5",
|
|
26
26
|
"@types/fs-extra": "^11.0.4",
|
|
27
27
|
"@types/localtunnel": "^2.0.4",
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
"deploy": "dain deploy"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dainprotocol/service-sdk": "^1.0.
|
|
13
|
+
"@dainprotocol/service-sdk": "^1.0.85",
|
|
14
14
|
"zod": "^3.23.8",
|
|
15
15
|
"hono": "^4.6.3",
|
|
16
16
|
"ts-node": "^10.4.0",
|
|
17
17
|
"typescript": "^5.5.4",
|
|
18
18
|
"@types/express": "^4.17.13",
|
|
19
19
|
"@types/node": "^22.5.4",
|
|
20
|
-
"axios": "^1.7.5",
|
|
20
|
+
"axios": "^1.7.5",
|
|
21
21
|
"@dainprotocol/cli": "^1.0.31"
|
|
22
22
|
}
|
|
23
23
|
}
|
|
Binary file
|