robot-resources 1.3.3 → 1.3.4
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/lib/wizard.js +34 -9
- package/package.json +1 -1
package/lib/wizard.js
CHANGED
|
@@ -254,31 +254,56 @@ export async function runWizard({ nonInteractive = false } = {}) {
|
|
|
254
254
|
}
|
|
255
255
|
} else {
|
|
256
256
|
// Silent provisioning — no prompt, no browser
|
|
257
|
+
// Use a stable machine ID so re-runs don't create duplicate accounts
|
|
257
258
|
try {
|
|
258
|
-
const hostname =
|
|
259
|
+
const { hostname } = await import('node:os');
|
|
260
|
+
const { join } = await import('node:path');
|
|
261
|
+
const { homedir } = await import('node:os');
|
|
262
|
+
const { readFileSync, writeFileSync, mkdirSync } = await import('node:fs');
|
|
263
|
+
const { randomUUID } = await import('node:crypto');
|
|
264
|
+
|
|
265
|
+
const rrDir = join(homedir(), '.robot-resources');
|
|
266
|
+
const machineIdPath = join(rrDir, '.machine-id');
|
|
267
|
+
let machineId;
|
|
268
|
+
try {
|
|
269
|
+
machineId = readFileSync(machineIdPath, 'utf-8').trim();
|
|
270
|
+
} catch {
|
|
271
|
+
machineId = randomUUID();
|
|
272
|
+
try {
|
|
273
|
+
mkdirSync(rrDir, { recursive: true });
|
|
274
|
+
writeFileSync(machineIdPath, machineId, 'utf-8');
|
|
275
|
+
} catch { /* non-fatal */ }
|
|
276
|
+
}
|
|
277
|
+
|
|
259
278
|
const platformUrl = process.env.RR_PLATFORM_URL || 'https://api.robotresources.ai';
|
|
260
279
|
const res = await fetch(`${platformUrl}/v1/auth/signup`, {
|
|
261
280
|
method: 'POST',
|
|
262
281
|
headers: { 'Content-Type': 'application/json' },
|
|
263
282
|
body: JSON.stringify({
|
|
264
|
-
agent_name: hostname,
|
|
283
|
+
agent_name: hostname(),
|
|
265
284
|
platform: 'cli',
|
|
285
|
+
machine_id: machineId,
|
|
266
286
|
}),
|
|
267
287
|
signal: AbortSignal.timeout(10_000),
|
|
268
288
|
});
|
|
269
289
|
|
|
270
290
|
if (res.ok) {
|
|
271
291
|
const { data } = await res.json();
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
292
|
+
if (data.api_key === 'existing') {
|
|
293
|
+
// Machine already provisioned in a previous run
|
|
294
|
+
success('Dashboard: already provisioned');
|
|
295
|
+
} else {
|
|
296
|
+
writeConfig({
|
|
297
|
+
api_key: data.api_key,
|
|
298
|
+
key_id: data.key_id,
|
|
299
|
+
claim_url: data.claim_url,
|
|
300
|
+
signup_source: 'auto',
|
|
301
|
+
});
|
|
302
|
+
success('Dashboard: API key provisioned (telemetry active)');
|
|
303
|
+
}
|
|
278
304
|
results.auth = true;
|
|
279
305
|
results.authMethod = 'auto';
|
|
280
306
|
results.claimUrl = data.claim_url;
|
|
281
|
-
success('Dashboard: API key provisioned (telemetry active)');
|
|
282
307
|
if (data.claim_url) {
|
|
283
308
|
info(`Claim your dashboard: ${data.claim_url}`);
|
|
284
309
|
}
|