@votadev/tooncode 2.2.6 → 2.2.8
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 +2 -2
- package/tooncode.py +55 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@votadev/tooncode",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.8",
|
|
4
4
|
"description": "🇹🇭 Thai Coding Agent CLI — Claude Code alternative powered by free models. 20 tools, multi-agent team, browser automation, MCP servers.",
|
|
5
5
|
"author": "VotaLab",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,4 +39,4 @@
|
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": ">=16"
|
|
41
41
|
}
|
|
42
|
-
}
|
|
42
|
+
}
|
package/tooncode.py
CHANGED
|
@@ -8,7 +8,7 @@ Usage:
|
|
|
8
8
|
python tooncode.py
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
|
-
VERSION = "2.2.
|
|
11
|
+
VERSION = "2.2.8"
|
|
12
12
|
|
|
13
13
|
import httpx
|
|
14
14
|
import json
|
|
@@ -3350,21 +3350,58 @@ Be specific. Give copy-paste ready solutions."""
|
|
|
3350
3350
|
|
|
3351
3351
|
with httpx.Client(timeout=httpx.Timeout(60.0, connect=15.0)) as client:
|
|
3352
3352
|
resp = client.post(_get_current_api_url(), headers=make_request_headers(), json=body)
|
|
3353
|
-
if resp.status_code
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
console.print(
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3353
|
+
if resp.status_code != 200:
|
|
3354
|
+
err_text = resp.text[:300]
|
|
3355
|
+
console.print(f"[error]Boss API error ({resp.status_code}): {err_text}[/error]")
|
|
3356
|
+
# Try other models as fallback
|
|
3357
|
+
for fallback_model in AVAILABLE_MODELS:
|
|
3358
|
+
if fallback_model == MODEL:
|
|
3359
|
+
continue
|
|
3360
|
+
console.print(f"[dim]Trying {fallback_model}...[/dim]")
|
|
3361
|
+
body["model"] = fallback_model
|
|
3362
|
+
if fallback_model in NO_SAMPLING_PARAMS:
|
|
3363
|
+
body.pop("temperature", None)
|
|
3364
|
+
body.pop("top_k", None)
|
|
3365
|
+
body.pop("top_p", None)
|
|
3366
|
+
try:
|
|
3367
|
+
# Use that model's endpoint if it has one
|
|
3368
|
+
mcfg = _get_model_config(fallback_model)
|
|
3369
|
+
fb_url = mcfg.get("api_url", _get_current_api_url())
|
|
3370
|
+
fb_headers = dict(make_request_headers())
|
|
3371
|
+
if mcfg.get("api_key"):
|
|
3372
|
+
fb_headers["x-api-key"] = mcfg["api_key"]
|
|
3373
|
+
resp2 = client.post(fb_url, headers=fb_headers, json=body)
|
|
3374
|
+
if resp2.status_code == 200:
|
|
3375
|
+
data2 = resp2.json()
|
|
3376
|
+
for block in data2.get("content", []):
|
|
3377
|
+
if block.get("type") == "text" and block.get("text"):
|
|
3378
|
+
answer = block["text"]
|
|
3379
|
+
console.print(Panel(
|
|
3380
|
+
Text(answer[:500] + ("..." if len(answer) > 500 else ""), style="dim"),
|
|
3381
|
+
title=f"[bold magenta]Boss Answer ({fallback_model})[/bold magenta]",
|
|
3382
|
+
border_style="magenta",
|
|
3383
|
+
))
|
|
3384
|
+
return answer
|
|
3385
|
+
except Exception:
|
|
3386
|
+
continue
|
|
3387
|
+
return "[bosshelp: all models failed]"
|
|
3388
|
+
|
|
3389
|
+
data = resp.json()
|
|
3390
|
+
answer = ""
|
|
3391
|
+
for block in data.get("content", []):
|
|
3392
|
+
if block.get("type") == "text":
|
|
3393
|
+
answer += block.get("text", "")
|
|
3394
|
+
if answer:
|
|
3395
|
+
console.print(Panel(
|
|
3396
|
+
Text(answer[:500] + ("..." if len(answer) > 500 else ""), style="dim"),
|
|
3397
|
+
title=f"[bold magenta]Boss Answer ({MODEL})[/bold magenta]",
|
|
3398
|
+
border_style="magenta",
|
|
3399
|
+
))
|
|
3400
|
+
return answer
|
|
3401
|
+
else:
|
|
3402
|
+
console.print("[yellow]Boss returned empty response[/yellow]")
|
|
3366
3403
|
except Exception as e:
|
|
3367
|
-
console.print(f"[error]
|
|
3404
|
+
console.print(f"[error]Boss fallback error: {e}[/error]")
|
|
3368
3405
|
|
|
3369
3406
|
return "[bosshelp: all methods failed]"
|
|
3370
3407
|
|
|
@@ -4634,7 +4671,9 @@ OUTPUT THE JSON ARRAY NOW:"""
|
|
|
4634
4671
|
shell=True, capture_output=True, text=True,
|
|
4635
4672
|
encoding="utf-8", errors="replace", timeout=120)
|
|
4636
4673
|
if r2.returncode == 0:
|
|
4637
|
-
console.print(f"[bold green]Updated to v{latest}!
|
|
4674
|
+
console.print(f"[bold green]Updated to v{latest}! Restarting...[/bold green]")
|
|
4675
|
+
# Auto-restart with same args
|
|
4676
|
+
os.execv(sys.executable, [sys.executable] + sys.argv)
|
|
4638
4677
|
else:
|
|
4639
4678
|
console.print(f"[error]Update failed: {r2.stderr[:200]}[/error]")
|
|
4640
4679
|
console.print("[dim]Try manually: npm install -g @votadev/tooncode[/dim]")
|