genbox 1.0.35 → 1.0.37

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.
@@ -193,10 +193,42 @@ exports.statusCommand = new commander_1.Command('status')
193
193
  const dbStatus = target.status; // 'provisioning' | 'running' | 'error' etc.
194
194
  const setupDuration = target.setupDuration;
195
195
  const setupCompletedAt = target.setupCompletedAt;
196
- // If DB says RUNNING and we have setupCompletedAt, setup is complete
197
- if (dbStatus === 'running' && setupCompletedAt) {
198
- const durationStr = setupDuration ? formatDuration(setupDuration) : 'unknown';
199
- console.log(chalk_1.default.green(`[SUCCESS] Setup completed! (took ${durationStr})`));
196
+ // If DB says RUNNING, setup is complete (use DB as source of truth)
197
+ if (dbStatus === 'running') {
198
+ if (setupCompletedAt && setupDuration) {
199
+ console.log(chalk_1.default.green(`[SUCCESS] Setup completed! (took ${formatDuration(setupDuration)})`));
200
+ }
201
+ else {
202
+ console.log(chalk_1.default.green(`[SUCCESS] Genbox is running`));
203
+ }
204
+ console.log('');
205
+ // Show billing info
206
+ const billing = {
207
+ creditsPerHour: target.creditsPerHour || 1,
208
+ totalCreditsUsed: target.totalCreditsUsed || 0,
209
+ totalHoursUsed: target.totalHoursUsed || 0,
210
+ currentHourEnd: target.currentHourEnd,
211
+ lastActivityAt: target.lastActivityAt,
212
+ autoDestroyOnInactivity: target.autoDestroyOnInactivity ?? true,
213
+ };
214
+ const now = new Date();
215
+ const minutesUntilBilling = billing.currentHourEnd
216
+ ? Math.max(0, Math.ceil((new Date(billing.currentHourEnd).getTime() - now.getTime()) / (60 * 1000)))
217
+ : 0;
218
+ const minutesInactive = billing.lastActivityAt
219
+ ? Math.floor((now.getTime() - new Date(billing.lastActivityAt).getTime()) / (60 * 1000))
220
+ : 0;
221
+ console.log(chalk_1.default.blue('[INFO] === Billing ==='));
222
+ console.log(` Size: ${target.size} (${billing.creditsPerHour} credit${billing.creditsPerHour > 1 ? 's' : ''}/hr)`);
223
+ console.log(` Current hour ends in: ${chalk_1.default.cyan(minutesUntilBilling + ' min')}`);
224
+ console.log(` Last activity: ${minutesInactive < 1 ? 'just now' : minutesInactive + ' min ago'}`);
225
+ console.log(` Total: ${billing.totalHoursUsed} hour${billing.totalHoursUsed !== 1 ? 's' : ''}, ${billing.totalCreditsUsed} credit${billing.totalCreditsUsed !== 1 ? 's' : ''}`);
226
+ if (billing.autoDestroyOnInactivity) {
227
+ const minutesUntilDestroy = Math.max(0, 60 - minutesInactive);
228
+ if (minutesInactive >= 45) {
229
+ console.log(chalk_1.default.yellow(` Auto-destroy in: ${minutesUntilDestroy} min (inactive)`));
230
+ }
231
+ }
200
232
  console.log('');
201
233
  // Show Docker containers status
202
234
  const dockerStatus = sshExec(target.ipAddress, keyPath, 'docker ps --format "{{.Names}}\\t{{.Status}}" 2>/dev/null', 10);
@@ -294,7 +326,21 @@ exports.statusCommand = new commander_1.Command('status')
294
326
  console.log(chalk_1.default.dim(' Run `genbox connect` to investigate.'));
295
327
  return;
296
328
  }
297
- // Fallback: try legacy cloud-init check for backwards compatibility
329
+ // If DB says TERMINATED
330
+ if (dbStatus === 'terminated') {
331
+ const destroyReason = target.destroyReason;
332
+ console.log(chalk_1.default.red(`[TERMINATED] Genbox has been destroyed`));
333
+ if (destroyReason) {
334
+ console.log(chalk_1.default.dim(` Reason: ${destroyReason}`));
335
+ }
336
+ return;
337
+ }
338
+ // If DB says STOPPED
339
+ if (dbStatus === 'stopped') {
340
+ console.log(chalk_1.default.yellow('[STOPPED] Genbox is stopped'));
341
+ return;
342
+ }
343
+ // Fallback: try legacy cloud-init check for backwards compatibility (should rarely reach here)
298
344
  let status = sshExec(target.ipAddress, keyPath, 'cloud-init status 2>&1');
299
345
  if (!status || status.includes('not found')) {
300
346
  // No cloud-init, check our status file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genbox",
3
- "version": "1.0.35",
3
+ "version": "1.0.37",
4
4
  "description": "Genbox CLI - AI-Powered Development Environments",
5
5
  "main": "dist/index.js",
6
6
  "bin": {