nex-framework-cli 1.0.1 → 1.0.4
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": "nex-framework-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "NEX CLI - Command-line interface for NEX Framework and Agent Marketplace",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "cli/nex-cli.js",
|
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
],
|
|
18
18
|
"scripts": {
|
|
19
19
|
"prepublishOnly": "npm run test",
|
|
20
|
-
"test": "node cli/nex-cli.js --version"
|
|
20
|
+
"test": "node cli/nex-cli.js --version",
|
|
21
|
+
"publish:cli": "node scripts/publish-cli.js",
|
|
22
|
+
"publish:cli:dry": "node scripts/publish-cli.js --dry-run"
|
|
21
23
|
},
|
|
22
24
|
"keywords": [
|
|
23
25
|
"nex",
|
|
@@ -31,14 +31,26 @@ export default class NEXMarketplace {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* Initialize Supabase client
|
|
34
|
+
* Initialize Supabase client and API URL
|
|
35
35
|
*/
|
|
36
36
|
initializeSupabase() {
|
|
37
37
|
const supabaseUrl = process.env.VITE_SUPABASE_URL
|
|
38
38
|
const supabaseKey = process.env.VITE_SUPABASE_ANON_KEY
|
|
39
39
|
|
|
40
|
+
// URL padrão da Edge Function (funciona sem configuração)
|
|
41
|
+
const DEFAULT_API_URL = 'https://jsazeeeqxxebydghsiad.supabase.co/functions/v1/nex-marketplace-api'
|
|
42
|
+
|
|
43
|
+
// API URL da Edge Function (preferida - sem expor anon key)
|
|
44
|
+
// Prioridade: 1) NEX_MARKETPLACE_API_URL, 2) Construída a partir de VITE_SUPABASE_URL, 3) Default
|
|
45
|
+
this.apiUrl = process.env.NEX_MARKETPLACE_API_URL ||
|
|
46
|
+
(supabaseUrl ? `${supabaseUrl}/functions/v1/nex-marketplace-api` : DEFAULT_API_URL)
|
|
47
|
+
|
|
48
|
+
// Cliente Supabase (apenas para operações que requerem autenticação)
|
|
40
49
|
if (supabaseUrl && supabaseKey) {
|
|
41
50
|
this.supabase = createClient(supabaseUrl, supabaseKey)
|
|
51
|
+
} else if (this.apiUrl) {
|
|
52
|
+
// Se tiver API URL mas não tiver anon key, ainda funciona para leitura
|
|
53
|
+
// Não mostra mensagem para não poluir o output
|
|
42
54
|
} else {
|
|
43
55
|
console.warn(chalk.yellow('⚠️ Supabase not configured. Marketplace will work in local-only mode.'))
|
|
44
56
|
}
|
|
@@ -117,9 +129,46 @@ export default class NEXMarketplace {
|
|
|
117
129
|
}
|
|
118
130
|
|
|
119
131
|
/**
|
|
120
|
-
* Search in Supabase
|
|
132
|
+
* Search in Supabase (via Edge Function ou cliente direto)
|
|
121
133
|
*/
|
|
122
134
|
async searchRemote(query, options = {}) {
|
|
135
|
+
// Preferir Edge Function (mais seguro - sem anon key)
|
|
136
|
+
if (this.apiUrl) {
|
|
137
|
+
return await this.searchViaAPI(query, options)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Fallback para cliente direto (se anon key disponível)
|
|
141
|
+
if (this.supabase) {
|
|
142
|
+
return await this.searchViaClient(query, options)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return []
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Search via Edge Function API (SEGURO - sem anon key)
|
|
150
|
+
*/
|
|
151
|
+
async searchViaAPI(query, options = {}) {
|
|
152
|
+
const params = new URLSearchParams()
|
|
153
|
+
if (query) params.append('q', query)
|
|
154
|
+
if (options.category) params.append('category', options.category)
|
|
155
|
+
if (options.official) params.append('official', 'true')
|
|
156
|
+
if (options.limit) params.append('limit', options.limit.toString())
|
|
157
|
+
|
|
158
|
+
const response = await fetch(`${this.apiUrl}/search?${params}`)
|
|
159
|
+
|
|
160
|
+
if (!response.ok) {
|
|
161
|
+
throw new Error(`API error: ${response.statusText}`)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const { agents } = await response.json()
|
|
165
|
+
return agents || []
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Search via Supabase client (fallback - requer anon key)
|
|
170
|
+
*/
|
|
171
|
+
async searchViaClient(query, options = {}) {
|
|
123
172
|
let dbQuery = this.supabase
|
|
124
173
|
.from('nex_marketplace_agents')
|
|
125
174
|
.select('*')
|
|
@@ -275,10 +324,20 @@ export default class NEXMarketplace {
|
|
|
275
324
|
const spinner = ora(`Loading info for ${agentId}...`).start()
|
|
276
325
|
|
|
277
326
|
try {
|
|
278
|
-
// Try to load from
|
|
327
|
+
// Try to load from API/Remote first (prefer API)
|
|
279
328
|
let agent = null
|
|
280
329
|
|
|
281
|
-
if (this.
|
|
330
|
+
if (this.apiUrl) {
|
|
331
|
+
try {
|
|
332
|
+
const response = await fetch(`${this.apiUrl}/info/${agentId}`)
|
|
333
|
+
if (response.ok) {
|
|
334
|
+
const { agent: apiAgent } = await response.json()
|
|
335
|
+
agent = apiAgent
|
|
336
|
+
}
|
|
337
|
+
} catch (error) {
|
|
338
|
+
// Silently fallback
|
|
339
|
+
}
|
|
340
|
+
} else if (this.supabase) {
|
|
282
341
|
const { data } = await this.supabase
|
|
283
342
|
.from('nex_marketplace_agents')
|
|
284
343
|
.select('*')
|