omnibiofex 2.8.4 → 4.0.0

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/src/api.js DELETED
@@ -1,72 +0,0 @@
1
- const axios = require('axios');
2
- const chalk = require('chalk');
3
- const config = require('./config');
4
- const { getAuthToken } = require('./auth');
5
-
6
- const apiClient = axios.create({
7
- timeout: 540000, // 9 minutes
8
- });
9
-
10
- // 🔥 FIX: Make the interceptor async to handle async getAuthToken()
11
- apiClient.interceptors.request.use(async (requestConfig) => {
12
- try {
13
- const token = await getAuthToken(); // 🔥 Now properly awaits the token
14
- requestConfig.headers.Authorization = `Bearer ${token}`;
15
- return requestConfig;
16
- } catch (error) {
17
- console.error(chalk.red('Failed to get auth token:'), error.message);
18
- throw error;
19
- }
20
- });
21
-
22
- // Handle errors
23
- apiClient.interceptors.response.use(
24
- (response) => response,
25
- (error) => {
26
- if (error.response?.status === 401) {
27
- console.error(chalk.red('Authentication expired. Please run: obx login'));
28
- process.exit(1);
29
- }
30
- return Promise.reject(error);
31
- }
32
- );
33
-
34
- async function createMission(topic, taskType) {
35
- const response = await apiClient.post(config.get('apiUrl'), {
36
- message: topic,
37
- taskType: taskType,
38
- conversationHistory: []
39
- });
40
- return response.data;
41
- }
42
-
43
- async function analyzeFile(filePath, taskType) {
44
- const fs = require('fs');
45
- const fileBuffer = fs.readFileSync(filePath);
46
- const base64Data = fileBuffer.toString('base64');
47
-
48
- const response = await apiClient.post(config.get('apiUrl'), {
49
- message: `Analyze this file: ${filePath}`,
50
- taskType: taskType,
51
- images: [`data:application/pdf;base64,${base64Data}`],
52
- conversationHistory: []
53
- });
54
- return response.data;
55
- }
56
-
57
- // 🔥 FIXED: Actually call the backend endpoint
58
- async function getUserCredits() {
59
- try {
60
- const response = await apiClient.get('https://getusercredits-yyedhmslhq-uc.a.run.app');
61
- return {
62
- balance: response.data.tokens || 0,
63
- used: 0,
64
- total: response.data.tokens || 0
65
- };
66
- } catch (error) {
67
- console.error(chalk.red('Error fetching credits:'), error.message);
68
- throw error;
69
- }
70
- }
71
-
72
- module.exports = { createMission, analyzeFile, getUserCredits };
package/src/config.js DELETED
@@ -1,16 +0,0 @@
1
- const Conf = require('conf');
2
-
3
- const config = new Conf({
4
- projectName: 'omnibiofex',
5
- defaults: {
6
- apiUrl: 'https://obxvisionassistant-yyedhmslhq-uc.a.run.app',
7
- dashboardUrl: 'https://x.omnibiofex.cloud/dash',
8
- authToken: null,
9
- refreshToken: null, // 🔥 NEW: Store refresh token
10
- userId: null,
11
- userEmail: null,
12
- tokenExpiry: null, // 🔥 NEW: Track token expiry time
13
- }
14
- });
15
-
16
- module.exports = config;