@dainprotocol/cli 1.2.31 → 1.2.33

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/index.js CHANGED
File without changes
package/dist/utils.js CHANGED
@@ -168,7 +168,7 @@ function displayTunnelUrl(tunnelUrl) {
168
168
  }
169
169
  function setupProxy(port, apiKey, config) {
170
170
  return __awaiter(this, void 0, void 0, function () {
171
- var spinner, client, tunnelUrl, error_1;
171
+ var spinner, client_2, tunnelUrl, error_1;
172
172
  return __generator(this, function (_a) {
173
173
  switch (_a.label) {
174
174
  case 0:
@@ -176,12 +176,41 @@ function setupProxy(port, apiKey, config) {
176
176
  _a.label = 1;
177
177
  case 1:
178
178
  _a.trys.push([1, 3, , 4]);
179
- client = new client_1.DainTunnel(config["tunnel-base-url"] || exports.DEFAULT_TUNNEL_BASE_URL, apiKey);
180
- return [4 /*yield*/, client.start(parseInt(port))];
179
+ client_2 = new client_1.DainTunnel(config["tunnel-base-url"] || exports.DEFAULT_TUNNEL_BASE_URL, apiKey);
180
+ // Handle tunnel lifecycle events
181
+ client_2.on("disconnected", function () {
182
+ console.log(chalk_1.default.yellow("\n⚠ Tunnel disconnected. Attempting to reconnect..."));
183
+ });
184
+ client_2.on("reconnecting", function (_a) {
185
+ var attempt = _a.attempt, delay = _a.delay;
186
+ console.log(chalk_1.default.yellow(" Reconnection attempt ".concat(attempt, "/10 in ").concat(Math.round(delay / 1000), "s...")));
187
+ });
188
+ client_2.on("reconnected", function () {
189
+ console.log(chalk_1.default.green("✓ Tunnel reconnected successfully"));
190
+ });
191
+ client_2.on("error", function (error) {
192
+ console.error(chalk_1.default.red("\n\u2717 Tunnel error: ".concat(error.message)));
193
+ });
194
+ client_2.on("max_reconnect_attempts", function () {
195
+ console.error(chalk_1.default.red("\n✗ Tunnel failed to reconnect after 10 attempts."));
196
+ console.log(chalk_1.default.yellow(" Resetting and trying again..."));
197
+ // Reset and try one more time (resetReconnection added in tunnel 1.1.31)
198
+ if (typeof client_2.resetReconnection === "function") {
199
+ client_2.resetReconnection();
200
+ client_2.start(parseInt(port)).catch(function (err) {
201
+ console.error(chalk_1.default.red("\n\u2717 Unable to restore tunnel connection: ".concat(err.message)));
202
+ console.log(chalk_1.default.yellow(" Please restart the dev server manually."));
203
+ });
204
+ }
205
+ else {
206
+ console.log(chalk_1.default.yellow(" Please restart the dev server manually."));
207
+ }
208
+ });
209
+ return [4 /*yield*/, client_2.start(parseInt(port))];
181
210
  case 2:
182
211
  tunnelUrl = _a.sent();
183
212
  spinner.succeed("Proxy setup complete");
184
- return [2 /*return*/, { client: client, tunnelUrl: tunnelUrl }];
213
+ return [2 /*return*/, { client: client_2, tunnelUrl: tunnelUrl }];
185
214
  case 3:
186
215
  error_1 = _a.sent();
187
216
  spinner.fail(chalk_1.default.red("Error setting up proxy"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dainprotocol/cli",
3
- "version": "1.2.31",
3
+ "version": "1.2.33",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -10,21 +10,14 @@
10
10
  "bin": {
11
11
  "dain": "./dist/index.js"
12
12
  },
13
- "scripts": {
14
- "build": "tsc && cp -r templates dist/",
15
- "test": "jest",
16
- "test:watch": "jest --watch",
17
- "test:coverage": "jest --coverage",
18
- "prepublishOnly": "pnpm run build && pnpm test"
19
- },
20
13
  "files": [
21
14
  "dist",
22
15
  "README.md"
23
16
  ],
24
17
  "dependencies": {
25
18
  "@ai-sdk/anthropic": "^0.0.50",
26
- "@dainprotocol/service-sdk": "^2.0.79",
27
- "@dainprotocol/tunnel": "^1.1.29",
19
+ "@dainprotocol/service-sdk": "2.0.80",
20
+ "@dainprotocol/tunnel": "1.1.33",
28
21
  "@types/fs-extra": "^11.0.4",
29
22
  "@types/localtunnel": "^2.0.4",
30
23
  "ai": "^3.3.41",
@@ -47,5 +40,11 @@
47
40
  "ts-jest": "^29.4.6",
48
41
  "ts-node": "^10.9.2",
49
42
  "typescript": "^5.9.3"
43
+ },
44
+ "scripts": {
45
+ "build": "tsc && cp -r templates dist/",
46
+ "test": "jest",
47
+ "test:watch": "jest --watch",
48
+ "test:coverage": "jest --coverage"
50
49
  }
51
- }
50
+ }