modelstat 0.0.14 → 0.0.16
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/cli.mjs +13 -13
- package/dist/cli.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -9007,28 +9007,28 @@ async function cmdConnect(opts) {
|
|
|
9007
9007
|
process.stdout.write(` \x1B[33m\u26A0\x1B[0m ${msg}
|
|
9008
9008
|
`);
|
|
9009
9009
|
};
|
|
9010
|
-
const hasLegacyBearer = !!state.bearer && !state.bearer.startsWith("ds_live_");
|
|
9011
|
-
const hasLegacyClaim = !!state.claimUrl && (state.claimUrl.includes("/c/") || /\/d\/[a-z]/.test(state.claimUrl) || !state.claimUrl.includes("/device/"));
|
|
9012
|
-
const hasLegacyCode = !!state.claimCode && !/^[0-9a-hjkmnp-tv-z]{32}$/.test(state.claimCode);
|
|
9013
|
-
if (hasLegacyBearer || hasLegacyClaim || hasLegacyCode) {
|
|
9014
|
-
step("Legacy state detected from an older version \u2014 wiping");
|
|
9015
|
-
state.setBearer(null);
|
|
9016
|
-
state.setDeviceId(null);
|
|
9017
|
-
state.setDeviceUuid(null);
|
|
9018
|
-
state.setClaimCode(null);
|
|
9019
|
-
state.setClaimUrl(null);
|
|
9020
|
-
ok("clean slate");
|
|
9021
|
-
}
|
|
9022
9010
|
if (!state.deviceUuid || !state.bearer || !state.deviceId) {
|
|
9023
9011
|
step("Registering this device with modelstat.ai");
|
|
9024
9012
|
await cmdSelfRegister();
|
|
9025
9013
|
} else {
|
|
9026
9014
|
step("Re-using existing device identity");
|
|
9027
9015
|
ok(`device ${state.deviceId}`);
|
|
9016
|
+
try {
|
|
9017
|
+
const me = await fetchDeviceMe(state.bearer);
|
|
9018
|
+
if (me.claim_code && me.claim_code !== state.claimCode) {
|
|
9019
|
+
state.setClaimCode(me.claim_code);
|
|
9020
|
+
ok(`claim code refreshed from server`);
|
|
9021
|
+
}
|
|
9022
|
+
if (me.claim_url && me.claim_url !== state.claimUrl) {
|
|
9023
|
+
state.setClaimUrl(me.claim_url);
|
|
9024
|
+
}
|
|
9025
|
+
} catch (e) {
|
|
9026
|
+
warn(`couldn't refresh device state: ${e.message}`);
|
|
9027
|
+
}
|
|
9028
9028
|
}
|
|
9029
9029
|
const claimCode = state.claimCode ?? "(unknown)";
|
|
9030
9030
|
const claimUrl = state.claimUrl ?? `https://modelstat.ai/device/${claimCode}`;
|
|
9031
|
-
const agentUrl = `https://modelstat.ai/device
|
|
9031
|
+
const agentUrl = `https://modelstat.ai/device/${claimCode}/agent`;
|
|
9032
9032
|
emitEvent(opts, "registered", {
|
|
9033
9033
|
device_uuid: state.deviceUuid,
|
|
9034
9034
|
device_id: state.deviceId,
|