@brandon_9527/tcode 1.0.2 → 1.0.3
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/.autodev/skills/teams/scripts/README.md +29 -0
- package/dist/python-src/.autodev/skills/teams/scripts/cursor_dispatch.sh +88 -0
- package/dist/python-src/.autodev/skills/teams/scripts/dispatch.sh +112 -0
- package/dist/python-src/.autodev/skills/teams/scripts/label.sh +62 -0
- package/dist/python-src/.autodev/skills/teams/scripts/layout.sh +181 -0
- package/dist/python-src/.autodev/skills/teams/scripts/old_dispatch.sh +42 -0
- package/dist/python-src/.autodev/skills/teams/scripts/pipe.sh +19 -0
- package/dist/python-src/.autodev/skills/teams/scripts/pipe_dispatch.sh +59 -0
- package/dist/python-src/.autodev/skills/teams/scripts/run.sh +18 -0
- package/dist/python-src/.autodev/skills/teams/scripts/stop.sh +26 -0
- package/dist/python-src/.autodev/skills/teams/scripts/tmux-layout.sh +43 -0
- package/dist/python-src/entry.py +28 -1
- package/dist/python-src/main.py +382 -3
- package/dist/python-src/pyproject.toml +1 -1
- package/dist/python-src/src/ai_tcode.egg-info/PKG-INFO +30 -0
- package/dist/python-src/src/ai_tcode.egg-info/SOURCES.txt +48 -0
- package/dist/python-src/src/ai_tcode.egg-info/dependency_links.txt +1 -0
- package/dist/python-src/src/ai_tcode.egg-info/requires.txt +26 -0
- package/dist/python-src/src/ai_tcode.egg-info/top_level.txt +9 -0
- package/dist/python-src/src/managers/manager_agent.py +200 -0
- package/dist/python-src/src/managers/manager_context.py +49 -0
- package/dist/python-src/src/managers/manager_instruction.py +192 -0
- package/dist/python-src/src/managers/sandbox.py +3 -3
- package/dist/python-src/src/middlewares/dynamic_content.py +63 -0
- package/dist/python-src/src/middlewares/hitl.py +3 -3
- package/dist/python-src/src/middlewares/memory.py +44 -0
- package/dist/python-src/src/middlewares/subagents.py +25 -25
- package/dist/python-src/src/middlewares/summary.py +35 -35
- package/dist/python-src/src/middlewares/utils.py +5 -0
- package/dist/python-src/src/prompts/prompts.py +1 -0
- package/dist/python-src/src/stream/formatter.py +17 -17
- package/dist/python-src/src/stream/handler.py +109 -81
- package/dist/python-src/src/stream/handler_with_tracker.py +10 -10
- package/dist/python-src/src/tools/web.py +10 -9
- package/dist/python-src/src/tui/chatui.py +67 -51
- package/dist/python-src/src/tui/components/tlist.py +6 -6
- package/dist/python-src/src/tui/components/tscroll_panel.py +8 -8
- package/dist/python-src/src/tui/utils/trender.py +27 -27
- package/dist/python-src/src/utils/prompt.py +15 -4
- package/dist/python-src/uv.lock +1980 -2094
- package/package.json +1 -1
- package/dist/python-src/src/__pycache__/__init__.cpython-311.pyc +0 -0
- package/dist/python-src/src/managers/__pycache__/__init__.cpython-311.pyc +0 -0
- package/dist/python-src/src/managers/__pycache__/sandbox.cpython-311.pyc +0 -0
- package/dist/python-src/src/middlewares/__pycache__/__init__.cpython-311.pyc +0 -0
- package/dist/python-src/src/middlewares/__pycache__/hitl.cpython-311.pyc +0 -0
- package/dist/python-src/src/middlewares/dynamic_prompt.py +0 -15
- package/dist/python-src/src/stream/__pycache__/__init__.cpython-311.pyc +0 -0
- package/dist/python-src/src/stream/__pycache__/emitter.cpython-311.pyc +0 -0
- package/dist/python-src/src/stream/__pycache__/file_write_parser.cpython-311.pyc +0 -0
- package/dist/python-src/src/stream/__pycache__/formatter.cpython-311.pyc +0 -0
- package/dist/python-src/src/stream/__pycache__/handler.cpython-311.pyc +0 -0
- package/dist/python-src/src/stream/__pycache__/tracker.cpython-311.pyc +0 -0
- package/dist/python-src/src/stream/__pycache__/utils.cpython-311.pyc +0 -0
- package/dist/python-src/src/tools/__pycache__/__init__.cpython-311.pyc +0 -0
- package/dist/python-src/src/tools/__pycache__/skill_loader.cpython-311.pyc +0 -0
- package/dist/python-src/src/tools/__pycache__/tools.cpython-311.pyc +0 -0
- package/dist/python-src/src/tools/__pycache__/web.cpython-311.pyc +0 -0
- package/dist/python-src/src/tui/__pycache__/chatui.cpython-311.pyc +0 -0
- package/dist/python-src/src/tui/__pycache__/config.cpython-311.pyc +0 -0
- package/dist/python-src/src/tui/components/__pycache__/__init__.cpython-311.pyc +0 -0
- package/dist/python-src/src/tui/components/__pycache__/live_spinner.cpython-311.pyc +0 -0
- package/dist/python-src/src/tui/components/__pycache__/tdiff.cpython-311.pyc +0 -0
- package/dist/python-src/src/tui/components/__pycache__/tdisplay.cpython-311.pyc +0 -0
- package/dist/python-src/src/tui/components/__pycache__/tlist.cpython-311.pyc +0 -0
- package/dist/python-src/src/tui/components/__pycache__/tscroll_panel.cpython-311.pyc +0 -0
- package/dist/python-src/src/tui/utils/__pycache__/__init__.cpython-311.pyc +0 -0
- package/dist/python-src/src/tui/utils/__pycache__/render.cpython-311.pyc +0 -0
- package/dist/python-src/src/tui/utils/__pycache__/trender.cpython-311.pyc +0 -0
- package/dist/python-src/src/utils/__pycache__/__init__.cpython-311.pyc +0 -0
- package/dist/python-src/src/utils/__pycache__/utils.cpython-311.pyc +0 -0
package/dist/python-src/entry.py
CHANGED
|
@@ -5,11 +5,38 @@
|
|
|
5
5
|
# if __name__ == "__main__":
|
|
6
6
|
# main()
|
|
7
7
|
|
|
8
|
+
|
|
9
|
+
# ===================== 强制修复 Git Bash 报错:NoConsoleScreenBufferError =====================
|
|
10
|
+
import os
|
|
11
|
+
import sys
|
|
12
|
+
|
|
13
|
+
# 🔥 核心:强制让 prompt_toolkit 使用兼容模式,彻底关闭 Windows 控制台检测
|
|
14
|
+
os.environ["PROMPT_TOOLKIT_NO_WIN32"] = "1"
|
|
15
|
+
os.environ["PROMPT_TOOLKIT_BASIC_OUTPUT"] = "1"
|
|
16
|
+
os.environ["PROMPT_TOOLKIT_FORCE_VT100"] = "1"
|
|
17
|
+
|
|
18
|
+
# 🔥 强制设置终端类型,让程序认为是 Linux 终端
|
|
19
|
+
if sys.platform == "win32":
|
|
20
|
+
os.environ["TERM"] = "xterm-256color"
|
|
21
|
+
|
|
22
|
+
# ===================== 下面才是你原来的代码 =====================
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
import warnings
|
|
26
|
+
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
|
27
|
+
warnings.filterwarnings("ignore", message="Pydantic serializer warnings")
|
|
28
|
+
|
|
8
29
|
from main import (
|
|
9
30
|
agent_ui,
|
|
10
31
|
asingle_agent,
|
|
32
|
+
team_main,
|
|
11
33
|
)
|
|
12
34
|
|
|
13
35
|
if __name__ == "__main__":
|
|
14
36
|
import asyncio
|
|
15
|
-
|
|
37
|
+
|
|
38
|
+
try:
|
|
39
|
+
asyncio.run(asingle_agent())
|
|
40
|
+
# asyncio.run(team_main())
|
|
41
|
+
except Exception as e:
|
|
42
|
+
pass
|
package/dist/python-src/main.py
CHANGED
|
@@ -19,6 +19,12 @@ _ = load_dotenv(find_dotenv())
|
|
|
19
19
|
from langchain_core.messages import AIMessageChunk
|
|
20
20
|
|
|
21
21
|
|
|
22
|
+
import warnings
|
|
23
|
+
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
|
24
|
+
warnings.filterwarnings("ignore", message="Pydantic serializer warnings")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
22
28
|
|
|
23
29
|
# # ========== 关键修改1:配置logging,让INFO级别日志能输出 ==========
|
|
24
30
|
# import logging
|
|
@@ -214,15 +220,388 @@ async def asingle_agent():
|
|
|
214
220
|
# sandbox=None
|
|
215
221
|
)
|
|
216
222
|
|
|
223
|
+
tui = LiveChatUI(
|
|
224
|
+
agent=agent,
|
|
225
|
+
saver=saver,
|
|
226
|
+
workspace=WORKSPACE,
|
|
227
|
+
context=context,
|
|
228
|
+
interrupt_tools=[
|
|
229
|
+
"bash",
|
|
230
|
+
"read_file",
|
|
231
|
+
"write_file",
|
|
232
|
+
"glob",
|
|
233
|
+
"grep",
|
|
234
|
+
"edit",
|
|
235
|
+
"list_dir",
|
|
236
|
+
"web_search",
|
|
237
|
+
"web_fetch"
|
|
238
|
+
],
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
await tui.run_async()
|
|
217
242
|
|
|
218
243
|
|
|
219
|
-
|
|
244
|
+
async def team_main():
|
|
245
|
+
""" 加载开发团队 """
|
|
246
|
+
from dataclasses import dataclass, field
|
|
247
|
+
from pathlib import Path
|
|
248
|
+
|
|
249
|
+
from src.core.deepagents import create_deep_agent, get_default_model
|
|
250
|
+
from src.managers.manager_context import ContextManager
|
|
251
|
+
from src.utils.prompt import apply_template, apply_prompt
|
|
252
|
+
from src.managers.sandbox import Container
|
|
253
|
+
from src.prompts.prompts import leader
|
|
254
|
+
|
|
255
|
+
from src.tools.tools import (
|
|
256
|
+
SkillAgentContext,
|
|
257
|
+
shell,
|
|
258
|
+
bash,
|
|
259
|
+
write_file,
|
|
260
|
+
read_file,
|
|
261
|
+
list_dir,
|
|
262
|
+
glob,
|
|
263
|
+
grep,
|
|
264
|
+
edit
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
from src.tools.web import (
|
|
268
|
+
web_search,
|
|
269
|
+
web_fetch
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
from langgraph.checkpoint.memory import MemorySaver
|
|
273
|
+
from langchain_core.tools import BaseTool
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
def _prepare(workspace, run_mode, session_id):
|
|
277
|
+
saver = MemorySaver()
|
|
278
|
+
|
|
279
|
+
# 1. 构建上下文管理器
|
|
280
|
+
context_manager = ContextManager(
|
|
281
|
+
dockerfile_path=os.path.join(os.getcwd(), "sources", "docker", "Dockerfile.sandbox"),
|
|
282
|
+
mode=run_mode
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
context_manager.create_environment(
|
|
286
|
+
session_id=session_id,
|
|
287
|
+
workspace_path=workspace,
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
# 2. 指令管理器
|
|
291
|
+
instruction_manager = context_manager.get_instruction_manager(
|
|
292
|
+
session_id=session_id
|
|
293
|
+
)
|
|
294
|
+
|
|
295
|
+
# 3. 代理管理器
|
|
296
|
+
agent_manager = context_manager.get_agent_manager(
|
|
297
|
+
session_id=session_id
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
# 4. mcp 管理器
|
|
301
|
+
# mcp_manager = context_manager.get_mcp_manager(
|
|
302
|
+
# session_id=session_id
|
|
303
|
+
# )
|
|
304
|
+
|
|
305
|
+
# 5. 沙箱
|
|
306
|
+
sandbox = context_manager.get_container(
|
|
307
|
+
session_id=session_id
|
|
308
|
+
)
|
|
309
|
+
|
|
310
|
+
# 6. 获取配置
|
|
311
|
+
agents_conf = agent_manager.get_all_conf()
|
|
312
|
+
|
|
313
|
+
toolkits = {
|
|
314
|
+
"filetools": [ shell, read_file, write_file, glob, grep, edit, list_dir],
|
|
315
|
+
"web": [web_search, web_fetch]
|
|
316
|
+
} if run_mode == "sandbox" else {
|
|
317
|
+
"filetools": [ bash, read_file, write_file, glob, grep, edit, list_dir],
|
|
318
|
+
"web": [web_search, web_fetch]
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
context = SkillAgentContext(
|
|
322
|
+
working_directory=workspace,
|
|
323
|
+
# skill_loader=None,
|
|
324
|
+
sandbox=sandbox
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
return agents_conf, toolkits, context, saver, instruction_manager
|
|
328
|
+
|
|
329
|
+
def _build_team(agents_conf: Dict[str, Any], domain: str, llm: ChatOpenAI, toolkits: Dict[str, List[BaseTool]], workspace: str, saver=None, store=None, recursion_limit=1000):
|
|
330
|
+
""" """
|
|
331
|
+
team_conf = agents_conf[domain]
|
|
332
|
+
|
|
333
|
+
# for mname, mconf in team_conf['members'].items():
|
|
334
|
+
# print(f"member_name: {mname}, member: {mconf}")
|
|
335
|
+
|
|
336
|
+
agents = []
|
|
337
|
+
for member_name, member in team_conf["members"].items():
|
|
338
|
+
print(f"member_name: {member_name}, member: {member}")
|
|
339
|
+
|
|
340
|
+
tools = []
|
|
341
|
+
for tool_name in member["tools"]:
|
|
342
|
+
tools.extend(toolkits.get(tool_name, []))
|
|
343
|
+
|
|
344
|
+
llm_conf = member.get("llm", None)
|
|
345
|
+
model = ChatOpenAI(**llm_conf) if llm_conf else get_default_model(streaming=False)
|
|
346
|
+
|
|
347
|
+
agent = {
|
|
348
|
+
"name": member_name,
|
|
349
|
+
"description": member["description"],
|
|
350
|
+
"system_prompt": apply_template(
|
|
351
|
+
agents_config=agents_conf,
|
|
352
|
+
domain=domain,
|
|
353
|
+
prompt_name=member_name,
|
|
354
|
+
WORKSPACE=workspace
|
|
355
|
+
),
|
|
356
|
+
"context_schema": SkillAgentContext,
|
|
357
|
+
"tools": tools,
|
|
358
|
+
"model": model
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
agents.append(agent)
|
|
362
|
+
|
|
363
|
+
tools = []
|
|
364
|
+
for tool_name in ["filetools", "web"]:
|
|
365
|
+
tools.extend([tool for tool in toolkits.get(tool_name, [])])
|
|
366
|
+
|
|
367
|
+
team = create_deep_agent(
|
|
368
|
+
model=llm,
|
|
369
|
+
subagents=agents,
|
|
370
|
+
tools=tools,
|
|
371
|
+
context_schema=SkillAgentContext,
|
|
372
|
+
# system_prompt=apply_template(
|
|
373
|
+
# agents_config=agents_conf,
|
|
374
|
+
# domain="default",
|
|
375
|
+
# prompt_name="leader_",
|
|
376
|
+
# WORKSPACE=workspace
|
|
377
|
+
# ),
|
|
378
|
+
system_prompt=apply_prompt(leader, WORKSPACE=workspace),
|
|
379
|
+
checkpointer=saver
|
|
380
|
+
).with_config({"recursion_limit": recursion_limit})
|
|
381
|
+
|
|
382
|
+
return team
|
|
383
|
+
|
|
384
|
+
# workspace = os.path.join(os.getcwd(), "workspace")
|
|
385
|
+
workspace = os.getcwd()
|
|
386
|
+
run_mode = "local"
|
|
387
|
+
session_id = "1"
|
|
388
|
+
|
|
389
|
+
# agents_conf, toolkits, context, saver, instruction_manager
|
|
390
|
+
agents_config, toolkits, context, saver, instruction_manager = _prepare(workspace, run_mode, session_id)
|
|
391
|
+
agent = _build_team(
|
|
392
|
+
agents_conf=agents_config,
|
|
393
|
+
domain="coding",
|
|
394
|
+
llm=llm,
|
|
395
|
+
toolkits=toolkits,
|
|
396
|
+
workspace=workspace,
|
|
397
|
+
saver=saver,
|
|
398
|
+
store=None,
|
|
399
|
+
recursion_limit=1000
|
|
400
|
+
)
|
|
401
|
+
|
|
402
|
+
ui = LiveChatUI(agent=agent, saver=saver, workspace=workspace, context=context, instruction_manager=instruction_manager)
|
|
403
|
+
|
|
404
|
+
await ui.run_async()
|
|
220
405
|
|
|
221
|
-
await tui.run_async()
|
|
222
406
|
|
|
407
|
+
async def teminal_chat():
|
|
408
|
+
""" """
|
|
409
|
+
from dataclasses import dataclass, field
|
|
410
|
+
from pathlib import Path
|
|
411
|
+
|
|
412
|
+
from src.core.deepagents import create_deep_agent, get_default_model
|
|
413
|
+
from src.managers.manager_context import ContextManager
|
|
414
|
+
from src.utils.prompt import apply_template, apply_prompt
|
|
415
|
+
from src.managers.sandbox import Container
|
|
416
|
+
from src.prompts.prompts import leader
|
|
417
|
+
from src.stream.handler import ainput, anormal_handler
|
|
418
|
+
|
|
419
|
+
from src.tools.tools import (
|
|
420
|
+
SkillAgentContext,
|
|
421
|
+
shell,
|
|
422
|
+
bash,
|
|
423
|
+
write_file,
|
|
424
|
+
read_file,
|
|
425
|
+
list_dir,
|
|
426
|
+
glob,
|
|
427
|
+
grep,
|
|
428
|
+
edit
|
|
429
|
+
)
|
|
430
|
+
|
|
431
|
+
from src.tools.web import (
|
|
432
|
+
web_search,
|
|
433
|
+
web_fetch
|
|
434
|
+
)
|
|
435
|
+
|
|
436
|
+
from langgraph.checkpoint.memory import MemorySaver
|
|
437
|
+
from langchain_core.messages import HumanMessage
|
|
438
|
+
from langchain_core.tools import BaseTool
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
def _prepare(workspace, run_mode, session_id):
|
|
442
|
+
saver = MemorySaver()
|
|
443
|
+
|
|
444
|
+
# 1. 构建上下文管理器
|
|
445
|
+
context_manager = ContextManager(
|
|
446
|
+
dockerfile_path=os.path.join(os.getcwd(), "sources", "docker", "Dockerfile.sandbox"),
|
|
447
|
+
mode=run_mode
|
|
448
|
+
)
|
|
449
|
+
|
|
450
|
+
context_manager.create_environment(
|
|
451
|
+
session_id=session_id,
|
|
452
|
+
workspace_path=workspace,
|
|
453
|
+
)
|
|
454
|
+
|
|
455
|
+
# 2. 指令管理器
|
|
456
|
+
instruction_manager = context_manager.get_instruction_manager(
|
|
457
|
+
session_id=session_id
|
|
458
|
+
)
|
|
459
|
+
|
|
460
|
+
# 3. 代理管理器
|
|
461
|
+
agent_manager = context_manager.get_agent_manager(
|
|
462
|
+
session_id=session_id
|
|
463
|
+
)
|
|
464
|
+
|
|
465
|
+
# 4. mcp 管理器
|
|
466
|
+
# mcp_manager = context_manager.get_mcp_manager(
|
|
467
|
+
# session_id=session_id
|
|
468
|
+
# )
|
|
469
|
+
|
|
470
|
+
# 5. 沙箱
|
|
471
|
+
sandbox = context_manager.get_container(
|
|
472
|
+
session_id=session_id
|
|
473
|
+
)
|
|
474
|
+
|
|
475
|
+
# 6. 获取配置
|
|
476
|
+
agents_conf = agent_manager.get_all_conf()
|
|
477
|
+
|
|
478
|
+
toolkits = {
|
|
479
|
+
"filetools": [ shell, read_file, write_file, glob, grep, edit, list_dir],
|
|
480
|
+
"web": [web_search, web_fetch]
|
|
481
|
+
} if run_mode == "sandbox" else {
|
|
482
|
+
"filetools": [ bash, read_file, write_file, glob, grep, edit, list_dir],
|
|
483
|
+
"web": [web_search, web_fetch]
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
context = SkillAgentContext(
|
|
487
|
+
working_directory=workspace,
|
|
488
|
+
# skill_loader=None,
|
|
489
|
+
sandbox=sandbox
|
|
490
|
+
)
|
|
491
|
+
|
|
492
|
+
return agents_conf, toolkits, context, saver, instruction_manager
|
|
493
|
+
|
|
494
|
+
def _build_team(agents_conf: Dict[str, Any], domain: str, llm: ChatOpenAI, toolkits: Dict[str, List[BaseTool]], workspace: str, saver=None, store=None, recursion_limit=1000):
|
|
495
|
+
""" """
|
|
496
|
+
team_conf = agents_conf[domain]
|
|
497
|
+
|
|
498
|
+
# for mname, mconf in team_conf['members'].items():
|
|
499
|
+
# print(f"member_name: {mname}, member: {mconf}")
|
|
500
|
+
|
|
501
|
+
agents = []
|
|
502
|
+
for member_name, member in team_conf["members"].items():
|
|
503
|
+
print(f"member_name: {member_name}, member: {member}")
|
|
504
|
+
|
|
505
|
+
tools = []
|
|
506
|
+
for tool_name in member["tools"]:
|
|
507
|
+
tools.extend(toolkits.get(tool_name, []))
|
|
508
|
+
|
|
509
|
+
llm_conf = member.get("llm", None)
|
|
510
|
+
model = ChatOpenAI(**llm_conf) if llm_conf else get_default_model(streaming=False)
|
|
511
|
+
|
|
512
|
+
agent = {
|
|
513
|
+
"name": member_name,
|
|
514
|
+
"description": member["description"],
|
|
515
|
+
"system_prompt": apply_template(
|
|
516
|
+
agents_config=agents_conf,
|
|
517
|
+
domain=domain,
|
|
518
|
+
prompt_name=member_name,
|
|
519
|
+
WORKSPACE=workspace
|
|
520
|
+
),
|
|
521
|
+
"context_schema": SkillAgentContext,
|
|
522
|
+
"tools": tools,
|
|
523
|
+
"model": model
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
agents.append(agent)
|
|
527
|
+
|
|
528
|
+
tools = []
|
|
529
|
+
for tool_name in ["filetools", "web"]:
|
|
530
|
+
tools.extend([tool for tool in toolkits.get(tool_name, [])])
|
|
531
|
+
|
|
532
|
+
team = create_deep_agent(
|
|
533
|
+
model=llm,
|
|
534
|
+
subagents=agents,
|
|
535
|
+
tools=tools,
|
|
536
|
+
context_schema=SkillAgentContext,
|
|
537
|
+
# system_prompt=apply_template(
|
|
538
|
+
# agents_config=agents_conf,
|
|
539
|
+
# domain="default",
|
|
540
|
+
# prompt_name="leader_",
|
|
541
|
+
# WORKSPACE=workspace
|
|
542
|
+
# ),
|
|
543
|
+
system_prompt=apply_prompt(leader, WORKSPACE=workspace),
|
|
544
|
+
checkpointer=saver
|
|
545
|
+
).with_config({"recursion_limit": recursion_limit})
|
|
546
|
+
|
|
547
|
+
return team
|
|
548
|
+
|
|
549
|
+
# workspace = os.path.join(os.getcwd(), "workspace")
|
|
550
|
+
workspace = os.getcwd()
|
|
551
|
+
run_mode = "local"
|
|
552
|
+
session_id = "1"
|
|
553
|
+
|
|
554
|
+
# agents_conf, toolkits, context, saver, instruction_manager
|
|
555
|
+
agents_config, toolkits, context, saver, instruction_manager = _prepare(workspace, run_mode, session_id)
|
|
556
|
+
agent = _build_team(
|
|
557
|
+
agents_conf=agents_config,
|
|
558
|
+
domain="coding",
|
|
559
|
+
llm=llm,
|
|
560
|
+
toolkits=toolkits,
|
|
561
|
+
workspace=workspace,
|
|
562
|
+
saver=saver,
|
|
563
|
+
store=None,
|
|
564
|
+
recursion_limit=1000
|
|
565
|
+
)
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
try:
|
|
569
|
+
while True:
|
|
570
|
+
query = await ainput("user>")
|
|
571
|
+
|
|
572
|
+
if query == "/comands":
|
|
573
|
+
for instruction in instruction_manager.list_instructions():
|
|
574
|
+
# print(instruction)
|
|
575
|
+
print(f"command: {instruction.name}, description: {instruction.description}")
|
|
576
|
+
continue
|
|
577
|
+
|
|
578
|
+
instruction_result = instruction_manager.parse(query)
|
|
579
|
+
executed_instruction, message = instruction_result["executed_instruction"], instruction_result['message']
|
|
580
|
+
|
|
581
|
+
new_query = f"\n [注意]: 执行用户请求必须严格遵循如下准则:\n{executed_instruction}\n\n 用户请求:\n{message}" if executed_instruction else message
|
|
582
|
+
|
|
583
|
+
stream = agent.astream(
|
|
584
|
+
{
|
|
585
|
+
"messages":[HumanMessage(content=new_query)]
|
|
586
|
+
},
|
|
587
|
+
config = {"configurable": {"thread_id": 1}},
|
|
588
|
+
stream_mode=["updates", "custom"],
|
|
589
|
+
context=context
|
|
590
|
+
) # .with_config({"recursion_limit": 1000})
|
|
591
|
+
|
|
592
|
+
await anormal_handler(stream, detail=True)
|
|
593
|
+
|
|
594
|
+
except Exception as e:
|
|
595
|
+
import traceback
|
|
596
|
+
traceback.print_exc()
|
|
597
|
+
finally:
|
|
598
|
+
pass
|
|
599
|
+
|
|
600
|
+
|
|
223
601
|
|
|
224
602
|
if __name__ == "__main__":
|
|
225
|
-
pass
|
|
603
|
+
# pass
|
|
604
|
+
asyncio.run(teminal_chat())
|
|
226
605
|
# asyncio.run(agent_ui())
|
|
227
606
|
# asyncio.run(team_main())
|
|
228
607
|
# asyncio.run(asingle_agent())
|
|
@@ -23,7 +23,6 @@ dependencies = [
|
|
|
23
23
|
"croniter>=6.0.0",
|
|
24
24
|
"apscheduler>=3.11.2",
|
|
25
25
|
"whatthepatch>=1.0.7",
|
|
26
|
-
"ddgs>=9.10.0",
|
|
27
26
|
"requests>=2.32.5",
|
|
28
27
|
"beautifulsoup4>=4.14.3",
|
|
29
28
|
"langchain-dashscope>=0.1.8",
|
|
@@ -32,6 +31,7 @@ dependencies = [
|
|
|
32
31
|
"dashscope>=1.25.12",
|
|
33
32
|
"langchain-core==1.2.13",
|
|
34
33
|
"python-minifier>=3.2.0",
|
|
34
|
+
"ddgs>=9.11.4",
|
|
35
35
|
]
|
|
36
36
|
|
|
37
37
|
#[project.scripts]
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ai-tcode
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Requires-Python: >=3.11
|
|
5
|
+
Requires-Dist: prompt-toolkit>=3.0.43
|
|
6
|
+
Requires-Dist: rich>=13.0.0
|
|
7
|
+
Requires-Dist: pyyaml>=6.0.0
|
|
8
|
+
Requires-Dist: click>=8.0.0
|
|
9
|
+
Requires-Dist: numpy>=1.24.0
|
|
10
|
+
Requires-Dist: python-dateutil>=2.8.0
|
|
11
|
+
Requires-Dist: langchain>=1.0.0
|
|
12
|
+
Requires-Dist: langchain-openai>=1.0.0
|
|
13
|
+
Requires-Dist: langgraph>=1.0.0
|
|
14
|
+
Requires-Dist: pyyaml>=6.0
|
|
15
|
+
Requires-Dist: python-dotenv>=1.0
|
|
16
|
+
Requires-Dist: lark-oapi>=1.5.3
|
|
17
|
+
Requires-Dist: langchain-mcp-adapters>=0.2.1
|
|
18
|
+
Requires-Dist: docker>=7.1.0
|
|
19
|
+
Requires-Dist: croniter>=6.0.0
|
|
20
|
+
Requires-Dist: apscheduler>=3.11.2
|
|
21
|
+
Requires-Dist: whatthepatch>=1.0.7
|
|
22
|
+
Requires-Dist: ddgs>=9.10.0
|
|
23
|
+
Requires-Dist: requests>=2.32.5
|
|
24
|
+
Requires-Dist: beautifulsoup4>=4.14.3
|
|
25
|
+
Requires-Dist: langchain-dashscope>=0.1.8
|
|
26
|
+
Requires-Dist: langchain-alibaba>=0.1.1
|
|
27
|
+
Requires-Dist: langchain-community>=0.4.1
|
|
28
|
+
Requires-Dist: dashscope>=1.25.12
|
|
29
|
+
Requires-Dist: langchain-core==1.2.13
|
|
30
|
+
Requires-Dist: python-minifier>=3.2.0
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/__init__.py
|
|
4
|
+
src/agents/__init__.py
|
|
5
|
+
src/ai_tcode.egg-info/PKG-INFO
|
|
6
|
+
src/ai_tcode.egg-info/SOURCES.txt
|
|
7
|
+
src/ai_tcode.egg-info/dependency_links.txt
|
|
8
|
+
src/ai_tcode.egg-info/requires.txt
|
|
9
|
+
src/ai_tcode.egg-info/top_level.txt
|
|
10
|
+
src/core/__init__.py
|
|
11
|
+
src/core/deepagents.py
|
|
12
|
+
src/core/prompts.py
|
|
13
|
+
src/managers/__init__.py
|
|
14
|
+
src/managers/sandbox.py
|
|
15
|
+
src/middlewares/__init__.py
|
|
16
|
+
src/middlewares/dynamic_prompt.py
|
|
17
|
+
src/middlewares/hitl.py
|
|
18
|
+
src/middlewares/patch_tool_calls.py
|
|
19
|
+
src/middlewares/subagents.py
|
|
20
|
+
src/middlewares/summary.py
|
|
21
|
+
src/stream/__init__.py
|
|
22
|
+
src/stream/emitter.py
|
|
23
|
+
src/stream/file_write_parser.py
|
|
24
|
+
src/stream/formatter.py
|
|
25
|
+
src/stream/handler.py
|
|
26
|
+
src/stream/handler_with_tracker.py
|
|
27
|
+
src/stream/tracker.py
|
|
28
|
+
src/stream/utils.py
|
|
29
|
+
src/tools/__init__.py
|
|
30
|
+
src/tools/security_hook.py
|
|
31
|
+
src/tools/skill_loader.py
|
|
32
|
+
src/tools/tools.py
|
|
33
|
+
src/tools/tools_.py
|
|
34
|
+
src/tools/web.py
|
|
35
|
+
src/tui/chatui.py
|
|
36
|
+
src/tui/config.py
|
|
37
|
+
src/tui/components/__init__.py
|
|
38
|
+
src/tui/components/live_spinner.py
|
|
39
|
+
src/tui/components/tdiff.py
|
|
40
|
+
src/tui/components/tdisplay.py
|
|
41
|
+
src/tui/components/tlist.py
|
|
42
|
+
src/tui/components/tscroll_panel.py
|
|
43
|
+
src/tui/utils/__init__.py
|
|
44
|
+
src/tui/utils/render.py
|
|
45
|
+
src/tui/utils/trender.py
|
|
46
|
+
src/utils/__init__.py
|
|
47
|
+
src/utils/prompt.py
|
|
48
|
+
src/utils/utils.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
prompt-toolkit>=3.0.43
|
|
2
|
+
rich>=13.0.0
|
|
3
|
+
pyyaml>=6.0.0
|
|
4
|
+
click>=8.0.0
|
|
5
|
+
numpy>=1.24.0
|
|
6
|
+
python-dateutil>=2.8.0
|
|
7
|
+
langchain>=1.0.0
|
|
8
|
+
langchain-openai>=1.0.0
|
|
9
|
+
langgraph>=1.0.0
|
|
10
|
+
pyyaml>=6.0
|
|
11
|
+
python-dotenv>=1.0
|
|
12
|
+
lark-oapi>=1.5.3
|
|
13
|
+
langchain-mcp-adapters>=0.2.1
|
|
14
|
+
docker>=7.1.0
|
|
15
|
+
croniter>=6.0.0
|
|
16
|
+
apscheduler>=3.11.2
|
|
17
|
+
whatthepatch>=1.0.7
|
|
18
|
+
ddgs>=9.10.0
|
|
19
|
+
requests>=2.32.5
|
|
20
|
+
beautifulsoup4>=4.14.3
|
|
21
|
+
langchain-dashscope>=0.1.8
|
|
22
|
+
langchain-alibaba>=0.1.1
|
|
23
|
+
langchain-community>=0.4.1
|
|
24
|
+
dashscope>=1.25.12
|
|
25
|
+
langchain-core==1.2.13
|
|
26
|
+
python-minifier>=3.2.0
|