chati-dev 4.0.10 → 4.0.11

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/bin/chati.js CHANGED
@@ -362,7 +362,7 @@ Telemetry:
362
362
 
363
363
  case 'deactivate': {
364
364
  const { runDeactivate } = await import('../src/license/commands.js');
365
- runDeactivate(targetDir);
365
+ await runDeactivate(targetDir);
366
366
  break;
367
367
  }
368
368
 
@@ -370,7 +370,12 @@ Telemetry:
370
370
  const licSubCmd = args[1] || 'status';
371
371
  if (licSubCmd === 'deactivate') {
372
372
  const { runDeactivate } = await import('../src/license/commands.js');
373
- runDeactivate(targetDir);
373
+ await runDeactivate(targetDir);
374
+ } else if (args.includes('--refresh') || licSubCmd === 'refresh') {
375
+ // Force re-validate against API and update local cache
376
+ const { runLicenseStatus } = await import('../src/license/commands.js');
377
+ await runLicenseStatus(targetDir);
378
+ console.log(' Cache updated. Hook will use fresh status on next run.\n');
374
379
  } else {
375
380
  const { runLicenseStatus } = await import('../src/license/commands.js');
376
381
  await runLicenseStatus(targetDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chati-dev",
3
- "version": "4.0.10",
3
+ "version": "4.0.11",
4
4
  "description": "AI-Powered Multi-Agent Orchestration System — Structured vibe coding for Full Stack Development",
5
5
  "type": "module",
6
6
  "bin": {
@@ -125,10 +125,28 @@ export async function validateLicense(_projectDir) {
125
125
  }
126
126
 
127
127
  /**
128
- * Remove license locally (does not deactivate machine slot on server).
128
+ * Remove license locally and deactivate machine slot on server (best-effort).
129
+ * Fails silently if API is unreachable.
129
130
  */
130
- export function deactivateLicense(_projectDir) {
131
+ export async function deactivateLicense(_projectDir) {
131
132
  const data = readGlobal();
133
+ const key = data.key && data.key !== 'null' ? data.key : null;
134
+
135
+ // Best-effort server deactivation (key + machine_id = proof of ownership)
136
+ if (key) {
137
+ try {
138
+ const machineId = getMachineId();
139
+ await fetch(`${API_BASE}/license/self-deactivate`, {
140
+ method: 'POST',
141
+ headers: { 'Content-Type': 'application/json' },
142
+ body: JSON.stringify({ key, machine_id: machineId }),
143
+ signal: AbortSignal.timeout(5000),
144
+ });
145
+ } catch {
146
+ // Fail silently — local deactivation still proceeds
147
+ }
148
+ }
149
+
132
150
  writeGlobal({
133
151
  ...data,
134
152
  key: null,
@@ -50,15 +50,15 @@ export async function runActivate(projectDir, keyArg) {
50
50
  // deactivate
51
51
  // ---------------------------------------------------------------------------
52
52
 
53
- export function runDeactivate(projectDir) {
53
+ export async function runDeactivate(projectDir) {
54
54
  const key = getLicenseKey(projectDir);
55
55
  if (!key) {
56
56
  console.log('No license key found locally. Nothing to remove.');
57
57
  return;
58
58
  }
59
- deactivateLicense(projectDir);
60
- console.log(`\n✓ License key removed locally.`);
61
- console.log(` To free up a machine slot, visit https://chati.dev/dashboard\n`);
59
+ console.log('Deactivating...');
60
+ await deactivateLicense(projectDir);
61
+ console.log(`\n✓ License key removed and machine slot freed.\n`);
62
62
  }
63
63
 
64
64
  // ---------------------------------------------------------------------------
@@ -74,7 +74,7 @@ export async function runLicenseStatus(projectDir) {
74
74
  return;
75
75
  }
76
76
 
77
- console.log(`\nChecking license...`);
77
+ console.log(`\nChecking license (refreshing cache)...`);
78
78
 
79
79
  let status;
80
80
  try {
@@ -27,7 +27,6 @@ export function getTelemetryConfig(targetDir) {
27
27
  enabled: true,
28
28
  anonymousId: null,
29
29
  endpoint: process.env.CHATI_TELEMETRY_ENDPOINT || 'https://chati.dev/api/telemetry',
30
- apiKey: process.env.CHATI_TELEMETRY_KEY || '10b0b54ba4f392fa46379ba778062ab0af5ca61e79609a7dce4aadd660104b56',
31
30
  };
32
31
 
33
32
  if (!existsSync(configPath)) return defaults;
@@ -41,7 +40,6 @@ export function getTelemetryConfig(targetDir) {
41
40
  enabled: telemetry.enabled === true,
42
41
  anonymousId: telemetry.anonymous_id || null,
43
42
  endpoint: telemetry.endpoint || defaults.endpoint,
44
- apiKey: telemetry.api_key || defaults.apiKey,
45
43
  };
46
44
  } catch {
47
45
  return defaults;
@@ -58,24 +58,26 @@ export async function sendEvents(events, config) {
58
58
  events,
59
59
  };
60
60
 
61
- try {
62
- const controller = new AbortController();
63
- const timeout = setTimeout(() => controller.abort(), 5000);
61
+ for (let attempt = 1; attempt <= 3; attempt++) {
62
+ try {
63
+ const controller = new AbortController();
64
+ const timeout = setTimeout(() => controller.abort(), 5000);
64
65
 
65
- await fetch(endpoint, {
66
- method: 'POST',
67
- headers: {
68
- 'Content-Type': 'application/json',
69
- ...(config.apiKey ? { 'X-Telemetry-Key': config.apiKey } : {}),
70
- },
71
- body: JSON.stringify(payload),
72
- signal: controller.signal,
73
- });
66
+ const res = await fetch(endpoint, {
67
+ method: 'POST',
68
+ headers: { 'Content-Type': 'application/json' },
69
+ body: JSON.stringify(payload),
70
+ signal: controller.signal,
71
+ });
74
72
 
75
- clearTimeout(timeout);
76
- return true;
77
- } catch {
78
- // Silently failnever block user workflow
79
- return false;
73
+ clearTimeout(timeout);
74
+ if (res.ok || res.status < 500) return true; // 4xx = don't retry
75
+ } catch {
76
+ // Network error or timeout retry if attempts remain
77
+ if (attempt < 3) {
78
+ await new Promise(r => setTimeout(r, attempt * 500)); // 500ms, 1000ms
79
+ }
80
+ }
80
81
  }
82
+ return false;
81
83
  }