nex-framework-cli 1.0.7 → 1.0.9
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/cli/nex-cli.js
CHANGED
|
@@ -28,10 +28,10 @@ program.configureHelp({
|
|
|
28
28
|
program
|
|
29
29
|
.name('nex')
|
|
30
30
|
.description('NEX Framework - Framework completo de agentes AI')
|
|
31
|
-
.version('1.0.
|
|
31
|
+
.version('1.0.8', '-v, --version', 'Mostra a versão')
|
|
32
32
|
.addHelpText('before', chalk.bold.cyan(`
|
|
33
33
|
╔════════════════════════════════════════════════════════════════╗
|
|
34
|
-
║ NEX Framework - CLI v1.0.
|
|
34
|
+
║ NEX Framework - CLI v1.0.8 ║
|
|
35
35
|
║ Framework completo de agentes AI ║
|
|
36
36
|
╚════════════════════════════════════════════════════════════════╝
|
|
37
37
|
`))
|
package/package.json
CHANGED
|
@@ -102,28 +102,46 @@ export default class NEXMarketplace {
|
|
|
102
102
|
|
|
103
103
|
try {
|
|
104
104
|
let results = []
|
|
105
|
+
let apiError = null
|
|
105
106
|
|
|
106
|
-
//
|
|
107
|
-
if (this.supabase) {
|
|
108
|
-
|
|
107
|
+
// Try remote search first
|
|
108
|
+
if (this.apiUrl || this.supabase) {
|
|
109
|
+
try {
|
|
110
|
+
results = await this.searchRemote(query, options)
|
|
111
|
+
} catch (error) {
|
|
112
|
+
apiError = error
|
|
113
|
+
// Continue with local search only
|
|
114
|
+
console.warn(chalk.yellow(`\n⚠️ Could not connect to marketplace: ${error.message}`))
|
|
115
|
+
console.log(chalk.gray(' Searching local registry only...\n'))
|
|
116
|
+
}
|
|
109
117
|
}
|
|
110
118
|
|
|
111
|
-
//
|
|
119
|
+
// Always search local registry
|
|
112
120
|
const localResults = await this.searchLocal(query, options)
|
|
113
121
|
|
|
114
122
|
// Merge results (deduplicate by agent_id)
|
|
115
123
|
const merged = this.mergeResults(results, localResults)
|
|
116
124
|
|
|
117
|
-
|
|
125
|
+
if (merged.length > 0) {
|
|
126
|
+
spinner.succeed(`Found ${merged.length} agents`)
|
|
127
|
+
} else {
|
|
128
|
+
spinner.warn('No agents found')
|
|
129
|
+
}
|
|
118
130
|
|
|
119
131
|
// Display results
|
|
120
132
|
this.displaySearchResults(merged)
|
|
121
133
|
|
|
134
|
+
// Show warning if API failed
|
|
135
|
+
if (apiError && localResults.length > 0) {
|
|
136
|
+
console.log(chalk.yellow('\n💡 Tip: Some results may be missing. Check your connection.\n'))
|
|
137
|
+
}
|
|
138
|
+
|
|
122
139
|
return merged
|
|
123
140
|
|
|
124
141
|
} catch (error) {
|
|
125
142
|
spinner.fail('Search failed')
|
|
126
|
-
console.error(chalk.red(
|
|
143
|
+
console.error(chalk.red(`\nError: ${error.message}`))
|
|
144
|
+
console.log(chalk.gray('\n💡 Try searching locally or check your connection.\n'))
|
|
127
145
|
throw error
|
|
128
146
|
}
|
|
129
147
|
}
|
|
@@ -149,20 +167,38 @@ export default class NEXMarketplace {
|
|
|
149
167
|
* Search via Edge Function API (SEGURO - sem anon key)
|
|
150
168
|
*/
|
|
151
169
|
async searchViaAPI(query, options = {}) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
170
|
+
try {
|
|
171
|
+
const params = new URLSearchParams()
|
|
172
|
+
if (query) params.append('q', query)
|
|
173
|
+
if (options.category) params.append('category', options.category)
|
|
174
|
+
if (options.official) params.append('official', 'true')
|
|
175
|
+
if (options.limit) params.append('limit', options.limit.toString())
|
|
176
|
+
|
|
177
|
+
// Timeout de 10 segundos
|
|
178
|
+
const controller = new AbortController()
|
|
179
|
+
const timeoutId = setTimeout(() => controller.abort(), 10000)
|
|
180
|
+
|
|
181
|
+
const response = await fetch(`${this.apiUrl}/search?${params}`, {
|
|
182
|
+
signal: controller.signal
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
clearTimeout(timeoutId)
|
|
186
|
+
|
|
187
|
+
if (!response.ok) {
|
|
188
|
+
throw new Error(`API error: ${response.statusText}`)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const { agents } = await response.json()
|
|
192
|
+
return agents || []
|
|
193
|
+
} catch (error) {
|
|
194
|
+
if (error.name === 'AbortError') {
|
|
195
|
+
throw new Error('Connection timeout. The marketplace API is not responding.')
|
|
196
|
+
}
|
|
197
|
+
if (error.code === 'UND_ERR_CONNECT_TIMEOUT' || error.message.includes('timeout')) {
|
|
198
|
+
throw new Error('Connection timeout. Please check your internet connection or try again later.')
|
|
199
|
+
}
|
|
200
|
+
throw error
|
|
162
201
|
}
|
|
163
|
-
|
|
164
|
-
const { agents } = await response.json()
|
|
165
|
-
return agents || []
|
|
166
202
|
}
|
|
167
203
|
|
|
168
204
|
/**
|
|
@@ -173,30 +209,66 @@ export default class NEXMarketplace {
|
|
|
173
209
|
|
|
174
210
|
try {
|
|
175
211
|
let results = []
|
|
212
|
+
let apiError = null
|
|
176
213
|
|
|
177
|
-
//
|
|
214
|
+
// Try API/Remote first
|
|
178
215
|
if (this.apiUrl) {
|
|
179
|
-
|
|
216
|
+
try {
|
|
217
|
+
results = await this.listAllViaAPI(options)
|
|
218
|
+
} catch (error) {
|
|
219
|
+
apiError = error
|
|
220
|
+
console.warn(chalk.yellow(`\n⚠️ Could not connect to marketplace API: ${error.message}`))
|
|
221
|
+
console.log(chalk.gray(' Falling back to local registry...\n'))
|
|
222
|
+
|
|
223
|
+
// Try Supabase client as fallback
|
|
224
|
+
if (this.supabase) {
|
|
225
|
+
try {
|
|
226
|
+
results = await this.listAllViaClient(options)
|
|
227
|
+
} catch (clientError) {
|
|
228
|
+
// If both fail, continue with local only
|
|
229
|
+
results = []
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
180
233
|
} else if (this.supabase) {
|
|
181
|
-
|
|
234
|
+
try {
|
|
235
|
+
results = await this.listAllViaClient(options)
|
|
236
|
+
} catch (error) {
|
|
237
|
+
apiError = error
|
|
238
|
+
results = []
|
|
239
|
+
}
|
|
182
240
|
}
|
|
183
241
|
|
|
184
|
-
//
|
|
242
|
+
// Always include local registry
|
|
185
243
|
const localResults = await this.searchLocal('', options)
|
|
186
244
|
|
|
187
245
|
// Merge results
|
|
188
246
|
const merged = this.mergeResults(results, localResults)
|
|
189
247
|
|
|
190
|
-
|
|
248
|
+
if (merged.length > 0) {
|
|
249
|
+
spinner.succeed(`Found ${merged.length} available agents`)
|
|
250
|
+
} else {
|
|
251
|
+
spinner.warn('No agents found')
|
|
252
|
+
}
|
|
191
253
|
|
|
192
254
|
// Display results
|
|
193
255
|
this.displaySearchResults(merged)
|
|
194
256
|
|
|
257
|
+
// Show warning if API failed but we have local results
|
|
258
|
+
if (apiError && localResults.length > 0) {
|
|
259
|
+
console.log(chalk.yellow('\n💡 Tip: Some agents may be missing. Check your connection or configure NEX_MARKETPLACE_API_URL\n'))
|
|
260
|
+
}
|
|
261
|
+
|
|
195
262
|
return merged
|
|
196
263
|
|
|
197
264
|
} catch (error) {
|
|
198
265
|
spinner.fail('Failed to load agents')
|
|
199
|
-
console.error(chalk.red(
|
|
266
|
+
console.error(chalk.red(`\nError: ${error.message}`))
|
|
267
|
+
console.log(chalk.gray('\n💡 Troubleshooting:'))
|
|
268
|
+
console.log(chalk.gray(' 1. Check your internet connection'))
|
|
269
|
+
console.log(chalk.gray(' 2. Verify the API URL: ' + (this.apiUrl || 'not configured')))
|
|
270
|
+
console.log(chalk.gray(' 3. Try: nex agent list (shows only installed agents)'))
|
|
271
|
+
console.log(chalk.gray(' 4. Configure custom API: export NEX_MARKETPLACE_API_URL=<your-url>\n'))
|
|
200
272
|
throw error
|
|
201
273
|
}
|
|
202
274
|
}
|
|
@@ -205,14 +277,32 @@ export default class NEXMarketplace {
|
|
|
205
277
|
* List all agents via Edge Function API
|
|
206
278
|
*/
|
|
207
279
|
async listAllViaAPI(options = {}) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
280
|
+
try {
|
|
281
|
+
// Timeout de 10 segundos
|
|
282
|
+
const controller = new AbortController()
|
|
283
|
+
const timeoutId = setTimeout(() => controller.abort(), 10000)
|
|
284
|
+
|
|
285
|
+
const response = await fetch(`${this.apiUrl}/list`, {
|
|
286
|
+
signal: controller.signal
|
|
287
|
+
})
|
|
288
|
+
|
|
289
|
+
clearTimeout(timeoutId)
|
|
290
|
+
|
|
291
|
+
if (!response.ok) {
|
|
292
|
+
throw new Error(`API error: ${response.statusText}`)
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const { agents } = await response.json()
|
|
296
|
+
return agents || []
|
|
297
|
+
} catch (error) {
|
|
298
|
+
if (error.name === 'AbortError') {
|
|
299
|
+
throw new Error('Connection timeout. The marketplace API is not responding.')
|
|
300
|
+
}
|
|
301
|
+
if (error.code === 'UND_ERR_CONNECT_TIMEOUT' || error.message.includes('timeout')) {
|
|
302
|
+
throw new Error('Connection timeout. Please check your internet connection or try again later.')
|
|
303
|
+
}
|
|
304
|
+
throw error
|
|
212
305
|
}
|
|
213
|
-
|
|
214
|
-
const { agents } = await response.json()
|
|
215
|
-
return agents || []
|
|
216
306
|
}
|
|
217
307
|
|
|
218
308
|
/**
|