@dainprotocol/cli 1.0.43 → 1.0.45

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.
@@ -1 +0,0 @@
1
- DAIN_API_KEY=
@@ -1,12 +0,0 @@
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
- "platform-base-url": "https://platform.dain.org",
11
- "runtime": "node"
12
- }
@@ -1,23 +0,0 @@
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.75",
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
- }
@@ -1,119 +0,0 @@
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}&current=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
- });
@@ -1,8 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "skipLibCheck": true,
4
- "module": "NodeNext",
5
- "moduleResolution": "NodeNext"
6
- }
7
- }
8
-