osai-agent 4.2.25 → 4.2.27
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/package.json +1 -1
- package/src/commands/admin.js +17 -7
package/package.json
CHANGED
package/src/commands/admin.js
CHANGED
|
@@ -12,12 +12,12 @@ const promptSecret = () => new Promise((resolve) => {
|
|
|
12
12
|
});
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
const adminFetch = async (serverArg, path, method = 'GET', body = null, pathPrefix = '/auth') => {
|
|
15
|
+
const adminFetch = async (serverArg, path, method = 'GET', body = null, pathPrefix = '/auth', secret = null) => {
|
|
16
16
|
const config = new Conf({ projectName: 'osai-agent' });
|
|
17
17
|
const serverUrl = serverArg || config.get('server') || DEFAULT_SERVER_URL;
|
|
18
18
|
const httpUrl = toHttpUrl(serverUrl);
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
if (!secret) secret = await promptSecret();
|
|
21
21
|
if (!secret) {
|
|
22
22
|
console.log(chalk.red('Admin secret is required.'));
|
|
23
23
|
process.exit(1);
|
|
@@ -82,12 +82,22 @@ export const enableUser = async ({ server, email }) => {
|
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
export const generateProKeys = async ({ server, count, type }) => {
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
const secret = await promptSecret();
|
|
86
|
+
if (!secret) {
|
|
87
|
+
console.log(chalk.red('Admin secret is required.'));
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
const spinner = ora({ text: 'Generating Pro keys...', spinner: 'bouncingBar' }).start();
|
|
91
|
+
let done = false;
|
|
92
|
+
const coldStartWarn = setTimeout(() => {
|
|
93
|
+
if (!done) spinner.text = 'Server is waking up (HF Spaces cold start), please wait...';
|
|
94
|
+
}, 15000);
|
|
95
|
+
const data = await adminFetch(server, '/generate', 'POST', { type, count }, '/pro', secret);
|
|
96
|
+
done = true;
|
|
97
|
+
clearTimeout(coldStartWarn);
|
|
98
|
+
spinner.succeed(`${data.count} Pro keys generated (${data.type}, ${data.duration_days} days)`);
|
|
89
99
|
for (const key of data.keys) {
|
|
90
|
-
console.log(`
|
|
100
|
+
console.log(` ${chalk.hex('#ff9e64')(key)}`);
|
|
91
101
|
}
|
|
92
102
|
console.log();
|
|
93
103
|
};
|