-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagent.py
More file actions
61 lines (47 loc) · 1.83 KB
/
Copy pathagent.py
File metadata and controls
61 lines (47 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""Bash tool agent — fixture for bash tool capability testing.
Exercises bash tool capabilities to verify:
- stdout/stderr capture (echo)
- Exit code propagation (exit-code)
- Working directory isolation (cwd)
- Environment variable injection (env)
- Multi-command sequences (clone)
"""
from friday_agent_sdk import agent, err, ok, parse_input, run
@agent(id="bash-test", version="1.0.0", description="Exercises bash tool capabilities")
def execute(prompt, ctx):
cmd = parse_input(prompt)
action = cmd.get("action", "echo")
if action == "dump-prompt":
return ok({"raw_prompt": prompt[:2000]})
if action == "list-tools":
tools = ctx.tools.list()
return ok({"tools": [t.name for t in tools]})
if action == "echo":
result = ctx.tools.call("bash", {"command": "echo hello"})
return ok({"bash_result": result})
if action == "exit-code":
result = ctx.tools.call("bash", {"command": "exit 42"})
return ok({"bash_result": result})
if action == "cwd":
result = ctx.tools.call("bash", {"command": "pwd", "cwd": "/tmp"})
return ok({"bash_result": result})
if action == "env":
result = ctx.tools.call(
"bash",
{
"command": "echo $QA_TEST_VAR",
"env": {"QA_TEST_VAR": "host-bridge-works"},
},
)
return ok({"bash_result": result})
if action == "clone":
repo_url = cmd["repo_url"]
result = ctx.tools.call(
"bash",
{"command": (f"git clone --depth 1 {repo_url} /tmp/qa-bash-clone-test && ls /tmp/qa-bash-clone-test")},
)
ctx.tools.call("bash", {"command": "rm -rf /tmp/qa-bash-clone-test"})
return ok({"bash_result": result})
return err(f"Unknown action: {action}")
if __name__ == "__main__":
run()