@brandon_9527/tcode 1.0.9 → 1.0.11
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/dist/python-src/.env +4 -4
- package/dist/python-src/README.md +8 -0
- package/dist/python-src/main.py +14 -6
- package/dist/python-src/src/agents/token_tracker.py +4 -4
- package/dist/python-src/src/claw/channels/feishu.py +8 -8
- package/dist/python-src/src/claw/cron/service.py +24 -24
- package/dist/python-src/src/core/context.py +11 -11
- package/dist/python-src/src/managers/manager_agent.py +7 -7
- package/dist/python-src/src/managers/sandbox.py +3 -3
- package/dist/python-src/src/middlewares/subagents.py +4 -4
- package/dist/python-src/src/middlewares/summary.py +31 -31
- package/dist/python-src/src/stream/formatter.py +19 -19
- package/dist/python-src/src/stream/handler_with_tracker.py +7 -7
- package/dist/python-src/src/trackers/token/report.py +2 -2
- package/dist/python-src/src/trackers/token/tracker.py +8 -8
- package/dist/python-src/src/tui/chatui.py +10 -10
- package/dist/python-src/src/tui/clawtui.py +26 -20
- package/dist/python-src/src/tui/components/tlist.py +6 -6
- package/dist/python-src/src/tui/components/tscroll_panel.py +4 -4
- package/dist/python-src/src/tui/components/tscroll_panel_old.py +8 -8
- package/dist/python-src/src/tui/utils/trender.py +17 -17
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ from prompt_toolkit.layout.controls import UIControl,UIContent
|
|
|
6
6
|
from prompt_toolkit.data_structures import Point
|
|
7
7
|
from prompt_toolkit.formatted_text import ANSI
|
|
8
8
|
class ScrollableFormattedLogControl(FormattedTextControl):
|
|
9
|
-
def __init__(A):A.lines=[];A.scroll_offset=0;A._height=0;A.last_count=0;super().__init__(A.
|
|
9
|
+
def __init__(A):A.lines=[];A.scroll_offset=0;A._height=0;A.last_count=0;super().__init__(A.bg,focusable=True,show_cursor=False)
|
|
10
10
|
def clear(A):A.lines=[];A.scroll_offset=0;A.last_count=0;A._height=0
|
|
11
11
|
def append_text(A,ansi_text):B=ansi_text.splitlines();A.lines.extend(B);A.last_count=len(B);A.bh()
|
|
12
12
|
def update_last(A,ansi_text):
|
|
@@ -18,18 +18,18 @@ class ScrollableFormattedLogControl(FormattedTextControl):
|
|
|
18
18
|
if A._height:A.scroll_offset=max(0,len(A.lines)-A._height)
|
|
19
19
|
def bh(A):
|
|
20
20
|
if A._height:A.scroll_offset=max(0,len(A.lines)-A._height)
|
|
21
|
-
def
|
|
21
|
+
def bf(A,amount):
|
|
22
22
|
if A._height:B=max(0,len(A.lines)-A._height);A.scroll_offset=max(0,min(A.scroll_offset+amount,B))
|
|
23
23
|
def is_focusable(A):return True
|
|
24
|
-
def
|
|
24
|
+
def bg(A):
|
|
25
25
|
C=A._height or 100;D=A.lines[A.scroll_offset:A.scroll_offset+C];B=[]
|
|
26
26
|
for E in D:F=sanitize_ansi_text(E);B.extend(ANSI(F).__pt_formatted_text__());B.append(('','\n'))
|
|
27
27
|
return B
|
|
28
28
|
def create_content(B,width,height):A=height;B._height=A or 100;return super().create_content(width,A)
|
|
29
29
|
def mouse_handler(A,mouse_event):
|
|
30
30
|
B=mouse_event;C=5
|
|
31
|
-
if B.event_type==MouseEventType.SCROLL_UP:A.
|
|
32
|
-
elif B.event_type==MouseEventType.SCROLL_DOWN:A.
|
|
31
|
+
if B.event_type==MouseEventType.SCROLL_UP:A.bf(-C);return
|
|
32
|
+
elif B.event_type==MouseEventType.SCROLL_DOWN:A.bf(C);return
|
|
33
33
|
return NotImplemented
|
|
34
34
|
class ScrollableLogControl(UIControl):
|
|
35
35
|
def __init__(A):A.lines=[];A.scroll_offset=0;A.visible_lines=[];A._height=0;A.last_count=0
|
|
@@ -43,7 +43,7 @@ class ScrollableLogControl(UIControl):
|
|
|
43
43
|
def refresh_scroll(A):
|
|
44
44
|
if A._height:A.scroll_offset=max(0,len(A.lines)-A._height)
|
|
45
45
|
def bh(A):A.scroll_offset=max(0,len(A.lines)-A._height)
|
|
46
|
-
def
|
|
46
|
+
def bf(A,amount):A.scroll_offset=max(0,min(A.scroll_offset+amount,max(0,len(A.lines)-A._height)))
|
|
47
47
|
def is_focusable(A):return True
|
|
48
48
|
def create_content(A,width,height):B=height;A._height=B;A.visible_lines=A.lines[A.scroll_offset:A.scroll_offset+B];return UIContent(get_line=A.get_line,line_count=len(A.visible_lines),cursor_position=Point(0,len(A.visible_lines)-1))
|
|
49
49
|
def get_line(B,lineno):
|
|
@@ -52,7 +52,7 @@ class ScrollableLogControl(UIControl):
|
|
|
52
52
|
C=sanitize_ansi_text(B.visible_lines[A]);return ANSI(C).__pt_formatted_text__()
|
|
53
53
|
def mouse_handler(A,mouse_event):
|
|
54
54
|
B=mouse_event
|
|
55
|
-
if B.event_type==MouseEventType.SCROLL_UP:A.
|
|
56
|
-
elif B.event_type==MouseEventType.SCROLL_DOWN:A.
|
|
55
|
+
if B.event_type==MouseEventType.SCROLL_UP:A.bf(-1);return
|
|
56
|
+
elif B.event_type==MouseEventType.SCROLL_DOWN:A.bf(1);return
|
|
57
57
|
return NotImplemented
|
|
58
58
|
def sanitize_ansi_text(text):return re.sub('[¹²³⁰⁴⁵⁶⁷⁸⁹₀₁₂₃₄₅₆₇₈₉]',' ',text)
|
|
@@ -28,7 +28,7 @@ from src.tui.components.tdiff import render_diff_as_markdown
|
|
|
28
28
|
from src.tui.components.tdisplay import render_content_with_line_limit
|
|
29
29
|
from src.tui.utils.render import markdown_to_wrapped_text
|
|
30
30
|
def display_tool_call(tool_name,args,events=[]):
|
|
31
|
-
C=tool_name;A=events;E=format_tool_compact(C,args);D=
|
|
31
|
+
C=tool_name;A=events;E=format_tool_compact(C,args);D=y(C,args);B=Tree(Text(_I,style=_J)+Text(f"{E}",style=_C),guide_style=_D)
|
|
32
32
|
if A and len(A)>0:F=display_sub_panel(D,sub_events=A);B.add(F)
|
|
33
33
|
else:B.add(D)
|
|
34
34
|
return B
|
|
@@ -37,12 +37,12 @@ def display_tool_result(tool_name,args=_E,result=_E,events=[]):
|
|
|
37
37
|
if A is _E:A={}
|
|
38
38
|
H=format_tool_compact(G,A);C=G.lower()
|
|
39
39
|
try:
|
|
40
|
-
if C==_K and isinstance(A,dict):B=
|
|
41
|
-
elif C==_L and isinstance(A,dict):B=
|
|
42
|
-
elif C in[_M]and isinstance(A,dict):B=
|
|
43
|
-
elif C==_H and isinstance(A,dict):B=
|
|
44
|
-
elif C==_N and isinstance(A,dict):B=
|
|
45
|
-
elif C==_O and isinstance(A,dict):B=
|
|
40
|
+
if C==_K and isinstance(A,dict):B=v(A)
|
|
41
|
+
elif C==_L and isinstance(A,dict):B=v(A)
|
|
42
|
+
elif C in[_M]and isinstance(A,dict):B=v(A)
|
|
43
|
+
elif C==_H and isinstance(A,dict):B=ba(A,D)
|
|
44
|
+
elif C==_N and isinstance(A,dict):B=bc(A,D)
|
|
45
|
+
elif C==_O and isinstance(A,dict):B=be(A,D)
|
|
46
46
|
elif C==_P and isinstance(A,dict):B=bb(A,D)
|
|
47
47
|
else:B=z(A,D)
|
|
48
48
|
except Exception as I:import traceback as J;B=Text(f"Error: {str(I)}\n{J.format_exc()}",style='red')
|
|
@@ -102,12 +102,12 @@ def format_tool_compact(name,args):
|
|
|
102
102
|
I=', '.join(M)
|
|
103
103
|
if len(I)>50:I=I[:47]+_B
|
|
104
104
|
return f"{J}({I})"
|
|
105
|
-
def
|
|
105
|
+
def y(tool_name,arguments):
|
|
106
106
|
D=' Will search for pattern';C=arguments;B='bold grey';A=tool_name.lower()
|
|
107
107
|
if A==_H:return Text(f"running ...",style=B)
|
|
108
108
|
if A==_M:return Text(f" Executing ...",style=B)
|
|
109
|
-
elif A==_L:return
|
|
110
|
-
elif A==_K:return
|
|
109
|
+
elif A==_L:return bd(C)
|
|
110
|
+
elif A==_K:return x(C)
|
|
111
111
|
elif A in[_N,_O]:return Text(D,style=B)
|
|
112
112
|
elif A==_P:return Text(D,stype=B)
|
|
113
113
|
else:return Text(' Executing ...',style=B)
|
|
@@ -123,12 +123,12 @@ def display_sub_panel(result=_E,sub_events=[]):
|
|
|
123
123
|
else:A.append(C)
|
|
124
124
|
else:A.append(markdown_to_wrapped_text(f"calling ...",prefix=_E))
|
|
125
125
|
J=Group(*[A for A in A]);K=Box(' \n \n \n \n \n \n \n ');L=Panel(J,title_align='left',box=K);return L
|
|
126
|
-
def
|
|
126
|
+
def x(arguments):
|
|
127
127
|
A=arguments;B=A.get(_F,'');C=A.get('old_string','');D=A.get('new_string','');E=''
|
|
128
128
|
if os.path.exists(B):
|
|
129
129
|
with open(B,'r',encoding='utf-8')as F:G=F.read()
|
|
130
130
|
H=D if C==''else G.replace(C,D,1);I=render_diff_as_markdown(E,H);return I
|
|
131
|
-
def
|
|
131
|
+
def bd(arguments):
|
|
132
132
|
D=arguments;A=D.get(_F,'');B=D.get(_R,'')
|
|
133
133
|
if os.path.exists(A):C=open(A,'r').read()
|
|
134
134
|
else:C=''
|
|
@@ -137,7 +137,7 @@ def bc(arguments):
|
|
|
137
137
|
E=recognize_language(A)
|
|
138
138
|
if E:G=f"```\n{E}\n{B}\n```";return render_content_with_line_limit(G,'',100)
|
|
139
139
|
else:return render_content_with_line_limit(B,'',100)
|
|
140
|
-
def
|
|
140
|
+
def v(arguments):
|
|
141
141
|
B=arguments.get(_F,'');C=''
|
|
142
142
|
if os.path.exists(B):C=open(B,'r').read()
|
|
143
143
|
E=C.split(_A);F=len(E);A=50
|
|
@@ -146,7 +146,7 @@ def y(arguments):
|
|
|
146
146
|
H=recognize_language(B)
|
|
147
147
|
if H:J=f"```{H}\n{D}\n```";return render_content_with_line_limit(J,'',-1)
|
|
148
148
|
else:return render_content_with_line_limit(D,'',-1)
|
|
149
|
-
def
|
|
149
|
+
def w(arguments,result):
|
|
150
150
|
C=result.strip().split(_A);F=len(C);B=[];D=10;G=C[:D]
|
|
151
151
|
for(H,A)in enumerate(G):
|
|
152
152
|
I=''if H==0 else''
|
|
@@ -155,7 +155,7 @@ def ba(arguments,result):
|
|
|
155
155
|
E=F-D
|
|
156
156
|
if E>0:B.append(f" ... and {E} more lines")
|
|
157
157
|
return Text(_A.join(B),style=_G)
|
|
158
|
-
def
|
|
158
|
+
def ba(arguments,result):
|
|
159
159
|
C=result.strip().split(_A);F=len(C);B=[];D=10;G=C[:D]
|
|
160
160
|
for(H,A)in enumerate(G):
|
|
161
161
|
I=''if H==0 else''
|
|
@@ -164,7 +164,7 @@ def x(arguments,result):
|
|
|
164
164
|
E=F-D
|
|
165
165
|
if E>0:B.append(f" ... and {E} more lines")
|
|
166
166
|
return Text(_A.join(B),style=_G)
|
|
167
|
-
def
|
|
167
|
+
def bc(arguments,result):
|
|
168
168
|
C=result.strip().split(_A);F=len(C);B=[];D=10;G=C[:D]
|
|
169
169
|
for(H,A)in enumerate(G):
|
|
170
170
|
I=''if H==0 else''
|
|
@@ -173,7 +173,7 @@ def bd(arguments,result):
|
|
|
173
173
|
E=F-D
|
|
174
174
|
if E>0:B.append(f" ... and {E} more lines")
|
|
175
175
|
return Text(_A.join(B),style=_G)
|
|
176
|
-
def
|
|
176
|
+
def be(arguments,result):
|
|
177
177
|
C=result.strip().split(_A);F=len(C);B=[];D=10;G=C[:D]
|
|
178
178
|
for(H,A)in enumerate(G):
|
|
179
179
|
I=''if H==0 else''
|