@brandon_9527/tcode 1.0.7 → 1.0.9

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.
Files changed (59) hide show
  1. package/dist/python-src/.env +5 -3
  2. package/dist/python-src/README.md +40 -1
  3. package/dist/python-src/_workspace/.autodev/config.json +12 -0
  4. package/dist/python-src/_workspace/.autodev/cron/jobs.json +4 -0
  5. package/dist/python-src/entry.py +35 -1
  6. package/dist/python-src/main.py +753 -40
  7. package/dist/python-src/pyproject.toml +1 -0
  8. package/dist/python-src/run.sh +9 -0
  9. package/dist/python-src/src/agents/token_tracker.py +4 -4
  10. package/dist/python-src/src/claw/bus/queue.py +1 -1
  11. package/dist/python-src/src/claw/channels/__init__.py +2 -2
  12. package/dist/python-src/src/claw/channels/base.py +2 -2
  13. package/dist/python-src/src/claw/channels/feishu.py +57 -16
  14. package/dist/python-src/src/claw/channels/manager.py +2 -2
  15. package/dist/python-src/src/claw/config/__init__.py +3 -0
  16. package/dist/python-src/src/claw/config/loader.py +38 -0
  17. package/dist/python-src/src/claw/config/schema.py +14 -29
  18. package/dist/python-src/src/claw/cron/__init__.py +3 -0
  19. package/dist/python-src/src/claw/cron/service.py +171 -0
  20. package/dist/python-src/src/claw/cron/types_.py +14 -0
  21. package/dist/python-src/src/claw/heartbeat/__init__.py +2 -0
  22. package/dist/python-src/src/claw/heartbeat/service.py +55 -0
  23. package/dist/python-src/src/claw/run.py +82 -0
  24. package/dist/python-src/src/claw/tools/base.py +23 -0
  25. package/dist/python-src/src/claw/tools/channel.py +0 -0
  26. package/dist/python-src/src/claw/tools/cron.py +138 -0
  27. package/dist/python-src/src/claw/utils/__init__.py +2 -0
  28. package/dist/python-src/src/claw/utils/helpers.py +27 -0
  29. package/dist/python-src/src/core/context.py +158 -0
  30. package/dist/python-src/src/core/deepagents.py +5 -5
  31. package/dist/python-src/src/managers/manager_agent.py +9 -9
  32. package/dist/python-src/src/managers/manager_command.py +62 -0
  33. package/dist/python-src/src/managers/manager_context.py +1 -1
  34. package/dist/python-src/src/managers/manager_instruction.py +7 -7
  35. package/dist/python-src/src/managers/manager_skill.py +3 -3
  36. package/dist/python-src/src/managers/sandbox.py +3 -3
  37. package/dist/python-src/src/middlewares/dynamic_content.py +2 -2
  38. package/dist/python-src/src/middlewares/hitl.py +3 -3
  39. package/dist/python-src/src/middlewares/memory.py +2 -2
  40. package/dist/python-src/src/middlewares/subagents.py +4 -4
  41. package/dist/python-src/src/middlewares/summary.py +37 -37
  42. package/dist/python-src/src/stream/file_write_parser.py +3 -3
  43. package/dist/python-src/src/stream/formatter.py +19 -19
  44. package/dist/python-src/src/stream/handler.py +4 -4
  45. package/dist/python-src/src/stream/handler_with_tracker.py +10 -10
  46. package/dist/python-src/src/trackers/token/pricing.py +2 -2
  47. package/dist/python-src/src/trackers/token/report.py +4 -4
  48. package/dist/python-src/src/trackers/token/tracker.py +8 -8
  49. package/dist/python-src/src/tui/chatui.py +10 -10
  50. package/dist/python-src/src/tui/clawtui.py +224 -0
  51. package/dist/python-src/src/tui/commands/__init__.py +3 -0
  52. package/dist/python-src/src/tui/commands/base.py +6 -0
  53. package/dist/python-src/src/tui/commands/instruction.py +5 -0
  54. package/dist/python-src/src/tui/components/tlist.py +7 -7
  55. package/dist/python-src/src/tui/components/tscroll_panel.py +73 -44
  56. package/dist/python-src/src/tui/components/tscroll_panel_old.py +58 -0
  57. package/dist/python-src/src/tui/utils/trender.py +21 -21
  58. package/dist/python-src/uv.lock +1969 -1958
  59. package/package.json +1 -1
