From 0e3d7053c4d1a774d43e241ff04571d57b9a6673 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Sun, 11 Oct 2026 14:24:45 +0300 Subject: feat: trust system --- llm.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'llm.py') diff --git a/llm.py b/llm.py index b21e81e..649f927 100755 --- a/llm.py +++ b/llm.py @@ -27,6 +27,8 @@ class AgentConfig: workdir: Path actions: List["Action"] + trustlevels: Dict[str, int] + trustlevel: int client = OpenAI( @@ -105,9 +107,16 @@ def query_agent(query: str, config: AgentConfig, state=()): f = first(config.actions, lambda f: f.name == action_name) if f is not None: - result_json = f(action, config) + desc = f.formatter(action) + if ( + config.trustlevels[action_name] > config.trustlevel + and not input(f"Perform {desc}? [y/N] ") == "y" + ): + result_json = {"status": "error", "reason": "Permission denied by user"} + else: + result_json = f(action, config) result_jsons.append(result_json) - replacements.append((m.start(), m.end(), action_name)) + replacements.append((m.start(), m.end(), desc)) replaced_res = "" i = 0 @@ -133,7 +142,18 @@ def main(): ) args = parser.parse_args() - config = AgentConfig(workdir=args.workdir, actions=[ls, read, write, tldr, shell]) + config = AgentConfig( + workdir=args.workdir, + actions=[ls, read, write, tldr, shell], + trustlevels={ + "ls": 0, + "read": 0, + "tldr": 0, + "write": 1, + "shell": 2, + }, + trustlevel=0, + ) state = ( { -- cgit v1.3.1