krnell 3.0.3 → 3.0.5
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/bin/krnell.mjs +2 -2
- package/bridge.py +1 -1
- package/iniciar.sh +1 -1
- package/kimi.py +18 -0
- package/opencode_sync.py +81 -17
- package/package.json +1 -1
- package/painel.py +873 -210
- package/tui_core.py +160 -26
package/bin/krnell.mjs
CHANGED
|
@@ -77,9 +77,9 @@ prepararPastaUsuario();
|
|
|
77
77
|
function lerVersao() {
|
|
78
78
|
try {
|
|
79
79
|
const pkg = JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf8'));
|
|
80
|
-
return pkg.version || '3.0.
|
|
80
|
+
return pkg.version || '3.0.5';
|
|
81
81
|
} catch {
|
|
82
|
-
return '3.0.
|
|
82
|
+
return '3.0.5';
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
package/bridge.py
CHANGED
|
@@ -59,7 +59,7 @@ OPENCODE_CONTEXT_TOKENS = 300000
|
|
|
59
59
|
OPENCODE_OUTPUT_TOKENS = 64000
|
|
60
60
|
MODEL_CONTEXT_ANUNCIADO = 0 # 0 = nao ha limite de descoberta configurado
|
|
61
61
|
MODEL_OUTPUT_ANUNCIADO = 0 # limite nativo conhecido; independente do contexto escolhido
|
|
62
|
-
BRIDGE_VERSION = '3.0.
|
|
62
|
+
BRIDGE_VERSION = '3.0.5'
|
|
63
63
|
PROVIDER_URLS = {'unorouter': 'https://api.unorouter.com/v1',
|
|
64
64
|
'tokenharbor': 'https://tokenharbor.ai/v1',
|
|
65
65
|
# Contas do app WorkBuddy: o fluxo real (login, headers de
|
package/iniciar.sh
CHANGED
package/kimi.py
CHANGED
|
@@ -30,6 +30,8 @@ FALHAS_PARA_REINICIAR = 3
|
|
|
30
30
|
ESPERAS_DE_REINICIO = (3.0, 6.0, 15.0, 30.0, 60.0)
|
|
31
31
|
ARQUIVO_LOG = 'kimi.log'
|
|
32
32
|
|
|
33
|
+
MODELO_PADRAO = 'kimi-k3.1-pro'
|
|
34
|
+
MODELO_ANTIGRAVITY_PADRAO = 'gemini-4-neon'
|
|
33
35
|
PROVEDORES_MOTOR = ('kimi', 'nvidia', 'antigravity')
|
|
34
36
|
MODELOS_NVIDIA = ('kimi-k3.1-pro', 'minimax-m3.1-flash')
|
|
35
37
|
MODELOS_ANTIGRAVITY = (
|
|
@@ -315,6 +317,22 @@ def antigravity_ativar_conta(hint: str, porta: int = PORTA_PADRAO, timeout: floa
|
|
|
315
317
|
return res
|
|
316
318
|
|
|
317
319
|
|
|
320
|
+
def antigravity_login_url(porta: int = PORTA_PADRAO, timeout: float = 5.0) -> tuple[str, str]:
|
|
321
|
+
"""Inicia fluxo OAuth do Antigravity e retorna `(url, state)`."""
|
|
322
|
+
res = antigravity_iniciar_login(porta=porta, timeout=timeout)
|
|
323
|
+
return str(res.get('url') or ''), str(res.get('state') or '')
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
def antigravity_completar(entrada: str, state: str = '', porta: int = PORTA_PADRAO, timeout: float = 20.0) -> dict:
|
|
327
|
+
"""Completa o OAuth do Antigravity com a URL/código colado."""
|
|
328
|
+
return antigravity_completar_login(state=state, entrada=entrada, porta=porta, timeout=timeout)
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
def antigravity_logout(email: str = '', porta: int = PORTA_PADRAO, timeout: float = 5.0) -> dict:
|
|
332
|
+
"""Remove conta conectada do Antigravity."""
|
|
333
|
+
return antigravity_remover_conta(hint=email, porta=porta, timeout=timeout)
|
|
334
|
+
|
|
335
|
+
|
|
318
336
|
def antigravity_remover_conta(hint: str, porta: int = PORTA_PADRAO, timeout: float = 5.0) -> dict:
|
|
319
337
|
res = _pedir(
|
|
320
338
|
porta,
|
package/opencode_sync.py
CHANGED
|
@@ -8,15 +8,60 @@ import shutil
|
|
|
8
8
|
from pathlib import Path
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
def _bases_home_opencode() -> list[Path]:
|
|
12
|
+
"""Homes onde o OpenCode pode morar (atual, XDG, Termux e proot-distro)."""
|
|
13
|
+
bases: list[Path] = []
|
|
14
|
+
vistos: set[str] = set()
|
|
15
|
+
|
|
16
|
+
def add(p: Path | None):
|
|
17
|
+
if not p:
|
|
18
|
+
return
|
|
19
|
+
chave = str(p)
|
|
20
|
+
if chave not in vistos:
|
|
21
|
+
vistos.add(chave)
|
|
22
|
+
bases.append(p)
|
|
23
|
+
|
|
24
|
+
add(Path.home())
|
|
25
|
+
# No Termux nativo, o usuário frequentemente instala o OpenCode dentro de um
|
|
26
|
+
# container proot-distro (ex.: ubuntu/debian) em $PREFIX/var/lib/proot-distro.
|
|
27
|
+
prefix = os.environ.get('PREFIX', '')
|
|
28
|
+
if prefix and 'com.termux' in prefix:
|
|
29
|
+
containers = Path(prefix) / 'var' / 'lib' / 'proot-distro' / 'installed-rootfs'
|
|
30
|
+
containers_alt = Path(prefix) / 'var' / 'lib' / 'proot-distro' / 'containers'
|
|
31
|
+
for raiz_c in (containers, containers_alt):
|
|
32
|
+
if not raiz_c.is_dir():
|
|
33
|
+
continue
|
|
34
|
+
try:
|
|
35
|
+
for distro in sorted(raiz_c.iterdir()):
|
|
36
|
+
for sub in (distro / 'root', distro / 'rootfs' / 'root'):
|
|
37
|
+
if (sub / '.config' / 'opencode').exists() or (sub / '.opencode').exists():
|
|
38
|
+
add(sub)
|
|
39
|
+
except OSError:
|
|
40
|
+
pass
|
|
41
|
+
return bases
|
|
42
|
+
|
|
43
|
+
|
|
11
44
|
def candidatos_config_opencode() -> list[Path]:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
45
|
+
lista: list[Path] = []
|
|
46
|
+
vistos: set[str] = set()
|
|
47
|
+
|
|
48
|
+
def add(p: Path):
|
|
49
|
+
chave = str(p)
|
|
50
|
+
if chave not in vistos:
|
|
51
|
+
vistos.add(chave)
|
|
52
|
+
lista.append(p)
|
|
53
|
+
|
|
54
|
+
xdg = os.environ.get('XDG_CONFIG_HOME')
|
|
55
|
+
if xdg:
|
|
56
|
+
add(Path(xdg) / 'opencode' / 'opencode.jsonc')
|
|
57
|
+
add(Path(xdg) / 'opencode' / 'opencode.json')
|
|
58
|
+
for base in _bases_home_opencode():
|
|
59
|
+
add(base / '.config' / 'opencode' / 'opencode.jsonc')
|
|
60
|
+
add(base / '.config' / 'opencode' / 'opencode.json')
|
|
17
61
|
if os.name == 'nt':
|
|
18
|
-
appdata = os.environ.get('APPDATA') or str(home / 'AppData' / 'Roaming')
|
|
19
|
-
|
|
62
|
+
appdata = os.environ.get('APPDATA') or str(Path.home() / 'AppData' / 'Roaming')
|
|
63
|
+
add(Path(appdata) / 'opencode' / 'opencode.jsonc')
|
|
64
|
+
add(Path(appdata) / 'opencode' / 'opencode.json')
|
|
20
65
|
return lista
|
|
21
66
|
|
|
22
67
|
|
|
@@ -129,21 +174,40 @@ def _substituir_ou_inserir_provedor(texto: str, provider_id: str, bloco: str) ->
|
|
|
129
174
|
|
|
130
175
|
|
|
131
176
|
def opencode_detectado() -> bool:
|
|
132
|
-
"""Detecta se o OpenCode está instalado (
|
|
177
|
+
"""Detecta se o OpenCode está instalado (PATH, npm global, ~/.opencode, XDG ou proot)."""
|
|
133
178
|
if shutil.which('opencode'):
|
|
134
179
|
return True
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
180
|
+
prefix = os.environ.get('PREFIX', '')
|
|
181
|
+
extras: list[Path] = []
|
|
182
|
+
if prefix:
|
|
183
|
+
extras.extend([
|
|
184
|
+
Path(prefix) / 'bin' / 'opencode',
|
|
185
|
+
Path(prefix) / 'lib' / 'node_modules' / '@opencode' / 'cli',
|
|
186
|
+
Path(prefix) / 'lib' / 'node_modules' / 'opencode-ai',
|
|
187
|
+
])
|
|
188
|
+
xdg = os.environ.get('XDG_CONFIG_HOME')
|
|
189
|
+
if xdg:
|
|
190
|
+
extras.append(Path(xdg) / 'opencode')
|
|
191
|
+
for base in _bases_home_opencode():
|
|
192
|
+
extras.extend([
|
|
193
|
+
base / '.opencode' / 'bin' / 'opencode',
|
|
194
|
+
base / '.opencode' / 'bin' / 'opencode.exe',
|
|
195
|
+
base / '.local' / 'bin' / 'opencode',
|
|
196
|
+
base / '.bun' / 'bin' / 'opencode',
|
|
197
|
+
base / '.npm-global' / 'bin' / 'opencode',
|
|
198
|
+
base / '.config' / 'opencode',
|
|
199
|
+
])
|
|
200
|
+
for p in extras:
|
|
141
201
|
if p.exists():
|
|
142
202
|
return True
|
|
143
203
|
if os.name == 'nt':
|
|
144
|
-
appdata = os.environ.get('APPDATA') or str(home / 'AppData' / 'Roaming')
|
|
145
|
-
|
|
146
|
-
|
|
204
|
+
appdata = os.environ.get('APPDATA') or str(Path.home() / 'AppData' / 'Roaming')
|
|
205
|
+
for p in (
|
|
206
|
+
Path(appdata) / 'opencode',
|
|
207
|
+
Path(appdata) / 'npm' / 'opencode.cmd',
|
|
208
|
+
):
|
|
209
|
+
if p.exists():
|
|
210
|
+
return True
|
|
147
211
|
return False
|
|
148
212
|
|
|
149
213
|
|
package/package.json
CHANGED