osai-agent 4.2.26 → 4.2.28
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
|
@@ -39,7 +39,7 @@ export default {
|
|
|
39
39
|
if (msg.type === 'REGISTERED') { clearTimeout(connectTimeout); this.ws = ws; resolve(msg); }
|
|
40
40
|
else if (msg.type === 'COMMANDS') { this.pendingCommands = msg.commands; this.currentTaskId = msg.taskId; }
|
|
41
41
|
else if (msg.type === 'CANCEL_ACK') { logger.info('Cancellation acknowledged by server'); }
|
|
42
|
-
|
|
42
|
+
else if (msg.type === 'ERROR') { clearTimeout(connectTimeout); ws.close(); reject(new Error(msg.message)); }
|
|
43
43
|
else if (msg.type === 'CANCEL_SUBAGENT') {
|
|
44
44
|
if (this._subagentActive && this._subagentLoop) {
|
|
45
45
|
this._subagentLoop.cancel();
|
package/src/agent/react-loop.js
CHANGED
|
@@ -274,6 +274,10 @@ export class AgentLoop {
|
|
|
274
274
|
await this._connectWebSocket();
|
|
275
275
|
} catch (err) {
|
|
276
276
|
this.onConnectionChange(false);
|
|
277
|
+
if (err.message.toLowerCase().includes('disabled')) {
|
|
278
|
+
console.log(chalk.red(`\n ${err.message}\n`));
|
|
279
|
+
process.exit(1);
|
|
280
|
+
}
|
|
277
281
|
logger.debug(`WebSocket connection failed: ${err.message}`);
|
|
278
282
|
logger.warn('Server unavailable, running in offline mode');
|
|
279
283
|
this.ws = null;
|
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,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)`);
|