@votadev/tooncode 2.2.7 → 2.2.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/tooncode.py +56 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@votadev/tooncode",
3
- "version": "2.2.7",
3
+ "version": "2.2.9",
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",
package/tooncode.py CHANGED
@@ -8,7 +8,7 @@ Usage:
8
8
  python tooncode.py
9
9
  """
10
10
 
11
- VERSION = "2.2.7"
11
+ VERSION = "2.2.9"
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 == 200:
3354
- data = resp.json()
3355
- answer = ""
3356
- for block in data.get("content", []):
3357
- if block.get("type") == "text":
3358
- answer += block.get("text", "")
3359
- if answer:
3360
- console.print(Panel(
3361
- Text(answer[:500] + ("..." if len(answer) > 500 else ""), style="dim"),
3362
- title=f"[bold magenta]Boss Answer ({MODEL})[/bold magenta]",
3363
- border_style="magenta",
3364
- ))
3365
- return answer
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]Fallback also failed: {e}[/error]")
3404
+ console.print(f"[error]Boss fallback error: {e}[/error]")
3368
3405
 
3369
3406
  return "[bosshelp: all methods failed]"
3370
3407
 
@@ -4944,6 +4981,10 @@ def main(_initial_prompt=None):
4944
4981
  def _(event):
4945
4982
  raise EOFError()
4946
4983
 
4984
+ @kb.add("escape", "escape")
4985
+ def _(event):
4986
+ event.current_buffer.reset()
4987
+
4947
4988
  def _bottom_toolbar():
4948
4989
  """Claude Code-style bottom toolbar."""
4949
4990
  ctx_max = CONTEXT_WINDOWS.get(MODEL, 200_000)