lazy-gravity 0.5.1 → 0.5.2

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.
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.openAction = openAction;
37
37
  const net = __importStar(require("net"));
38
+ const http = __importStar(require("http"));
38
39
  const os = __importStar(require("os"));
39
40
  const child_process_1 = require("child_process");
40
41
  const cdpPorts_1 = require("../../utils/cdpPorts");
@@ -45,6 +46,7 @@ const C = {
45
46
  dim: '\x1b[2m',
46
47
  cyan: '\x1b[36m',
47
48
  green: '\x1b[32m',
49
+ yellow: '\x1b[33m',
48
50
  red: '\x1b[31m',
49
51
  };
50
52
  /**
@@ -110,6 +112,44 @@ function openLinux(port) {
110
112
  }
111
113
  });
112
114
  }
115
+ /**
116
+ * Poll CDP endpoint until it responds or timeout is reached.
117
+ */
118
+ function waitForCdp(port, timeoutMs = 15000, intervalMs = 1000) {
119
+ const start = Date.now();
120
+ return new Promise((resolve) => {
121
+ const check = () => {
122
+ const req = http.get(`http://127.0.0.1:${port}/json/list`, (res) => {
123
+ let data = '';
124
+ res.on('data', (chunk) => (data += chunk));
125
+ res.on('end', () => {
126
+ try {
127
+ const parsed = JSON.parse(data);
128
+ if (Array.isArray(parsed)) {
129
+ resolve(true);
130
+ return;
131
+ }
132
+ }
133
+ catch { /* not ready */ }
134
+ retry();
135
+ });
136
+ });
137
+ req.on('error', () => retry());
138
+ req.setTimeout(2000, () => {
139
+ req.destroy();
140
+ retry();
141
+ });
142
+ };
143
+ const retry = () => {
144
+ if (Date.now() - start >= timeoutMs) {
145
+ resolve(false);
146
+ return;
147
+ }
148
+ setTimeout(check, intervalMs);
149
+ };
150
+ check();
151
+ });
152
+ }
113
153
  async function openAction() {
114
154
  const platform = os.platform();
115
155
  console.log(`\n ${C.cyan}Searching for an available CDP port...${C.reset}`);
@@ -133,7 +173,15 @@ async function openAction() {
133
173
  else {
134
174
  await openLinux(port);
135
175
  }
136
- console.log(` ${C.green}${APP_NAME} opened on CDP port ${port}${C.reset}`);
176
+ console.log(` ${C.dim}Waiting for CDP to respond on port ${port}...${C.reset}`);
177
+ const ready = await waitForCdp(port);
178
+ if (ready) {
179
+ console.log(` ${C.green}${APP_NAME} is ready on CDP port ${port}${C.reset}`);
180
+ }
181
+ else {
182
+ console.log(` ${C.yellow}${APP_NAME} launched but CDP not yet responding on port ${port}${C.reset}`);
183
+ console.log(` ${C.dim}It may still be starting up. Try running start in a few seconds.${C.reset}`);
184
+ }
137
185
  console.log(` ${C.dim}Run ${C.reset}${C.cyan}lazy-gravity start${C.reset}${C.dim} to connect the bot.${C.reset}\n`);
138
186
  }
139
187
  catch (error) {
@@ -81,10 +81,14 @@ async function ensureAntigravityRunning() {
81
81
  logger_1.logger.warn('='.repeat(70));
82
82
  logger_1.logger.warn(' Antigravity CDP ports are not responding');
83
83
  logger_1.logger.warn('');
84
- logger_1.logger.warn(' Please run AntigravityDebug.command before starting the Bot');
84
+ logger_1.logger.warn(' Run the following command to open Antigravity with CDP enabled:');
85
+ logger_1.logger.warn('');
86
+ logger_1.logger.warn(' lazy-gravity open');
85
87
  logger_1.logger.warn('');
86
88
  logger_1.logger.warn(' Or manually:');
87
89
  logger_1.logger.warn(` ${(0, pathUtils_1.getAntigravityCdpHint)(9222)}`);
90
+ logger_1.logger.warn('');
91
+ logger_1.logger.warn(' Then run: lazy-gravity start');
88
92
  logger_1.logger.warn('='.repeat(70));
89
93
  logger_1.logger.warn('');
90
94
  }
@@ -43,6 +43,7 @@ function buildProjectListPayload(workspaces, page = 0) {
43
43
  const safePage = Math.max(0, Math.min(page, totalPages - 1));
44
44
  let rc = (0, richContentBuilder_1.withTimestamp)((0, richContentBuilder_1.withColor)((0, richContentBuilder_1.withTitle)((0, richContentBuilder_1.withDescription)((0, richContentBuilder_1.createRichContent)(), (0, i18n_1.t)('Select a project to auto-create a category and session channel')), 'Projects'), 0x5865F2));
45
45
  if (workspaces.length === 0) {
46
+ rc = (0, richContentBuilder_1.withDescription)(rc, (0, i18n_1.t)('No projects found.\nCreate a project directory in your workspace base folder, then try again.'));
46
47
  return { richContent: rc, components: [] };
47
48
  }
48
49
  if (totalPages > 1) {
@@ -104,6 +105,7 @@ function buildProjectListUI(workspaces, page = 0) {
104
105
  .setDescription((0, i18n_1.t)('Select a project to auto-create a category and session channel'))
105
106
  .setTimestamp();
106
107
  if (workspaces.length === 0) {
108
+ embed.setDescription((0, i18n_1.t)('No projects found.\nCreate a project directory in your workspace base folder, then try again.'));
107
109
  return { embeds: [embed], components: [] };
108
110
  }
109
111
  const start = safePage * exports.ITEMS_PER_PAGE;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lazy-gravity",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Control Antigravity from anywhere — a local, secure bot (Discord + Telegram) that lets you remotely operate Antigravity on your home PC from your smartphone.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {