codegpt-ai 1.17.0 → 1.18.0
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/ai_cli/__pycache__/updater.cpython-313.pyc +0 -0
- package/chat.py +76 -42
- package/package.json +1 -1
|
Binary file
|
package/chat.py
CHANGED
|
@@ -507,72 +507,99 @@ def save_permissions():
|
|
|
507
507
|
}, indent=2))
|
|
508
508
|
|
|
509
509
|
|
|
510
|
-
# Actions that need confirmation
|
|
510
|
+
# Actions that need confirmation — (description, risk level)
|
|
511
|
+
# Risk: CRITICAL, HIGH, MEDIUM, LOW
|
|
511
512
|
RISKY_ACTIONS = {
|
|
512
|
-
|
|
513
|
-
"
|
|
514
|
-
"
|
|
515
|
-
"tool_install":
|
|
516
|
-
"
|
|
517
|
-
"
|
|
518
|
-
|
|
519
|
-
"
|
|
520
|
-
"
|
|
521
|
-
"
|
|
522
|
-
"
|
|
523
|
-
"
|
|
524
|
-
"
|
|
525
|
-
"
|
|
526
|
-
"
|
|
527
|
-
"
|
|
528
|
-
|
|
529
|
-
"
|
|
530
|
-
"
|
|
531
|
-
"
|
|
532
|
-
"
|
|
533
|
-
"
|
|
534
|
-
"
|
|
535
|
-
"
|
|
536
|
-
"
|
|
537
|
-
"
|
|
538
|
-
"
|
|
539
|
-
"spotify":
|
|
540
|
-
"volume":
|
|
541
|
-
"brightness":
|
|
542
|
-
|
|
513
|
+
# CRITICAL — can damage system, leak data, or run arbitrary code
|
|
514
|
+
"shell": ("Run a shell command", "CRITICAL"),
|
|
515
|
+
"code_exec": ("Execute Python code", "CRITICAL"),
|
|
516
|
+
"tool_install": ("Install a new tool", "CRITICAL"),
|
|
517
|
+
"connect": ("Connect to a remote server", "CRITICAL"),
|
|
518
|
+
"pin_set": ("Set a login PIN", "CRITICAL"),
|
|
519
|
+
# HIGH — external access, data modification
|
|
520
|
+
"tool_launch": ("Launch an external AI tool", "HIGH"),
|
|
521
|
+
"open_url": ("Open a URL in browser", "HIGH"),
|
|
522
|
+
"github": ("Access GitHub", "HIGH"),
|
|
523
|
+
"delete_chat": ("Delete a saved conversation", "HIGH"),
|
|
524
|
+
"mem_clear": ("Clear all AI memories", "HIGH"),
|
|
525
|
+
"train_build": ("Build a custom AI model", "HIGH"),
|
|
526
|
+
"qr": ("Generate QR code with your IP", "HIGH"),
|
|
527
|
+
"broadcast": ("Send message to all tools", "HIGH"),
|
|
528
|
+
"system_prompt": ("Modify system prompt", "HIGH"),
|
|
529
|
+
# MEDIUM — uses resources, changes settings
|
|
530
|
+
"file_read": ("Read a file into context", "MEDIUM"),
|
|
531
|
+
"export": ("Export conversation to file", "MEDIUM"),
|
|
532
|
+
"save_chat": ("Save conversation to disk", "MEDIUM"),
|
|
533
|
+
"train_collect": ("Collect conversation as training", "MEDIUM"),
|
|
534
|
+
"mem_save": ("Save to AI memory", "MEDIUM"),
|
|
535
|
+
"agent_run": ("Run an AI agent", "MEDIUM"),
|
|
536
|
+
"swarm": ("Run agent swarm pipeline", "MEDIUM"),
|
|
537
|
+
"all_agents": ("Ask all agents at once", "MEDIUM"),
|
|
538
|
+
"race": ("Race all models", "MEDIUM"),
|
|
539
|
+
"team_chat": ("Start team chat with AIs", "MEDIUM"),
|
|
540
|
+
"spotify": ("Control Spotify", "MEDIUM"),
|
|
541
|
+
"volume": ("Change system volume", "MEDIUM"),
|
|
542
|
+
"brightness": ("Change screen brightness", "MEDIUM"),
|
|
543
|
+
# LOW — safe changes
|
|
544
|
+
"model_change": ("Switch AI model", "LOW"),
|
|
545
|
+
"persona_change": ("Change AI persona", "LOW"),
|
|
546
|
+
"compact": ("Summarize and compact conversation","LOW"),
|
|
547
|
+
"fork": ("Fork conversation", "LOW"),
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
RISK_COLORS = {
|
|
551
|
+
"CRITICAL": "bold red",
|
|
552
|
+
"HIGH": "red",
|
|
553
|
+
"MEDIUM": "yellow",
|
|
554
|
+
"LOW": "green",
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
RISK_ICONS = {
|
|
558
|
+
"CRITICAL": "☠",
|
|
559
|
+
"HIGH": "⚠",
|
|
560
|
+
"MEDIUM": "◇",
|
|
561
|
+
"LOW": "△",
|
|
543
562
|
}
|
|
544
563
|
|
|
545
564
|
|
|
546
565
|
def ask_permission(action, detail=""):
|
|
547
|
-
"""Ask user for permission before performing
|
|
566
|
+
"""Ask user for permission before performing an action.
|
|
548
567
|
Returns True if allowed, False if denied."""
|
|
549
568
|
|
|
550
569
|
# Already permanently approved
|
|
551
570
|
if action in PERMISSION_ALWAYS_ALLOW:
|
|
552
571
|
return True
|
|
553
572
|
|
|
554
|
-
#
|
|
555
|
-
|
|
573
|
+
# Get action info
|
|
574
|
+
action_info = RISKY_ACTIONS.get(action, (action, "MEDIUM"))
|
|
575
|
+
if isinstance(action_info, str):
|
|
576
|
+
action_desc, risk = action_info, "MEDIUM"
|
|
577
|
+
else:
|
|
578
|
+
action_desc, risk = action_info
|
|
579
|
+
|
|
580
|
+
risk_color = RISK_COLORS.get(risk, "yellow")
|
|
581
|
+
risk_icon = RISK_ICONS.get(risk, "?")
|
|
556
582
|
compact = is_compact()
|
|
557
583
|
|
|
558
584
|
if compact:
|
|
559
585
|
console.print(Panel(
|
|
560
586
|
Text.from_markup(
|
|
561
|
-
f"[
|
|
587
|
+
f"[{risk_color}]{risk_icon} {risk}[/]\n"
|
|
562
588
|
f" {action_desc}\n"
|
|
563
|
-
+ (f" [dim]{detail[:
|
|
589
|
+
+ (f" [dim]{detail[:35]}[/]\n" if detail else "")
|
|
564
590
|
),
|
|
565
|
-
border_style="
|
|
591
|
+
border_style=risk_color.replace("bold ", ""), padding=(0, 1), width=tw(),
|
|
566
592
|
))
|
|
567
593
|
else:
|
|
568
594
|
console.print(Panel(
|
|
569
595
|
Text.from_markup(
|
|
570
|
-
f"[
|
|
596
|
+
f"[{risk_color}]{risk_icon} Risk: {risk}[/]\n\n"
|
|
571
597
|
f" Action: [bright_cyan]{action_desc}[/]\n"
|
|
572
598
|
+ (f" Detail: [dim]{detail[:60]}[/]\n" if detail else "")
|
|
573
599
|
+ f"\n [dim](y)es (n)o (a)lways allow this[/]"
|
|
574
600
|
),
|
|
575
|
-
|
|
601
|
+
title=f"[{risk_color}]Permission[/]",
|
|
602
|
+
border_style=risk_color.replace("bold ", ""), padding=(0, 2), width=tw(),
|
|
576
603
|
))
|
|
577
604
|
|
|
578
605
|
try:
|
|
@@ -6381,10 +6408,17 @@ def main():
|
|
|
6381
6408
|
title_style="bold yellow", show_header=True, header_style="bold")
|
|
6382
6409
|
table.add_column("Action", style="bright_cyan", width=16)
|
|
6383
6410
|
table.add_column("Description", style="dim")
|
|
6411
|
+
table.add_column("Risk", width=10)
|
|
6384
6412
|
table.add_column("Status", width=10)
|
|
6385
|
-
for action,
|
|
6413
|
+
for action, info in RISKY_ACTIONS.items():
|
|
6414
|
+
if isinstance(info, tuple):
|
|
6415
|
+
desc, risk = info
|
|
6416
|
+
else:
|
|
6417
|
+
desc, risk = info, "MEDIUM"
|
|
6418
|
+
rc = RISK_COLORS.get(risk, "yellow")
|
|
6419
|
+
ri = RISK_ICONS.get(risk, "?")
|
|
6386
6420
|
status = "[green]allowed[/]" if action in PERMISSION_ALWAYS_ALLOW else "[yellow]ask[/]"
|
|
6387
|
-
table.add_row(action, desc, status)
|
|
6421
|
+
table.add_row(action, desc, f"[{rc}]{ri} {risk}[/]", status)
|
|
6388
6422
|
console.print(table)
|
|
6389
6423
|
console.print(Text(" /permissions reset — revoke all", style="dim"))
|
|
6390
6424
|
console.print()
|