osai-agent 4.2.26 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "osai-agent",
3
- "version": "4.2.26",
3
+ "version": "4.2.27",
4
4
  "type": "module",
5
5
  "description": "OS AI Agent - YOUR AI AGENT",
6
6
  "main": "src/index.js",
@@ -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
- const secret = await promptSecret();
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,17 @@ export const enableUser = async ({ server, email }) => {
82
82
  };
83
83
 
84
84
  export const generateProKeys = async ({ server, count, type }) => {
85
+ const secret = await promptSecret();
86
+ if (!secret) {
87
+ console.log(chalk.red('Admin secret is required.'));
88
+ process.exit(1);
89
+ }
85
90
  const spinner = ora({ text: 'Generating Pro keys...', spinner: 'bouncingBar' }).start();
86
91
  let done = false;
87
92
  const coldStartWarn = setTimeout(() => {
88
93
  if (!done) spinner.text = 'Server is waking up (HF Spaces cold start), please wait...';
89
94
  }, 15000);
90
- const data = await adminFetch(server, '/generate', 'POST', { type, count }, '/pro');
95
+ const data = await adminFetch(server, '/generate', 'POST', { type, count }, '/pro', secret);
91
96
  done = true;
92
97
  clearTimeout(coldStartWarn);
93
98
  spinner.succeed(`${data.count} Pro keys generated (${data.type}, ${data.duration_days} days)`);