@@ -1,4 +1,6 @@
1
1
 
2
- OPENAI_API_KEY=sk-4c9334245f5f4e7aa4009650ef0438b0
3
- OPENAI_API_BASE=https://dashscope.aliyuncs.com/compatible-mode/v1
4
- DEFAULT_MODEL=qwen-plus
2
+ #OPENAI_API_KEY=sk-4c9334245f5f4e7aa4009650ef0438b0
3
+ #OPENAI_API_BASE=https://dashscope.aliyuncs.com/compatible-mode/v1
4
+ #DEFAULT_MODEL=qwen-plus
5
+
6
+ # MAX_TOKENS_BEFORE_SUMMARY=1000000
@@ -4,4 +4,43 @@ uv sync
4
4
  # 测试子命令
5
5
  uv run entry.py hello "TestUser" -b "1990/01/01"
6
6
  uv run entry.py calc add 10 20
7
- uv run entry.py calc average 1 2 3 4 5
7
+ uv run entry.py calc average 1 2 3 4 5
8
+
9
+
10
+
11
+ ## run
12
+
13
+ chmod +x run.sh
14
+ alias mini_claw="/Users/brandon/workspace/coder/ai-tcode/tcode/run.sh"
15
+
16
+ $ mini_claw
17
+
18
+
19
+ """
20
+ "appId": "cli_a909847e1278dcbd",
21
+ "appSecret": "bE0usuE0MKUJVDWOo9olib5X8PKv66pK",
22
+ """
23
+
24
+
25
+ mini_claw --mode claw \
26
+ --app-id "cli_a909847e1278dcbd" \
27
+ --app-secret "bE0usuE0MKUJVDWOo9olib5X8PKv66pK" \
28
+ --api-key "sk-4c9334245f5f4e7aa4009650ef0438b0" \
29
+ --base-url "https://dashscope.aliyuncs.com/compatible-mode/v1" \
30
+ --model "qwen-plus"
31
+
32
+
33
+
34
+ mini_claw --mode claw \
35
+ --app-id cli_a909847e1278dcbd \
36
+ --app-secret bE0usuE0MKUJVDWOo9olib5X8PKv66pK \
37
+ --api-key sk-4c9334245f5f4e7aa4009650ef0438b0 \
38
+ --base-url https://dashscope.aliyuncs.com/compatible-mode/v1 \
39
+ --model qwen-plus
40
+
41
+ tcode --mode claw \
42
+ --app-id cli_a909847e1278dcbd \
43
+ --app-secret bE0usuE0MKUJVDWOo9olib5X8PKv66pK \
44
+ --api-key sk-4c9334245f5f4e7aa4009650ef0438b0 \
45
+ --base-url https://dashscope.aliyuncs.com/compatible-mode/v1 \
46
+ --model qwen-plus
@@ -0,0 +1,12 @@
1
+ {
2
+ "channels": {
3
+ "feishu": {
4
+ "enabled": true,
5
+ "appId": "cli_a909847e1278dcbd",
6
+ "appSecret": "bE0usuE0MKUJVDWOo9olib5X8PKv66pK",
7
+ "encryptKey": "",
8
+ "verificationToken": "",
9
+ "allowFrom": []
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "version": 1,
3
+ "jobs": []
4
+ }
@@ -29,6 +29,7 @@ warnings.filterwarnings("ignore", message="Pydantic serializer warnings")
29
29
 
30
30
  import typer
31
31
  import asyncio
32
+ import os
32
33
 
33
34
 
34
35
  from main import (
@@ -36,7 +37,8 @@ from main import (
36
37
  asingle_agent,
37
38
  team_main,
38
39
  run_once,
39
- teminal_chat
40
+ teminal_chat,
41
+ claw_main
40
42
  )
41
43
 
42
44
  app = typer.Typer()
@@ -50,13 +52,38 @@ def root(
50
52
  prompt: str = typer.Option(None, "-p", "--prompt", help="用户输入请求内容"),
51
53
  verbose: bool = typer.Option(False, "-v", "--verbose", help="显示agent执行详细过程"),
52
54
  mode: str = typer.Option("team", "-m", "--mode", help="运行模式,single或team"),
55
+ # ====================== 新增:接收 max_tokens 参数 ======================
56
+ max_tokens: int = typer.Option(None, "--max-in-tokens", help="覆盖环境变量 MAX_TOKENS_BEFORE_SUMMARY"),
57
+ api_key: str = typer.Option(None, "--api-key", help="llm 服务 API_KEY"),
58
+ base_url:str = typer.Option(None, "--base-url", help="llm 服务 base_url"),
59
+ model: str = typer.Option(None, "--model", help="llm 服务 model"),
60
+ # ====================== 新增:接收 claw 相关参数 ======================
61
+ app_id: str = typer.Option(None, "--app-id", help="claw 服务 app_id"),
62
+ app_secret:str = typer.Option(None, "--app-secret", help="claw 服务 app_secret"),
63
+
53
64
  ):
65
+ if max_tokens is not None:
66
+ os.environ["MAX_TOKENS_BEFORE_SUMMARY"] = str(max_tokens)
67
+ # print(f"✅ 已强制覆盖 MAX_TOKENS_BEFORE_SUMMARY = {max_tokens}")
68
+ if api_key is not None:
69
+ os.environ["OPENAI_API_KEY"] = api_key
70
+ if base_url is not None:
71
+ os.environ["OPENAI_API_BASE"] = base_url
72
+ if model is not None:
73
+ os.environ["DEFAULT_MODEL"] = model
74
+ if app_id is not None:
75
+ os.environ["APP_ID"] = app_id
76
+ if app_secret is not None:
77
+ os.environ["APP_SECRET"] = app_secret
78
+
54
79
  if ctx.invoked_subcommand is None:
55
80
  if not prompt:
56
81
  if mode == "single":
57
82
  asyncio.run(asingle_agent())
58
83
  elif mode == "team":
59
84
  asyncio.run(team_main())
85
+ elif mode == 'claw':
86
+ claw_main()
60
87
 
61
88
  # 同步环境执行异步任务
62
89
  asyncio.run(run_once(prompt, verbose))
@@ -67,7 +94,14 @@ def root(
67
94
  @interact_app.command("interact")
68
95
  def interact_mode(
69
96
  verbose: bool = typer.Option(False, "-v", "--verbose", help="显示agent执行详细过程"),
97
+ # ====================== 交互模式也支持覆盖 ======================
98
+ max_tokens: int = typer.Option(None, "--max-in-tokens", help="覆盖环境变量 MAX_TOKENS_BEFORE_SUMMARY"),
70
99
  ):
100
+ if max_tokens is not None:
101
+ print(f"交互模式:当前 MAX_TOKENS_BEFORE_SUMMARY = {os.getenv('MAX_TOKENS_BEFORE_SUMMARY')}")
102
+ os.environ["MAX_TOKENS_BEFORE_SUMMARY"] = str(max_tokens)
103
+ print(f"✅ 交互模式:已覆盖 MAX_TOKENS_BEFORE_SUMMARY = {max_tokens}")
104
+
71
105
  # 执行交互模式
72
106
  asyncio.run(teminal_chat(verbose))
73
107