pokt-cli 1.0.9 → 1.0.10
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/README.md +7 -1
- package/dist/bin/pokt.js +5 -4
- package/dist/chat/client.js +4 -3
- package/dist/chat/loop.js +2 -2
- package/dist/commands/chat.js +2 -2
- package/dist/commands/config.js +44 -5
- package/dist/commands/doctor.js +6 -1
- package/dist/commands/pro.js +2 -2
- package/dist/commands/provider.js +2 -2
- package/dist/config.d.ts +19 -2
- package/dist/config.js +62 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -71,7 +71,10 @@ pokt --help
|
|
|
71
71
|
- `pokt config set-ollama -v <url>` — URL base do Ollama local.
|
|
72
72
|
- `pokt config set-ollama-cloud -v <key>` — API key Ollama Cloud.
|
|
73
73
|
- `pokt config set-gemini -v <key>` — API key Google Gemini.
|
|
74
|
-
- `pokt config set-pokt-token -v <token>` — Token
|
|
74
|
+
- `pokt config set-pokt-token -v <token>` — Token Pokt (gerado no painel na Railway).
|
|
75
|
+
- `pokt config set-pokt-api-url -v <url>` — API com token Pokt (provider `controller`; padrão Railway). O provider **openai** continua em `api.openai.com`.
|
|
76
|
+
- `pokt config set-pro-portal-url -v <url>` — Painel / serviço (padrão Railway).
|
|
77
|
+
- `pokt config set-token-purchase-url -v <url>` — Só a página de **comprar token** (padrão: Controller Vercel).
|
|
75
78
|
- `pokt config clear-openrouter` — Remove o token OpenRouter.
|
|
76
79
|
- `pokt config clear-openai` — Remove a API key OpenAI.
|
|
77
80
|
- `pokt config clear-grok` — Remove a API key Grok (xAI).
|
|
@@ -98,6 +101,9 @@ Se preferir não salvar chaves no computador (ou para CI), você pode usar env v
|
|
|
98
101
|
- `OLLAMA_BASE_URL`
|
|
99
102
|
- `OLLAMA_CLOUD_API_KEY`
|
|
100
103
|
- `POKT_TOKEN`
|
|
104
|
+
- `POKT_API_BASE_URL` — API com token Pokt (Railway por padrão).
|
|
105
|
+
- `POKT_PRO_PORTAL_URL` (ou `POKT_CONTROLLER_PORTAL_URL`) — Painel / serviço (Railway por padrão).
|
|
106
|
+
- `POKT_TOKEN_PURCHASE_URL` — Só checkout / compra de token (Vercel por padrão). Na atualização, URLs antigas `pokt-cli-controller.vercel.app` salvas em API/painel migram automaticamente para a Railway.
|
|
101
107
|
|
|
102
108
|
### Provedores (`provider`)
|
|
103
109
|
|
package/dist/bin/pokt.js
CHANGED
|
@@ -257,7 +257,7 @@ async function handleConfigMenu() {
|
|
|
257
257
|
if (response.type === 'back')
|
|
258
258
|
return showMenu();
|
|
259
259
|
if (response.type === 'show') {
|
|
260
|
-
const {
|
|
260
|
+
const { getPoktApiBaseUrl, getProPortalBaseUrl, getTokenPurchaseUrl } = await import('../config.js');
|
|
261
261
|
const openai = config.get('openaiApiKey');
|
|
262
262
|
const grok = config.get('grokApiKey');
|
|
263
263
|
const openrouter = config.get('openrouterToken');
|
|
@@ -266,7 +266,9 @@ async function handleConfigMenu() {
|
|
|
266
266
|
const ollamaCloud = config.get('ollamaCloudApiKey');
|
|
267
267
|
const poktToken = config.get('poktToken');
|
|
268
268
|
console.log(chalk.blue('\nCurrent config (tokens masked):'));
|
|
269
|
-
console.log(ui.dim('
|
|
269
|
+
console.log(ui.dim(' Pokt API (chat):'), getPoktApiBaseUrl());
|
|
270
|
+
console.log(ui.dim(' Painel / serviço:'), getProPortalBaseUrl());
|
|
271
|
+
console.log(ui.dim(' Comprar token:'), getTokenPurchaseUrl());
|
|
270
272
|
console.log(ui.dim(' Pokt Token:'), poktToken ? poktToken.slice(0, 10) + '****' : '(not set)');
|
|
271
273
|
console.log(ui.dim(' OpenAI API Key:'), openai ? openai.slice(0, 8) + '****' : '(not set)');
|
|
272
274
|
console.log(ui.dim(' Grok (xAI) API Key:'), grok ? grok.slice(0, 8) + '****' : '(not set)');
|
|
@@ -312,9 +314,8 @@ async function handleConfigMenu() {
|
|
|
312
314
|
async function handleProviderMenu() {
|
|
313
315
|
const { config, getEffectiveActiveModel, PROVIDER_LABELS, ALL_PROVIDERS } = await import('../config.js');
|
|
314
316
|
let models = config.get('registeredModels');
|
|
315
|
-
const hasControllerUrl = !!(config.get('controllerBaseUrl'));
|
|
316
317
|
const hasPoktToken = !!(config.get('poktToken'));
|
|
317
|
-
if (
|
|
318
|
+
if (hasPoktToken && !models.some((m) => m.provider === 'controller')) {
|
|
318
319
|
models = [{ provider: 'controller', id: 'default' }, ...models];
|
|
319
320
|
config.set('registeredModels', models);
|
|
320
321
|
}
|
package/dist/chat/client.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import OpenAI from 'openai';
|
|
2
|
-
import {
|
|
2
|
+
import { getPoktApiBaseUrl, getProPortalBaseUrl, getOpenAIApiKey, getGrokApiKey, getOpenRouterToken, getGeminiApiKey, getOllamaCloudApiKey, getOllamaBaseUrl, getPoktToken, } from '../config.js';
|
|
3
3
|
export async function getClient(modelConfig) {
|
|
4
|
+
// openai / grok / … → hosts oficiais abaixo. Só `controller` usa getPoktApiBaseUrl (token Pokt, não é api.openai.com).
|
|
4
5
|
if (modelConfig.provider === 'controller') {
|
|
5
|
-
const baseUrl =
|
|
6
|
+
const baseUrl = getPoktApiBaseUrl();
|
|
6
7
|
const token = getPoktToken();
|
|
7
8
|
if (!token) {
|
|
8
|
-
throw new Error(
|
|
9
|
+
throw new Error(`Token Pokt não configurado. Painel: ${getProPortalBaseUrl()} — pokt config set-pokt-token -v <token>`);
|
|
9
10
|
}
|
|
10
11
|
return new OpenAI({
|
|
11
12
|
baseURL: `${baseUrl}/api/v1`,
|
package/dist/chat/loop.js
CHANGED
|
@@ -185,7 +185,7 @@ Comandos do chat:
|
|
|
185
185
|
${ui.accent('/chat')} — checkpoints/sessões (list/save/resume/delete/share)
|
|
186
186
|
${ui.accent('/resume')} — alias de /chat
|
|
187
187
|
${ui.accent('/copy')} — copia a última resposta do Pokt (Windows: clip)
|
|
188
|
-
${ui.accent('/pro')} — abrir
|
|
188
|
+
${ui.accent('/pro')} — abrir compra de token no navegador (Vercel)
|
|
189
189
|
${ui.accent('/quit')} ou ${ui.accent('exit')} — sair do chat
|
|
190
190
|
`));
|
|
191
191
|
}
|
|
@@ -331,7 +331,7 @@ Comandos do chat:
|
|
|
331
331
|
if (trimmed === '?') {
|
|
332
332
|
console.log(ui.dim(`
|
|
333
333
|
Atalhos:
|
|
334
|
-
${ui.accent('/pro')} ou ${ui.accent('/torne-se-pro')} —
|
|
334
|
+
${ui.accent('/pro')} ou ${ui.accent('/torne-se-pro')} — comprar token (abre Vercel; painel/API na Railway)
|
|
335
335
|
exit, ${ui.accent('/quit')} — sair do chat
|
|
336
336
|
${ui.accent('/help')} — ver comandos do chat
|
|
337
337
|
`));
|
package/dist/commands/chat.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getEffectiveActiveModel, getOpenAIApiKey, getGrokApiKey, getOpenRouterToken, getGeminiApiKey, getPoktToken } from '../config.js';
|
|
1
|
+
import { getEffectiveActiveModel, getOpenAIApiKey, getGrokApiKey, getOpenRouterToken, getGeminiApiKey, getPoktToken, getProPortalBaseUrl, } from '../config.js';
|
|
2
2
|
import { startChatLoop } from '../chat/loop.js';
|
|
3
3
|
import { ui } from '../ui.js';
|
|
4
4
|
export const chatCommand = {
|
|
@@ -29,7 +29,7 @@ export const chatCommand = {
|
|
|
29
29
|
}
|
|
30
30
|
if (activeModel.provider === 'controller') {
|
|
31
31
|
if (!getPoktToken()) {
|
|
32
|
-
console.log(ui.error(
|
|
32
|
+
console.log(ui.error(`Pokt token not set. Painel: ${getProPortalBaseUrl()} — pokt config set-pokt-token -v <token>`));
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
}
|
package/dist/commands/config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { config,
|
|
1
|
+
import { config, getPoktApiBaseUrl, getProPortalBaseUrl, getTokenPurchaseUrl } from '../config.js';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import { ui } from '../ui.js';
|
|
4
4
|
export const configCommand = {
|
|
@@ -8,7 +8,22 @@ export const configCommand = {
|
|
|
8
8
|
.positional('action', {
|
|
9
9
|
describe: 'Action to perform',
|
|
10
10
|
type: 'string',
|
|
11
|
-
choices: [
|
|
11
|
+
choices: [
|
|
12
|
+
'set-openai',
|
|
13
|
+
'set-grok',
|
|
14
|
+
'set-openrouter',
|
|
15
|
+
'set-ollama',
|
|
16
|
+
'set-ollama-cloud',
|
|
17
|
+
'set-gemini',
|
|
18
|
+
'set-pokt-token',
|
|
19
|
+
'set-pokt-api-url',
|
|
20
|
+
'set-pro-portal-url',
|
|
21
|
+
'set-token-purchase-url',
|
|
22
|
+
'clear-openrouter',
|
|
23
|
+
'clear-openai',
|
|
24
|
+
'clear-grok',
|
|
25
|
+
'show',
|
|
26
|
+
]
|
|
12
27
|
})
|
|
13
28
|
.option('value', {
|
|
14
29
|
describe: 'The value to set',
|
|
@@ -32,7 +47,9 @@ export const configCommand = {
|
|
|
32
47
|
console.log(ui.dim(' Gemini API Key:'), gemini ? gemini.slice(0, 8) + '****' : '(not set)');
|
|
33
48
|
console.log(ui.dim(' Ollama Base URL (local):'), ollama || '(not set)');
|
|
34
49
|
console.log(ui.dim(' Ollama Cloud API Key:'), ollamaCloud ? ollamaCloud.slice(0, 8) + '****' : '(not set) — https://ollama.com/settings/keys');
|
|
35
|
-
console.log(ui.dim('
|
|
50
|
+
console.log(ui.dim(' Pokt API (chat / token):'), getPoktApiBaseUrl());
|
|
51
|
+
console.log(ui.dim(' Painel / serviço (Railway):'), getProPortalBaseUrl());
|
|
52
|
+
console.log(ui.dim(' Comprar token (Vercel):'), getTokenPurchaseUrl());
|
|
36
53
|
console.log(ui.dim(' Pokt Token:'), poktToken ? poktToken.slice(0, 10) + '****' : '(not set) — use: pokt config set-pokt-token -v <token>');
|
|
37
54
|
console.log(ui.warn('\nTokens are stored in your user config directory. Do not share it.\n'));
|
|
38
55
|
return;
|
|
@@ -52,7 +69,16 @@ export const configCommand = {
|
|
|
52
69
|
console.log(ui.success('Grok (xAI) API key cleared.'));
|
|
53
70
|
return;
|
|
54
71
|
}
|
|
55
|
-
if (action !== 'set-openai' &&
|
|
72
|
+
if (action !== 'set-openai' &&
|
|
73
|
+
action !== 'set-grok' &&
|
|
74
|
+
action !== 'set-openrouter' &&
|
|
75
|
+
action !== 'set-ollama' &&
|
|
76
|
+
action !== 'set-ollama-cloud' &&
|
|
77
|
+
action !== 'set-gemini' &&
|
|
78
|
+
action !== 'set-pokt-token' &&
|
|
79
|
+
action !== 'set-pokt-api-url' &&
|
|
80
|
+
action !== 'set-pro-portal-url' &&
|
|
81
|
+
action !== 'set-token-purchase-url')
|
|
56
82
|
return;
|
|
57
83
|
const raw = Array.isArray(value) ? value[0] : value;
|
|
58
84
|
const strValue = typeof raw === 'string' ? raw : (raw != null ? String(raw) : '');
|
|
@@ -92,7 +118,20 @@ export const configCommand = {
|
|
|
92
118
|
config.set('registeredModels', [controllerModel, ...models]);
|
|
93
119
|
}
|
|
94
120
|
config.set('activeModel', controllerModel);
|
|
95
|
-
|
|
121
|
+
const portal = getProPortalBaseUrl();
|
|
122
|
+
console.log(ui.success(`Pokt token salvo. Provedor Pokt ativo. Gere tokens no painel: ${portal}`));
|
|
123
|
+
}
|
|
124
|
+
else if (action === 'set-pokt-api-url') {
|
|
125
|
+
config.set('poktApiBaseUrl', strValue.replace(/\/$/, ''));
|
|
126
|
+
console.log(ui.success(`URL da API Pokt (token Bearer / provider controller) salva: ${strValue.replace(/\/$/, '')}`));
|
|
127
|
+
}
|
|
128
|
+
else if (action === 'set-pro-portal-url') {
|
|
129
|
+
config.set('controllerBaseUrl', strValue.replace(/\/$/, ''));
|
|
130
|
+
console.log(ui.success(`URL do painel/serviço (Railway) salva: ${strValue.replace(/\/$/, '')}`));
|
|
131
|
+
}
|
|
132
|
+
else if (action === 'set-token-purchase-url') {
|
|
133
|
+
config.set('tokenPurchaseBaseUrl', strValue.replace(/\/$/, ''));
|
|
134
|
+
console.log(ui.success(`URL de compra de token (checkout) salva: ${strValue.replace(/\/$/, '')}`));
|
|
96
135
|
}
|
|
97
136
|
}
|
|
98
137
|
};
|
package/dist/commands/doctor.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ora from 'ora';
|
|
2
2
|
import { ui } from '../ui.js';
|
|
3
|
-
import { PROVIDER_LABELS, getEffectiveActiveModel, getOpenAIApiKey, getGrokApiKey, getOpenRouterToken, getGeminiApiKey, getOllamaBaseUrl, getOllamaCloudApiKey, getPoktToken, } from '../config.js';
|
|
3
|
+
import { PROVIDER_LABELS, getEffectiveActiveModel, getOpenAIApiKey, getGrokApiKey, getOpenRouterToken, getGeminiApiKey, getOllamaBaseUrl, getOllamaCloudApiKey, getPoktToken, getPoktApiBaseUrl, getProPortalBaseUrl, getTokenPurchaseUrl, } from '../config.js';
|
|
4
4
|
import { getClient } from '../chat/client.js';
|
|
5
5
|
function mask(value) {
|
|
6
6
|
if (!value)
|
|
@@ -55,6 +55,11 @@ export const doctorCommand = {
|
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
57
|
console.log(ui.success(`Credencial OK: ${req.name} = ${mask(req.value)}`));
|
|
58
|
+
if (active.provider === 'controller') {
|
|
59
|
+
console.log(ui.dim(` API Pokt (chat): ${getPoktApiBaseUrl()}`));
|
|
60
|
+
console.log(ui.dim(` Painel / serviço: ${getProPortalBaseUrl()}`));
|
|
61
|
+
console.log(ui.dim(` Comprar token: ${getTokenPurchaseUrl()}`));
|
|
62
|
+
}
|
|
58
63
|
}
|
|
59
64
|
else if (active.provider === 'ollama') {
|
|
60
65
|
console.log(ui.success(`Ollama (local) não precisa de chave. Base URL: ${getOllamaBaseUrl()}`));
|
package/dist/commands/pro.js
CHANGED
|
@@ -4,7 +4,7 @@ import { ui } from '../ui.js';
|
|
|
4
4
|
export const proCommand = {
|
|
5
5
|
command: 'pro',
|
|
6
6
|
aliases: ['Pro'],
|
|
7
|
-
describe: 'Abre a página
|
|
7
|
+
describe: 'Abre a página de compra de token no Controller (Vercel). Painel/API usam a Railway. Use --url só para imprimir o link.',
|
|
8
8
|
builder: (yargs) => yargs.option('url', {
|
|
9
9
|
type: 'boolean',
|
|
10
10
|
default: false,
|
|
@@ -25,7 +25,7 @@ export function runProFlow(printOnlyUrl = false) {
|
|
|
25
25
|
console.log(proHomeUrl);
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
console.log(ui.dim('Pokt
|
|
28
|
+
console.log(ui.dim('Comprar token Pokt — abre o site na Vercel (pagamento). Painel/API: Railway.\n'));
|
|
29
29
|
console.log(ui.accent(proHomeUrl));
|
|
30
30
|
try {
|
|
31
31
|
openBrowser(proHomeUrl);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { config, ALL_PROVIDERS, getOpenAIApiKey, getGrokApiKey, getOpenRouterToken, getGeminiApiKey, getOllamaCloudApiKey, getPoktToken } from '../config.js';
|
|
1
|
+
import { config, ALL_PROVIDERS, getOpenAIApiKey, getGrokApiKey, getOpenRouterToken, getGeminiApiKey, getOllamaCloudApiKey, getPoktToken, getProPortalBaseUrl, } from '../config.js';
|
|
2
2
|
import { ui } from '../ui.js';
|
|
3
3
|
export const providerCommand = {
|
|
4
4
|
command: 'provider use <provider>',
|
|
@@ -54,7 +54,7 @@ export const providerCommand = {
|
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
if (provider === 'controller' && !getPoktToken()) {
|
|
57
|
-
console.log(ui.error(
|
|
57
|
+
console.log(ui.error(`Pokt token not set. Painel: ${getProPortalBaseUrl()} — pokt config set-pokt-token -v <token>`));
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
60
|
if (provider === 'ollama-cloud' && !getOllamaCloudApiKey()) {
|
package/dist/config.d.ts
CHANGED
|
@@ -34,7 +34,12 @@ interface AppConfig {
|
|
|
34
34
|
geminiApiKey: string;
|
|
35
35
|
ollamaBaseUrl: string;
|
|
36
36
|
ollamaCloudApiKey: string;
|
|
37
|
+
/** Painel / links gerais (Railway); não usar para compra de token */
|
|
37
38
|
controllerBaseUrl: string;
|
|
39
|
+
/** Base para API com token Pokt — provider `controller` (Railway) */
|
|
40
|
+
poktApiBaseUrl: string;
|
|
41
|
+
/** Só compra de token / checkout — Vercel */
|
|
42
|
+
tokenPurchaseBaseUrl: string;
|
|
38
43
|
poktToken: string;
|
|
39
44
|
registeredModels: ModelConfig[];
|
|
40
45
|
activeModel: ModelConfig | null;
|
|
@@ -49,6 +54,11 @@ export declare const env: {
|
|
|
49
54
|
readonly ollamaBaseUrl: readonly ["OLLAMA_BASE_URL"];
|
|
50
55
|
readonly ollamaCloudApiKey: readonly ["OLLAMA_CLOUD_API_KEY"];
|
|
51
56
|
readonly poktToken: readonly ["POKT_TOKEN"];
|
|
57
|
+
readonly poktApiBaseUrl: readonly ["POKT_API_BASE_URL"];
|
|
58
|
+
/** Painel e URLs gerais (Railway) */
|
|
59
|
+
readonly proPortalUrl: readonly ["POKT_PRO_PORTAL_URL", "POKT_CONTROLLER_PORTAL_URL"];
|
|
60
|
+
/** Apenas página de compra de token (Vercel) */
|
|
61
|
+
readonly tokenPurchaseUrl: readonly ["POKT_TOKEN_PURCHASE_URL"];
|
|
52
62
|
};
|
|
53
63
|
export declare function getOpenAIApiKey(): string;
|
|
54
64
|
export declare function getGrokApiKey(): string;
|
|
@@ -57,8 +67,15 @@ export declare function getGeminiApiKey(): string;
|
|
|
57
67
|
export declare function getOllamaBaseUrl(): string;
|
|
58
68
|
export declare function getOllamaCloudApiKey(): string;
|
|
59
69
|
export declare function getPoktToken(): string;
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
/** Base da API só para provider `controller` (Bearer Pokt). OpenAI direto usa outro ramo no getClient. */
|
|
71
|
+
export declare function getPoktApiBaseUrl(): string;
|
|
72
|
+
/** Painel e links gerais (Railway), exceto compra de token — ver getTokenPurchaseUrl(). */
|
|
73
|
+
export declare function getProPortalBaseUrl(): string;
|
|
74
|
+
/** Somente comprar token / checkout — Vercel (Controller). Usado por `pokt pro`. */
|
|
75
|
+
export declare function getTokenPurchaseUrl(): string;
|
|
76
|
+
/** @deprecated Use getPoktApiBaseUrl() ou getProPortalBaseUrl() conforme o caso. */
|
|
77
|
+
export declare const getControllerBaseUrl: typeof getPoktApiBaseUrl;
|
|
78
|
+
/** URL aberta por `pokt pro` (comprar token) — Vercel por padrão. */
|
|
62
79
|
export declare const getProPurchaseUrl: () => string;
|
|
63
80
|
/** Prioridade: modelo ativo explícito → Pokt (controller) se token setado → OpenRouter → Gemini → Ollama Cloud → Ollama local */
|
|
64
81
|
export declare function getEffectiveActiveModel(): ModelConfig | null;
|
package/dist/config.js
CHANGED
|
@@ -10,7 +10,24 @@ export const PROVIDER_LABELS = {
|
|
|
10
10
|
};
|
|
11
11
|
/** Lista de todos os provedores disponíveis (único lugar para incluir novos no futuro) */
|
|
12
12
|
export const ALL_PROVIDERS = Object.keys(PROVIDER_LABELS);
|
|
13
|
-
|
|
13
|
+
/** Serviço Pokt na Railway: API (`/api/v1`), painel e tudo que substituiu o host antigo da Vercel. */
|
|
14
|
+
const DEFAULT_POKT_SERVICE_BASE_URL = 'https://poktcliback-production.up.railway.app';
|
|
15
|
+
/** Somente fluxo de compra de token (Stripe / “Torne-se Pro”) — permanece no Controller Vercel. */
|
|
16
|
+
const DEFAULT_TOKEN_PURCHASE_BASE_URL = 'https://pokt-cli-controller.vercel.app';
|
|
17
|
+
/** Host legado: configs antigas são migradas automaticamente para `DEFAULT_POKT_SERVICE_BASE_URL`. */
|
|
18
|
+
const LEGACY_VERCEL_POKT_HOST = 'pokt-cli-controller.vercel.app';
|
|
19
|
+
function normalizeBaseUrl(url) {
|
|
20
|
+
return url.trim().replace(/\/$/, '');
|
|
21
|
+
}
|
|
22
|
+
function isLegacyVercelPoktUrl(url) {
|
|
23
|
+
try {
|
|
24
|
+
const u = new URL(url.trim());
|
|
25
|
+
return u.hostname.toLowerCase() === LEGACY_VERCEL_POKT_HOST;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
14
31
|
export const config = new Conf({
|
|
15
32
|
projectName: 'pokt-cli',
|
|
16
33
|
defaults: {
|
|
@@ -20,7 +37,9 @@ export const config = new Conf({
|
|
|
20
37
|
geminiApiKey: '',
|
|
21
38
|
ollamaBaseUrl: 'http://localhost:11434',
|
|
22
39
|
ollamaCloudApiKey: '',
|
|
23
|
-
controllerBaseUrl:
|
|
40
|
+
controllerBaseUrl: DEFAULT_POKT_SERVICE_BASE_URL,
|
|
41
|
+
poktApiBaseUrl: DEFAULT_POKT_SERVICE_BASE_URL,
|
|
42
|
+
tokenPurchaseBaseUrl: DEFAULT_TOKEN_PURCHASE_BASE_URL,
|
|
24
43
|
poktToken: '',
|
|
25
44
|
registeredModels: [
|
|
26
45
|
{ provider: 'controller', id: 'default' },
|
|
@@ -51,7 +70,26 @@ export const env = {
|
|
|
51
70
|
ollamaBaseUrl: ['OLLAMA_BASE_URL'],
|
|
52
71
|
ollamaCloudApiKey: ['OLLAMA_CLOUD_API_KEY'],
|
|
53
72
|
poktToken: ['POKT_TOKEN'],
|
|
73
|
+
poktApiBaseUrl: ['POKT_API_BASE_URL'],
|
|
74
|
+
/** Painel e URLs gerais (Railway) */
|
|
75
|
+
proPortalUrl: ['POKT_PRO_PORTAL_URL', 'POKT_CONTROLLER_PORTAL_URL'],
|
|
76
|
+
/** Apenas página de compra de token (Vercel) */
|
|
77
|
+
tokenPurchaseUrl: ['POKT_TOKEN_PURCHASE_URL'],
|
|
54
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* Migração: quem tinha a URL antiga da Vercel em API ou portal passa a usar a Railway.
|
|
81
|
+
* A URL de compra de token não é alterada aqui.
|
|
82
|
+
*/
|
|
83
|
+
function migrateLegacyPoktUrls() {
|
|
84
|
+
const target = DEFAULT_POKT_SERVICE_BASE_URL;
|
|
85
|
+
for (const key of ['poktApiBaseUrl', 'controllerBaseUrl']) {
|
|
86
|
+
const val = config.get(key);
|
|
87
|
+
if (typeof val === 'string' && val.trim() !== '' && isLegacyVercelPoktUrl(val)) {
|
|
88
|
+
config.set(key, target);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
migrateLegacyPoktUrls();
|
|
55
93
|
export function getOpenAIApiKey() {
|
|
56
94
|
return readEnvFirst(env.openaiApiKey) || config.get('openaiApiKey') || '';
|
|
57
95
|
}
|
|
@@ -75,12 +113,28 @@ export function getOllamaCloudApiKey() {
|
|
|
75
113
|
export function getPoktToken() {
|
|
76
114
|
return readEnvFirst(env.poktToken) || config.get('poktToken') || '';
|
|
77
115
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
116
|
+
/** Base da API só para provider `controller` (Bearer Pokt). OpenAI direto usa outro ramo no getClient. */
|
|
117
|
+
export function getPoktApiBaseUrl() {
|
|
118
|
+
const fromEnv = readEnvFirst(env.poktApiBaseUrl);
|
|
119
|
+
const url = fromEnv || config.get('poktApiBaseUrl') || DEFAULT_POKT_SERVICE_BASE_URL;
|
|
120
|
+
return normalizeBaseUrl(url);
|
|
121
|
+
}
|
|
122
|
+
/** Painel e links gerais (Railway), exceto compra de token — ver getTokenPurchaseUrl(). */
|
|
123
|
+
export function getProPortalBaseUrl() {
|
|
124
|
+
const fromEnv = readEnvFirst(env.proPortalUrl);
|
|
125
|
+
const url = fromEnv || config.get('controllerBaseUrl') || DEFAULT_POKT_SERVICE_BASE_URL;
|
|
126
|
+
return normalizeBaseUrl(url);
|
|
127
|
+
}
|
|
128
|
+
/** Somente comprar token / checkout — Vercel (Controller). Usado por `pokt pro`. */
|
|
129
|
+
export function getTokenPurchaseUrl() {
|
|
130
|
+
const fromEnv = readEnvFirst(env.tokenPurchaseUrl);
|
|
131
|
+
const url = fromEnv || config.get('tokenPurchaseBaseUrl') || DEFAULT_TOKEN_PURCHASE_BASE_URL;
|
|
132
|
+
return normalizeBaseUrl(url);
|
|
133
|
+
}
|
|
134
|
+
/** @deprecated Use getPoktApiBaseUrl() ou getProPortalBaseUrl() conforme o caso. */
|
|
135
|
+
export const getControllerBaseUrl = getPoktApiBaseUrl;
|
|
136
|
+
/** URL aberta por `pokt pro` (comprar token) — Vercel por padrão. */
|
|
137
|
+
export const getProPurchaseUrl = () => getTokenPurchaseUrl();
|
|
84
138
|
/** Prioridade: modelo ativo explícito → Pokt (controller) se token setado → OpenRouter → Gemini → Ollama Cloud → Ollama local */
|
|
85
139
|
export function getEffectiveActiveModel() {
|
|
86
140
|
const explicit = config.get('activeModel');
|