by-tiny-agents 0.2.3__py3-none-any.whl
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.
- Packages/colors.py +144 -0
- Packages/prettyResolver.py +75 -0
- Tools/hourNow/hourNow.py +5 -0
- Tools/runInShell/runInShell.py +38 -0
- Tools/tools.json +56 -0
- Tools/toolsCall.json +5 -0
- by_tiny_agents-0.2.3.dist-info/METADATA +389 -0
- by_tiny_agents-0.2.3.dist-info/RECORD +20 -0
- by_tiny_agents-0.2.3.dist-info/WHEEL +5 -0
- by_tiny_agents-0.2.3.dist-info/licenses/LICENSE +21 -0
- by_tiny_agents-0.2.3.dist-info/top_level.txt +4 -0
- src/AgentHarness.py +118 -0
- src/Panel/Panel.py +882 -0
- src/Panel/themes.py +37 -0
- src/tinyAgents.py +242 -0
- tinyAgents/colors.py +3 -0
- tinyAgents/core.py +29 -0
- tinyAgents/formatting.py +5 -0
- tinyAgents/harness.py +5 -0
- tinyAgents/panel.py +5 -0
Packages/colors.py
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import time
|
|
4
|
+
import random
|
|
5
|
+
|
|
6
|
+
RESET = "\033[0m"
|
|
7
|
+
BOLD = "\033[1m"
|
|
8
|
+
DIM = "\033[2m"
|
|
9
|
+
ITALIC = "\033[3m"
|
|
10
|
+
UNDERLINE = "\033[4m"
|
|
11
|
+
BLINK = "\033[5m"
|
|
12
|
+
REVERSE = "\033[7m"
|
|
13
|
+
HIDDEN = "\033[8m"
|
|
14
|
+
STRIKE = "\033[9m"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
BLACK = "\033[30m"
|
|
18
|
+
RED = "\033[31m"
|
|
19
|
+
GREEN = "\033[32m"
|
|
20
|
+
YELLOW = "\033[33m"
|
|
21
|
+
BLUE = "\033[34m"
|
|
22
|
+
MAGENTA = "\033[35m"
|
|
23
|
+
CYAN = "\033[36m"
|
|
24
|
+
WHITE = "\033[37m"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
BRIGHT_BLACK = "\033[90m"
|
|
28
|
+
BRIGHT_RED = "\033[91m"
|
|
29
|
+
BRIGHT_GREEN = "\033[92m"
|
|
30
|
+
BRIGHT_YELLOW = "\033[93m"
|
|
31
|
+
BRIGHT_BLUE = "\033[94m"
|
|
32
|
+
BRIGHT_MAGENTA = "\033[95m"
|
|
33
|
+
BRIGHT_CYAN = "\033[96m"
|
|
34
|
+
BRIGHT_WHITE = "\033[97m"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
BG_BLACK = "\033[40m"
|
|
38
|
+
BG_RED = "\033[41m"
|
|
39
|
+
BG_GREEN = "\033[42m"
|
|
40
|
+
BG_YELLOW = "\033[43m"
|
|
41
|
+
BG_BLUE = "\033[44m"
|
|
42
|
+
BG_MAGENTA = "\033[45m"
|
|
43
|
+
BG_CYAN = "\033[46m"
|
|
44
|
+
BG_WHITE = "\033[47m"
|
|
45
|
+
|
|
46
|
+
BG_BRIGHT_BLACK = "\033[100m"
|
|
47
|
+
BG_BRIGHT_RED = "\033[101m"
|
|
48
|
+
BG_BRIGHT_GREEN = "\033[102m"
|
|
49
|
+
BG_BRIGHT_YELLOW = "\033[103m"
|
|
50
|
+
BG_BRIGHT_BLUE = "\033[104m"
|
|
51
|
+
BG_BRIGHT_MAGENTA = "\033[105m"
|
|
52
|
+
BG_BRIGHT_CYAN = "\033[106m"
|
|
53
|
+
BG_BRIGHT_WHITE = "\033[107m"
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def rgb(r, g, b):
|
|
57
|
+
return f"\033[38;2;{r};{g};{b}m"
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def bg_rgb(r, g, b):
|
|
61
|
+
return f"\033[48;2;{r};{g};{b}m"
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def hex_color(value):
|
|
65
|
+
value = value.lstrip("#")
|
|
66
|
+
r, g, b = (int(value[i : i + 2], 16) for i in (0, 2, 4))
|
|
67
|
+
return rgb(r, g, b)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def clear():
|
|
71
|
+
os.system("cls" if os.name == "nt" else "clear")
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def slow(text, delay=0.03, color=""):
|
|
75
|
+
for char in text:
|
|
76
|
+
sys.stdout.write(color + char + RESET)
|
|
77
|
+
sys.stdout.flush()
|
|
78
|
+
time.sleep(delay)
|
|
79
|
+
print()
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def loading(text="Loading", duration=2, color=CYAN):
|
|
83
|
+
frames = ["|", "/", "-", "\\"]
|
|
84
|
+
end = time.time() + duration
|
|
85
|
+
|
|
86
|
+
while time.time() < end:
|
|
87
|
+
for frame in frames:
|
|
88
|
+
sys.stdout.write(f"\r{color}{frame} {text}...{RESET}")
|
|
89
|
+
sys.stdout.flush()
|
|
90
|
+
time.sleep(0.1)
|
|
91
|
+
if time.time() >= end:
|
|
92
|
+
break
|
|
93
|
+
|
|
94
|
+
print(f"\r{GREEN}✓ {text} completed!{RESET}")
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def progress(total=20, delay=0.05, color=GREEN):
|
|
98
|
+
for i in range(total + 1):
|
|
99
|
+
percent = int(i / total * 100)
|
|
100
|
+
bar = "█" * i + "░" * (total - i)
|
|
101
|
+
|
|
102
|
+
sys.stdout.write(f"\r{color}[{bar}] {percent}%{RESET}")
|
|
103
|
+
sys.stdout.flush()
|
|
104
|
+
time.sleep(delay)
|
|
105
|
+
|
|
106
|
+
print()
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def rainbow(text):
|
|
110
|
+
colors = [RED, YELLOW, GREEN, CYAN, BLUE, MAGENTA]
|
|
111
|
+
for i, char in enumerate(text):
|
|
112
|
+
sys.stdout.write(colors[i % len(colors)] + char)
|
|
113
|
+
print(RESET, end="")
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def flash(text, times=3, delay=0.2, color=YELLOW):
|
|
117
|
+
for _ in range(times):
|
|
118
|
+
print(f"\r{color}{BOLD}{text}{RESET}", end="", flush=True)
|
|
119
|
+
time.sleep(delay)
|
|
120
|
+
print("\r" + " " * len(text), end="", flush=True)
|
|
121
|
+
time.sleep(delay)
|
|
122
|
+
print(f"\r{color}{BOLD}{text}{RESET}")
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def random_color(text):
|
|
126
|
+
colors = [RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, BRIGHT_WHITE]
|
|
127
|
+
print(f"{random.choice(colors)}{text}{RESET}")
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def box(text, color=CYAN):
|
|
131
|
+
lines = text.splitlines() or [""]
|
|
132
|
+
width = max(map(len, lines))
|
|
133
|
+
border = "+" + "-" * (width + 2) + "+"
|
|
134
|
+
|
|
135
|
+
print(f"{color}{border}{RESET}")
|
|
136
|
+
for line in lines:
|
|
137
|
+
print(f"{color}|{RESET} {line:<{width}} {color}|{RESET}")
|
|
138
|
+
print(f"{color}{border}{RESET}")
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def title(text, color=BRIGHT_CYAN):
|
|
142
|
+
print(f"\n{color}{BOLD}{'=' * 40}")
|
|
143
|
+
print(f" {text}")
|
|
144
|
+
print(f"{'=' * 40}{RESET}\n")
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
from Packages.colors import *
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def prettyResolve(text):
|
|
5
|
+
result = []
|
|
6
|
+
|
|
7
|
+
bold = False
|
|
8
|
+
title_color = ""
|
|
9
|
+
title_active = False
|
|
10
|
+
line_start = True
|
|
11
|
+
i = 0
|
|
12
|
+
|
|
13
|
+
def apply_style():
|
|
14
|
+
result.append((title_color or "") + (BOLD if bold or title_active else ""))
|
|
15
|
+
|
|
16
|
+
while i < len(text):
|
|
17
|
+
if line_start:
|
|
18
|
+
if text[i : i + 4] == "### ":
|
|
19
|
+
title_color = CYAN
|
|
20
|
+
title_active = True
|
|
21
|
+
result.append(title_color + BOLD)
|
|
22
|
+
i += 4
|
|
23
|
+
line_start = False
|
|
24
|
+
continue
|
|
25
|
+
|
|
26
|
+
elif text[i : i + 3] == "## ":
|
|
27
|
+
title_color = BLUE
|
|
28
|
+
title_active = True
|
|
29
|
+
result.append(title_color + BOLD)
|
|
30
|
+
i += 3
|
|
31
|
+
line_start = False
|
|
32
|
+
continue
|
|
33
|
+
|
|
34
|
+
elif text[i : i + 2] == "# ":
|
|
35
|
+
title_color = YELLOW
|
|
36
|
+
title_active = True
|
|
37
|
+
result.append(title_color + BOLD)
|
|
38
|
+
i += 2
|
|
39
|
+
line_start = False
|
|
40
|
+
continue
|
|
41
|
+
|
|
42
|
+
if text[i : i + 2] == "**":
|
|
43
|
+
bold = not bold
|
|
44
|
+
result.append(RESET)
|
|
45
|
+
apply_style()
|
|
46
|
+
i += 2
|
|
47
|
+
line_start = False
|
|
48
|
+
continue
|
|
49
|
+
|
|
50
|
+
if text[i] == "*":
|
|
51
|
+
bold = not bold
|
|
52
|
+
result.append(RESET)
|
|
53
|
+
apply_style()
|
|
54
|
+
i += 1
|
|
55
|
+
line_start = False
|
|
56
|
+
continue
|
|
57
|
+
|
|
58
|
+
char = text[i]
|
|
59
|
+
result.append(char)
|
|
60
|
+
i += 1
|
|
61
|
+
|
|
62
|
+
if char == "\n":
|
|
63
|
+
|
|
64
|
+
result.append(RESET)
|
|
65
|
+
|
|
66
|
+
bold = False
|
|
67
|
+
title_color = ""
|
|
68
|
+
title_active = False
|
|
69
|
+
line_start = True
|
|
70
|
+
else:
|
|
71
|
+
line_start = False
|
|
72
|
+
|
|
73
|
+
result.append(RESET)
|
|
74
|
+
|
|
75
|
+
return "".join(result)
|
Tools/hourNow/hourNow.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import subprocess
|
|
2
|
+
from Packages.colors import DIM, RESET
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def runInShell(cmd):
|
|
6
|
+
logs = []
|
|
7
|
+
|
|
8
|
+
process = subprocess.Popen(
|
|
9
|
+
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
if process.stdout:
|
|
13
|
+
for line in process.stdout:
|
|
14
|
+
logs.append(line)
|
|
15
|
+
|
|
16
|
+
code = process.wait()
|
|
17
|
+
|
|
18
|
+
return {"logs": logs, "exitCode": code}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def runInShellCool(cmd, write=print):
|
|
22
|
+
write(f"{DIM}$ {cmd}{RESET}")
|
|
23
|
+
logs = []
|
|
24
|
+
|
|
25
|
+
process = subprocess.Popen(
|
|
26
|
+
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
if process.stdout:
|
|
30
|
+
for line in process.stdout:
|
|
31
|
+
logs.append(line)
|
|
32
|
+
text = line.rstrip("")
|
|
33
|
+
write(f"{DIM}{text}{RESET}")
|
|
34
|
+
|
|
35
|
+
code = process.wait()
|
|
36
|
+
write(f"{DIM}Exited with [{code}]{RESET}")
|
|
37
|
+
|
|
38
|
+
return {"logs": logs, "exitCode": code}
|
Tools/tools.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"tools": [
|
|
3
|
+
{
|
|
4
|
+
"type": "function",
|
|
5
|
+
"function": {
|
|
6
|
+
"name": "hourNow",
|
|
7
|
+
"description": "Return the current UTC date and time.",
|
|
8
|
+
"parameters": {
|
|
9
|
+
"type": "object",
|
|
10
|
+
"properties": {},
|
|
11
|
+
"additionalProperties": false
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"type": "function",
|
|
17
|
+
"function": {
|
|
18
|
+
"name": "runInShell",
|
|
19
|
+
"description": "Run a shell command and return its output and exit code.",
|
|
20
|
+
"parameters": {
|
|
21
|
+
"type": "object",
|
|
22
|
+
"properties": {
|
|
23
|
+
"cmd": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "The command to execute in the shell."
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"required": [
|
|
29
|
+
"cmd"
|
|
30
|
+
],
|
|
31
|
+
"additionalProperties": false
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"type": "function",
|
|
37
|
+
"function": {
|
|
38
|
+
"name": "runInShellCool",
|
|
39
|
+
"description": "Run a shell command, display its output, and return its output and exit code.",
|
|
40
|
+
"parameters": {
|
|
41
|
+
"type": "object",
|
|
42
|
+
"properties": {
|
|
43
|
+
"cmd": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"description": "The command to execute in the shell."
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"required": [
|
|
49
|
+
"cmd"
|
|
50
|
+
],
|
|
51
|
+
"additionalProperties": false
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|