zrb 1.21.29__py3-none-any.whl → 2.0.0a4__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.

Potentially problematic release.


This version of zrb might be problematic. Click here for more details.

Files changed (192) hide show
  1. zrb/__init__.py +118 -129
  2. zrb/builtin/__init__.py +54 -2
  3. zrb/builtin/llm/chat.py +147 -0
  4. zrb/callback/callback.py +8 -1
  5. zrb/cmd/cmd_result.py +2 -1
  6. zrb/config/config.py +491 -280
  7. zrb/config/helper.py +84 -0
  8. zrb/config/web_auth_config.py +50 -35
  9. zrb/context/any_shared_context.py +13 -2
  10. zrb/context/context.py +31 -3
  11. zrb/context/print_fn.py +13 -0
  12. zrb/context/shared_context.py +14 -1
  13. zrb/input/option_input.py +30 -2
  14. zrb/llm/agent/__init__.py +9 -0
  15. zrb/llm/agent/agent.py +215 -0
  16. zrb/llm/agent/summarizer.py +20 -0
  17. zrb/llm/app/__init__.py +10 -0
  18. zrb/llm/app/completion.py +281 -0
  19. zrb/llm/app/confirmation/allow_tool.py +66 -0
  20. zrb/llm/app/confirmation/handler.py +178 -0
  21. zrb/llm/app/confirmation/replace_confirmation.py +77 -0
  22. zrb/llm/app/keybinding.py +34 -0
  23. zrb/llm/app/layout.py +117 -0
  24. zrb/llm/app/lexer.py +155 -0
  25. zrb/llm/app/redirection.py +28 -0
  26. zrb/llm/app/style.py +16 -0
  27. zrb/llm/app/ui.py +733 -0
  28. zrb/llm/config/__init__.py +4 -0
  29. zrb/llm/config/config.py +122 -0
  30. zrb/llm/config/limiter.py +247 -0
  31. zrb/llm/history_manager/__init__.py +4 -0
  32. zrb/llm/history_manager/any_history_manager.py +23 -0
  33. zrb/llm/history_manager/file_history_manager.py +91 -0
  34. zrb/llm/history_processor/summarizer.py +108 -0
  35. zrb/llm/note/__init__.py +3 -0
  36. zrb/llm/note/manager.py +122 -0
  37. zrb/llm/prompt/__init__.py +29 -0
  38. zrb/llm/prompt/claude_compatibility.py +92 -0
  39. zrb/llm/prompt/compose.py +55 -0
  40. zrb/llm/prompt/default.py +51 -0
  41. zrb/llm/prompt/markdown/mandate.md +23 -0
  42. zrb/llm/prompt/markdown/persona.md +3 -0
  43. zrb/llm/prompt/markdown/summarizer.md +21 -0
  44. zrb/llm/prompt/note.py +41 -0
  45. zrb/llm/prompt/system_context.py +46 -0
  46. zrb/llm/prompt/zrb.py +41 -0
  47. zrb/llm/skill/__init__.py +3 -0
  48. zrb/llm/skill/manager.py +86 -0
  49. zrb/llm/task/__init__.py +4 -0
  50. zrb/llm/task/llm_chat_task.py +316 -0
  51. zrb/llm/task/llm_task.py +245 -0
  52. zrb/llm/tool/__init__.py +39 -0
  53. zrb/llm/tool/bash.py +75 -0
  54. zrb/llm/tool/code.py +266 -0
  55. zrb/llm/tool/file.py +419 -0
  56. zrb/llm/tool/note.py +70 -0
  57. zrb/{builtin/llm → llm}/tool/rag.py +8 -5
  58. zrb/llm/tool/search/brave.py +53 -0
  59. zrb/llm/tool/search/searxng.py +47 -0
  60. zrb/llm/tool/search/serpapi.py +47 -0
  61. zrb/llm/tool/skill.py +19 -0
  62. zrb/llm/tool/sub_agent.py +70 -0
  63. zrb/llm/tool/web.py +97 -0
  64. zrb/llm/tool/zrb_task.py +66 -0
  65. zrb/llm/util/attachment.py +101 -0
  66. zrb/llm/util/prompt.py +104 -0
  67. zrb/llm/util/stream_response.py +178 -0
  68. zrb/session/any_session.py +0 -3
  69. zrb/session/session.py +1 -1
  70. zrb/task/base/context.py +25 -13
  71. zrb/task/base/execution.py +52 -47
  72. zrb/task/base/lifecycle.py +7 -4
  73. zrb/task/base_task.py +48 -49
  74. zrb/task/base_trigger.py +4 -1
  75. zrb/task/cmd_task.py +6 -0
  76. zrb/task/http_check.py +11 -5
  77. zrb/task/make_task.py +3 -0
  78. zrb/task/rsync_task.py +5 -0
  79. zrb/task/scaffolder.py +7 -4
  80. zrb/task/scheduler.py +3 -0
  81. zrb/task/tcp_check.py +6 -4
  82. zrb/util/ascii_art/art/bee.txt +17 -0
  83. zrb/util/ascii_art/art/cat.txt +9 -0
  84. zrb/util/ascii_art/art/ghost.txt +16 -0
  85. zrb/util/ascii_art/art/panda.txt +17 -0
  86. zrb/util/ascii_art/art/rose.txt +14 -0
  87. zrb/util/ascii_art/art/unicorn.txt +15 -0
  88. zrb/util/ascii_art/banner.py +92 -0
  89. zrb/util/cli/markdown.py +22 -2
  90. zrb/util/cmd/command.py +33 -10
  91. zrb/util/file.py +51 -32
  92. zrb/util/match.py +78 -0
  93. zrb/util/run.py +3 -3
  94. {zrb-1.21.29.dist-info → zrb-2.0.0a4.dist-info}/METADATA +9 -15
  95. {zrb-1.21.29.dist-info → zrb-2.0.0a4.dist-info}/RECORD +100 -128
  96. zrb/attr/__init__.py +0 -0
  97. zrb/builtin/llm/attachment.py +0 -40
  98. zrb/builtin/llm/chat_completion.py +0 -274
  99. zrb/builtin/llm/chat_session.py +0 -270
  100. zrb/builtin/llm/chat_session_cmd.py +0 -288
  101. zrb/builtin/llm/chat_trigger.py +0 -79
  102. zrb/builtin/llm/history.py +0 -71
  103. zrb/builtin/llm/input.py +0 -27
  104. zrb/builtin/llm/llm_ask.py +0 -269
  105. zrb/builtin/llm/previous-session.js +0 -21
  106. zrb/builtin/llm/tool/__init__.py +0 -0
  107. zrb/builtin/llm/tool/api.py +0 -75
  108. zrb/builtin/llm/tool/cli.py +0 -52
  109. zrb/builtin/llm/tool/code.py +0 -236
  110. zrb/builtin/llm/tool/file.py +0 -560
  111. zrb/builtin/llm/tool/note.py +0 -84
  112. zrb/builtin/llm/tool/sub_agent.py +0 -150
  113. zrb/builtin/llm/tool/web.py +0 -171
  114. zrb/builtin/project/__init__.py +0 -0
  115. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/__init__.py +0 -0
  116. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/template/app_template/module/my_module/service/__init__.py +0 -0
  117. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/common/__init__.py +0 -0
  118. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/__init__.py +0 -0
  119. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/__init__.py +0 -0
  120. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/permission/__init__.py +0 -0
  121. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/role/__init__.py +0 -0
  122. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/user/__init__.py +0 -0
  123. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/schema/__init__.py +0 -0
  124. zrb/builtin/project/create/__init__.py +0 -0
  125. zrb/builtin/shell/__init__.py +0 -0
  126. zrb/builtin/shell/autocomplete/__init__.py +0 -0
  127. zrb/callback/__init__.py +0 -0
  128. zrb/cmd/__init__.py +0 -0
  129. zrb/config/default_prompt/interactive_system_prompt.md +0 -29
  130. zrb/config/default_prompt/persona.md +0 -1
  131. zrb/config/default_prompt/summarization_prompt.md +0 -57
  132. zrb/config/default_prompt/system_prompt.md +0 -38
  133. zrb/config/llm_config.py +0 -339
  134. zrb/config/llm_context/config.py +0 -166
  135. zrb/config/llm_context/config_parser.py +0 -40
  136. zrb/config/llm_context/workflow.py +0 -81
  137. zrb/config/llm_rate_limitter.py +0 -190
  138. zrb/content_transformer/__init__.py +0 -0
  139. zrb/context/__init__.py +0 -0
  140. zrb/dot_dict/__init__.py +0 -0
  141. zrb/env/__init__.py +0 -0
  142. zrb/group/__init__.py +0 -0
  143. zrb/input/__init__.py +0 -0
  144. zrb/runner/__init__.py +0 -0
  145. zrb/runner/web_route/__init__.py +0 -0
  146. zrb/runner/web_route/home_page/__init__.py +0 -0
  147. zrb/session/__init__.py +0 -0
  148. zrb/session_state_log/__init__.py +0 -0
  149. zrb/session_state_logger/__init__.py +0 -0
  150. zrb/task/__init__.py +0 -0
  151. zrb/task/base/__init__.py +0 -0
  152. zrb/task/llm/__init__.py +0 -0
  153. zrb/task/llm/agent.py +0 -204
  154. zrb/task/llm/agent_runner.py +0 -152
  155. zrb/task/llm/config.py +0 -122
  156. zrb/task/llm/conversation_history.py +0 -209
  157. zrb/task/llm/conversation_history_model.py +0 -67
  158. zrb/task/llm/default_workflow/coding/workflow.md +0 -41
  159. zrb/task/llm/default_workflow/copywriting/workflow.md +0 -68
  160. zrb/task/llm/default_workflow/git/workflow.md +0 -118
  161. zrb/task/llm/default_workflow/golang/workflow.md +0 -128
  162. zrb/task/llm/default_workflow/html-css/workflow.md +0 -135
  163. zrb/task/llm/default_workflow/java/workflow.md +0 -146
  164. zrb/task/llm/default_workflow/javascript/workflow.md +0 -158
  165. zrb/task/llm/default_workflow/python/workflow.md +0 -160
  166. zrb/task/llm/default_workflow/researching/workflow.md +0 -153
  167. zrb/task/llm/default_workflow/rust/workflow.md +0 -162
  168. zrb/task/llm/default_workflow/shell/workflow.md +0 -299
  169. zrb/task/llm/error.py +0 -95
  170. zrb/task/llm/file_replacement.py +0 -206
  171. zrb/task/llm/file_tool_model.py +0 -57
  172. zrb/task/llm/history_processor.py +0 -206
  173. zrb/task/llm/history_summarization.py +0 -25
  174. zrb/task/llm/print_node.py +0 -221
  175. zrb/task/llm/prompt.py +0 -321
  176. zrb/task/llm/subagent_conversation_history.py +0 -41
  177. zrb/task/llm/tool_wrapper.py +0 -361
  178. zrb/task/llm/typing.py +0 -3
  179. zrb/task/llm/workflow.py +0 -76
  180. zrb/task/llm_task.py +0 -379
  181. zrb/task_status/__init__.py +0 -0
  182. zrb/util/__init__.py +0 -0
  183. zrb/util/cli/__init__.py +0 -0
  184. zrb/util/cmd/__init__.py +0 -0
  185. zrb/util/codemod/__init__.py +0 -0
  186. zrb/util/string/__init__.py +0 -0
  187. zrb/xcom/__init__.py +0 -0
  188. /zrb/{config/default_prompt/file_extractor_system_prompt.md → llm/prompt/markdown/file_extractor.md} +0 -0
  189. /zrb/{config/default_prompt/repo_extractor_system_prompt.md → llm/prompt/markdown/repo_extractor.md} +0 -0
  190. /zrb/{config/default_prompt/repo_summarizer_system_prompt.md → llm/prompt/markdown/repo_summarizer.md} +0 -0
  191. {zrb-1.21.29.dist-info → zrb-2.0.0a4.dist-info}/WHEEL +0 -0
  192. {zrb-1.21.29.dist-info → zrb-2.0.0a4.dist-info}/entry_points.txt +0 -0
zrb/__init__.py CHANGED
@@ -1,130 +1,119 @@
1
- import importlib
2
- from typing import TYPE_CHECKING, Any
3
-
4
- _LAZY_LOAD = {
5
- "AnyAttr": "zrb.attr.type",
6
- "BoolAttr": "zrb.attr.type",
7
- "FloatAttr": "zrb.attr.type",
8
- "IntAttr": "zrb.attr.type",
9
- "StrAttr": "zrb.attr.type",
10
- "StrDictAttr": "zrb.attr.type",
11
- "fstring": "zrb.attr.type",
12
- "AnyCallback": "zrb.callback.any_callback",
13
- "Callback": "zrb.callback.callback",
14
- "CmdResult": "zrb.cmd.cmd_result",
15
- "Cmd": "zrb.cmd.cmd_val",
16
- "CmdPath": "zrb.cmd.cmd_val",
17
- "CFG": "zrb.config.config",
18
- "AnyContentTransformer": "zrb.content_transformer.any_content_transformer",
19
- "ContentTransformer": "zrb.content_transformer.content_transformer",
20
- "AnyContext": "zrb.context.any_context",
21
- "AnySharedContext": "zrb.context.any_shared_context",
22
- "Context": "zrb.context.context",
23
- "SharedContext": "zrb.context.shared_context",
24
- "AnyEnv": "zrb.env.any_env",
25
- "Env": "zrb.env.env",
26
- "EnvFile": "zrb.env.env_file",
27
- "EnvMap": "zrb.env.env_map",
28
- "AnyGroup": "zrb.group.any_group",
29
- "Group": "zrb.group.group",
30
- "AnyInput": "zrb.input.any_input",
31
- "BaseInput": "zrb.input.base_input",
32
- "BoolInput": "zrb.input.bool_input",
33
- "FloatInput": "zrb.input.float_input",
34
- "IntInput": "zrb.input.int_input",
35
- "OptionInput": "zrb.input.option_input",
36
- "PasswordInput": "zrb.input.password_input",
37
- "StrInput": "zrb.input.str_input",
38
- "TextInput": "zrb.input.text_input",
39
- "llm_config": "zrb.config.llm_config",
40
- "llm_rate_limitter": "zrb.config.llm_rate_limitter",
41
- "cli": "zrb.runner.cli",
42
- "web_auth_config": "zrb.config.web_auth_config",
43
- "User": "zrb.runner.web_schema.user",
44
- "Session": "zrb.session.session",
45
- "AnyTask": "zrb.task.any_task",
46
- "BaseTask": "zrb.task.base_task",
47
- "BaseTrigger": "zrb.task.base_trigger",
48
- "CmdTask": "zrb.task.cmd_task",
49
- "HttpCheck": "zrb.task.http_check",
50
- "ConversationHistory": "zrb.task.llm.conversation_history",
51
- "LLMTask": "zrb.task.llm_task",
52
- "make_task": "zrb.task.make_task",
53
- "RsyncTask": "zrb.task.rsync_task",
54
- "Scaffolder": "zrb.task.scaffolder",
55
- "Scheduler": "zrb.task.scheduler",
56
- "Task": "zrb.task.task",
57
- "TcpCheck": "zrb.task.tcp_check",
58
- "load_file": "zrb.util.load",
59
- "load_module": "zrb.util.load",
60
- "Xcom": "zrb.xcom.xcom",
61
- }
62
-
63
- if TYPE_CHECKING:
64
- from zrb import builtin
65
- from zrb.attr.type import (
66
- AnyAttr,
67
- BoolAttr,
68
- FloatAttr,
69
- IntAttr,
70
- StrAttr,
71
- StrDictAttr,
72
- fstring,
73
- )
74
- from zrb.callback.any_callback import AnyCallback
75
- from zrb.callback.callback import Callback
76
- from zrb.cmd.cmd_result import CmdResult
77
- from zrb.cmd.cmd_val import Cmd, CmdPath
78
- from zrb.config.config import CFG
79
- from zrb.config.llm_config import llm_config
80
- from zrb.config.llm_rate_limitter import llm_rate_limitter
81
- from zrb.config.web_auth_config import web_auth_config
82
- from zrb.content_transformer.any_content_transformer import AnyContentTransformer
83
- from zrb.content_transformer.content_transformer import ContentTransformer
84
- from zrb.context.any_context import AnyContext
85
- from zrb.context.any_shared_context import AnySharedContext
86
- from zrb.context.context import Context
87
- from zrb.context.shared_context import SharedContext
88
- from zrb.env.any_env import AnyEnv
89
- from zrb.env.env import Env
90
- from zrb.env.env_file import EnvFile
91
- from zrb.env.env_map import EnvMap
92
- from zrb.group.any_group import AnyGroup
93
- from zrb.group.group import Group
94
- from zrb.input.any_input import AnyInput
95
- from zrb.input.base_input import BaseInput
96
- from zrb.input.bool_input import BoolInput
97
- from zrb.input.float_input import FloatInput
98
- from zrb.input.int_input import IntInput
99
- from zrb.input.option_input import OptionInput
100
- from zrb.input.password_input import PasswordInput
101
- from zrb.input.str_input import StrInput
102
- from zrb.input.text_input import TextInput
103
- from zrb.runner.cli import cli
104
- from zrb.runner.web_schema.user import User
105
- from zrb.session.session import Session
106
- from zrb.task.any_task import AnyTask
107
- from zrb.task.base_task import BaseTask
108
- from zrb.task.base_trigger import BaseTrigger
109
- from zrb.task.cmd_task import CmdTask
110
- from zrb.task.http_check import HttpCheck
111
- from zrb.task.llm.conversation_history import ConversationHistory
112
- from zrb.task.llm_task import LLMTask
113
- from zrb.task.make_task import make_task
114
- from zrb.task.rsync_task import RsyncTask
115
- from zrb.task.scaffolder import Scaffolder
116
- from zrb.task.scheduler import Scheduler
117
- from zrb.task.task import Task
118
- from zrb.task.tcp_check import TcpCheck
119
- from zrb.util.load import load_file, load_module
120
- from zrb.xcom.xcom import Xcom
121
-
122
-
123
- def __getattr__(name: str) -> Any:
124
- if name in _LAZY_LOAD:
125
- module = importlib.import_module(_LAZY_LOAD[name])
126
- return getattr(module, name)
127
- raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
128
-
129
-
130
1
  from zrb import builtin
2
+ from zrb.attr.type import (
3
+ AnyAttr,
4
+ BoolAttr,
5
+ FloatAttr,
6
+ IntAttr,
7
+ StrAttr,
8
+ StrDictAttr,
9
+ fstring,
10
+ )
11
+ from zrb.callback.any_callback import AnyCallback
12
+ from zrb.callback.callback import Callback
13
+ from zrb.cmd.cmd_result import CmdResult
14
+ from zrb.cmd.cmd_val import Cmd, CmdPath
15
+ from zrb.config.config import CFG
16
+ from zrb.config.web_auth_config import web_auth_config
17
+ from zrb.content_transformer.any_content_transformer import AnyContentTransformer
18
+ from zrb.content_transformer.content_transformer import ContentTransformer
19
+ from zrb.context.any_context import AnyContext
20
+ from zrb.context.any_shared_context import AnySharedContext
21
+ from zrb.context.context import Context
22
+ from zrb.context.shared_context import SharedContext
23
+ from zrb.env.any_env import AnyEnv
24
+ from zrb.env.env import Env
25
+ from zrb.env.env_file import EnvFile
26
+ from zrb.env.env_map import EnvMap
27
+ from zrb.group.any_group import AnyGroup
28
+ from zrb.group.group import Group
29
+ from zrb.input.any_input import AnyInput
30
+ from zrb.input.base_input import BaseInput
31
+ from zrb.input.bool_input import BoolInput
32
+ from zrb.input.float_input import FloatInput
33
+ from zrb.input.int_input import IntInput
34
+ from zrb.input.option_input import OptionInput
35
+ from zrb.input.password_input import PasswordInput
36
+ from zrb.input.str_input import StrInput
37
+ from zrb.input.text_input import TextInput
38
+ from zrb.llm.config.config import LLMConfig, llm_config
39
+ from zrb.llm.config.limiter import LLMLimiter, llm_limiter
40
+ from zrb.llm.task.llm_chat_task import LLMChatTask
41
+ from zrb.llm.task.llm_task import LLMTask
42
+ from zrb.runner.cli import cli
43
+ from zrb.runner.web_schema.user import User
44
+ from zrb.session.session import Session
45
+ from zrb.task.any_task import AnyTask
46
+ from zrb.task.base_task import BaseTask
47
+ from zrb.task.base_trigger import BaseTrigger
48
+ from zrb.task.cmd_task import CmdTask
49
+ from zrb.task.http_check import HttpCheck
50
+ from zrb.task.make_task import make_task
51
+ from zrb.task.rsync_task import RsyncTask
52
+ from zrb.task.scaffolder import Scaffolder
53
+ from zrb.task.scheduler import Scheduler
54
+ from zrb.task.task import Task
55
+ from zrb.task.tcp_check import TcpCheck
56
+ from zrb.util.load import load_file, load_module
57
+ from zrb.xcom.xcom import Xcom
58
+
59
+ __all__ = [
60
+ "builtin",
61
+ "AnyAttr",
62
+ "BoolAttr",
63
+ "FloatAttr",
64
+ "IntAttr",
65
+ "StrAttr",
66
+ "StrDictAttr",
67
+ "fstring",
68
+ "AnyCallback",
69
+ "Callback",
70
+ "CmdResult",
71
+ "Cmd",
72
+ "CmdPath",
73
+ "CFG",
74
+ "web_auth_config",
75
+ "AnyContentTransformer",
76
+ "ContentTransformer",
77
+ "AnyContext",
78
+ "AnySharedContext",
79
+ "Context",
80
+ "SharedContext",
81
+ "AnyEnv",
82
+ "Env",
83
+ "EnvFile",
84
+ "EnvMap",
85
+ "AnyGroup",
86
+ "Group",
87
+ "AnyInput",
88
+ "BaseInput",
89
+ "BoolInput",
90
+ "FloatInput",
91
+ "IntInput",
92
+ "OptionInput",
93
+ "PasswordInput",
94
+ "StrInput",
95
+ "TextInput",
96
+ "cli",
97
+ "User",
98
+ "Session",
99
+ "AnyTask",
100
+ "BaseTask",
101
+ "BaseTrigger",
102
+ "CmdTask",
103
+ "HttpCheck",
104
+ "make_task",
105
+ "RsyncTask",
106
+ "Scaffolder",
107
+ "Scheduler",
108
+ "Task",
109
+ "TcpCheck",
110
+ "load_file",
111
+ "load_module",
112
+ "Xcom",
113
+ "LLMTask",
114
+ "LLMChatTask",
115
+ "LLMConfig",
116
+ "llm_config",
117
+ "LLMLimiter",
118
+ "llm_limiter",
119
+ ]
zrb/builtin/__init__.py CHANGED
@@ -9,8 +9,7 @@ from zrb.builtin.git import (
9
9
  from zrb.builtin.git_subtree import git_add_subtree, git_pull_subtree, git_push_subtree
10
10
  from zrb.builtin.http import generate_curl, http_request
11
11
  from zrb.builtin.jwt import decode_jwt, encode_jwt, validate_jwt
12
- from zrb.builtin.llm.chat_trigger import llm_chat_trigger
13
- from zrb.builtin.llm.llm_ask import llm_ask
12
+ from zrb.builtin.llm.chat import llm_chat
14
13
  from zrb.builtin.md5 import hash_md5, sum_md5, validate_md5
15
14
  from zrb.builtin.project.add.fastapp.fastapp_task import add_fastapp_to_project
16
15
  from zrb.builtin.project.create.project_task import create_project
@@ -45,3 +44,56 @@ from zrb.builtin.uuid import (
45
44
  validate_uuid_v4,
46
45
  validate_uuid_v5,
47
46
  )
47
+
48
+ __all__ = [
49
+ "decode_base64",
50
+ "encode_base64",
51
+ "validate_base64",
52
+ "get_git_diff",
53
+ "git_commit",
54
+ "git_pull",
55
+ "git_push",
56
+ "prune_local_branches",
57
+ "git_add_subtree",
58
+ "git_pull_subtree",
59
+ "git_push_subtree",
60
+ "generate_curl",
61
+ "http_request",
62
+ "decode_jwt",
63
+ "encode_jwt",
64
+ "validate_jwt",
65
+ "llm_chat",
66
+ "hash_md5",
67
+ "sum_md5",
68
+ "validate_md5",
69
+ "add_fastapp_to_project",
70
+ "create_project",
71
+ "format_python_code",
72
+ "shuffle_values",
73
+ "throw_dice",
74
+ "start_searxng",
75
+ "setup_asdf",
76
+ "setup_latex_on_ubuntu",
77
+ "setup_tmux",
78
+ "setup_ubuntu",
79
+ "setup_zsh",
80
+ "make_bash_autocomplete",
81
+ "get_shell_subcommands",
82
+ "make_zsh_autocomplete",
83
+ "add_todo",
84
+ "archive_todo",
85
+ "complete_todo",
86
+ "edit_todo",
87
+ "list_todo",
88
+ "log_todo",
89
+ "show_todo",
90
+ "generate_uuid_v1",
91
+ "generate_uuid_v3",
92
+ "generate_uuid_v4",
93
+ "generate_uuid_v5",
94
+ "validate_uuid",
95
+ "validate_uuid_v1",
96
+ "validate_uuid_v3",
97
+ "validate_uuid_v4",
98
+ "validate_uuid_v5",
99
+ ]
@@ -0,0 +1,147 @@
1
+ from zrb.builtin.group import llm_group
2
+ from zrb.config.config import CFG
3
+ from zrb.input.bool_input import BoolInput
4
+ from zrb.input.str_input import StrInput
5
+ from zrb.llm.app.confirmation.replace_confirmation import replace_confirmation
6
+ from zrb.llm.history_processor.summarizer import create_summarizer_history_processor
7
+ from zrb.llm.note.manager import NoteManager
8
+ from zrb.llm.prompt.claude_compatibility import (
9
+ create_claude_compatibility_prompt,
10
+ )
11
+ from zrb.llm.prompt.compose import PromptManager, new_prompt
12
+ from zrb.llm.prompt.default import (
13
+ get_mandate_prompt,
14
+ get_persona_prompt,
15
+ )
16
+ from zrb.llm.prompt.note import create_note_prompt
17
+ from zrb.llm.prompt.system_context import system_context
18
+ from zrb.llm.prompt.zrb import create_zrb_prompt
19
+ from zrb.llm.skill.manager import SkillManager
20
+ from zrb.llm.task.llm_chat_task import LLMChatTask
21
+ from zrb.llm.tool.bash import run_shell_command
22
+ from zrb.llm.tool.code import analyze_code
23
+ from zrb.llm.tool.file import (
24
+ analyze_file,
25
+ list_files,
26
+ read_file,
27
+ read_files,
28
+ replace_in_file,
29
+ search_files,
30
+ write_file,
31
+ write_files,
32
+ )
33
+ from zrb.llm.tool.note import create_note_tools
34
+ from zrb.llm.tool.skill import create_activate_skill_tool
35
+ from zrb.llm.tool.sub_agent import create_sub_agent_tool
36
+ from zrb.llm.tool.web import open_web_page, search_internet
37
+ from zrb.llm.tool.zrb_task import create_list_zrb_task_tool, create_run_zrb_task_tool
38
+ from zrb.runner.cli import cli
39
+
40
+ skill_manager = SkillManager()
41
+ note_manager = NoteManager()
42
+
43
+ llm_chat = LLMChatTask(
44
+ name="chat",
45
+ description="🤖 Chat with your AI Assistant",
46
+ input=[
47
+ StrInput("message", "Message", allow_empty=True, always_prompt=False),
48
+ StrInput(
49
+ "session", "Conversation Session", allow_empty=True, always_prompt=False
50
+ ),
51
+ BoolInput(
52
+ "yolo", "YOLO Mode", default=False, allow_empty=True, always_prompt=False
53
+ ),
54
+ StrInput("attach", "Attachments", allow_empty=True, always_prompt=False),
55
+ BoolInput(
56
+ "interactive",
57
+ "Interactive Mode",
58
+ default=True,
59
+ allow_empty=True,
60
+ always_prompt=False,
61
+ ),
62
+ ],
63
+ yolo="{ctx.input.yolo}",
64
+ message="{ctx.input.message}",
65
+ conversation_name="{ctx.input.session}",
66
+ interactive="{ctx.input.interactive}",
67
+ history_processors=[
68
+ create_summarizer_history_processor(
69
+ token_threshold=CFG.LLM_HISTORY_SUMMARIZATION_TOKEN_THRESHOLD,
70
+ summary_window=CFG.LLM_HISTORY_SUMMARIZATION_WINDOW,
71
+ )
72
+ ],
73
+ prompt_manager=PromptManager(),
74
+ ui_ascii_art=lambda ctx: CFG.LLM_ASSISTANT_ASCII_ART,
75
+ ui_assistant_name=lambda ctx: CFG.LLM_ASSISTANT_NAME,
76
+ ui_greeting=lambda ctx: f"{CFG.LLM_ASSISTANT_NAME}\n{CFG.LLM_ASSISTANT_JARGON}",
77
+ ui_jargon=lambda ctx: CFG.LLM_ASSISTANT_JARGON,
78
+ ui_summarize_commands=["/compress", "/compact"],
79
+ ui_attach_commands=["/attach"],
80
+ ui_exit_commands=["/q", "/bye", "/quit", "/exit"],
81
+ ui_info_commands=["/info", "/help"],
82
+ ui_save_commands=["/save"],
83
+ ui_load_commands=["/load"],
84
+ ui_yolo_toggle_commands=["/yolo"],
85
+ ui_redirect_output_commands=[">", "/redirect"],
86
+ ui_exec_commands=["!", "/exec"],
87
+ )
88
+ llm_group.add_task(llm_chat)
89
+ cli.add_task(llm_chat)
90
+
91
+
92
+ async def roll_dice() -> str:
93
+ """Roll a six-sided die and return the result."""
94
+ import asyncio
95
+ import random
96
+
97
+ await asyncio.sleep(3)
98
+ return str(random.randint(1, 6))
99
+
100
+
101
+ async def get_current_time() -> str:
102
+ """Get the current time."""
103
+ from datetime import datetime
104
+
105
+ return datetime.now().strftime("%H:%M:%S")
106
+
107
+
108
+ joke_agent = create_sub_agent_tool(
109
+ name="joke_agent",
110
+ description="Generates jokes about the current directory content.",
111
+ system_prompt=(
112
+ "You are a comedian. Use the 'run_shell_command' tool to list files "
113
+ "(ls -la) and make a funny joke about the project structure."
114
+ ),
115
+ tools=[run_shell_command],
116
+ )
117
+
118
+ llm_chat.prompt_manager.add_middleware(
119
+ new_prompt(get_persona_prompt(CFG.LLM_ASSISTANT_NAME)),
120
+ new_prompt(get_mandate_prompt()),
121
+ system_context,
122
+ create_note_prompt(note_manager),
123
+ create_claude_compatibility_prompt(skill_manager),
124
+ create_zrb_prompt(),
125
+ )
126
+ llm_chat.add_confirmation_middleware(replace_confirmation)
127
+ llm_chat.add_tool(
128
+ roll_dice,
129
+ joke_agent,
130
+ run_shell_command,
131
+ list_files,
132
+ read_file,
133
+ read_files,
134
+ write_file,
135
+ write_files,
136
+ replace_in_file,
137
+ search_files,
138
+ analyze_file,
139
+ analyze_code,
140
+ search_internet,
141
+ open_web_page,
142
+ create_list_zrb_task_tool(),
143
+ create_run_zrb_task_tool(),
144
+ create_activate_skill_tool(skill_manager),
145
+ *create_note_tools(note_manager),
146
+ )
147
+ llm_chat.add_tool(get_current_time)
zrb/callback/callback.py CHANGED
@@ -6,7 +6,6 @@ from zrb.callback.any_callback import AnyCallback
6
6
  from zrb.session.any_session import AnySession
7
7
  from zrb.task.any_task import AnyTask
8
8
  from zrb.util.attr import get_str_dict_attr
9
- from zrb.util.cli.style import stylize_faint
10
9
  from zrb.util.string.conversion import to_snake_case
11
10
  from zrb.xcom.xcom import Xcom
12
11
 
@@ -24,6 +23,7 @@ class Callback(AnyCallback):
24
23
  task: AnyTask,
25
24
  input_mapping: StrDictAttr,
26
25
  render_input_mapping: bool = True,
26
+ xcom_mapping: dict[str, str] | None = None,
27
27
  result_queue: str | None = None,
28
28
  error_queue: str | None = None,
29
29
  session_name_queue: str | None = None,
@@ -36,6 +36,7 @@ class Callback(AnyCallback):
36
36
  input_mapping: A dictionary or attribute mapping to prepare inputs for the task.
37
37
  render_input_mapping: Whether to render the input mapping using
38
38
  f-string like syntax.
39
+ xcom_mapping: Map of parent session's xcom names to current session's xcom names
39
40
  result_queue: The name of the XCom queue in the parent session
40
41
  to publish the task result.
41
42
  result_queue: The name of the Xcom queue in the parent session
@@ -46,6 +47,7 @@ class Callback(AnyCallback):
46
47
  self._task = task
47
48
  self._input_mapping = input_mapping
48
49
  self._render_input_mapping = render_input_mapping
50
+ self._xcom_mapping = xcom_mapping
49
51
  self._result_queue = result_queue
50
52
  self._error_queue = error_queue
51
53
  self._session_name_queue = session_name_queue
@@ -63,6 +65,11 @@ class Callback(AnyCallback):
63
65
  for name, value in inputs.items():
64
66
  session.shared_ctx.input[name] = value
65
67
  session.shared_ctx.input[to_snake_case(name)] = value
68
+ # map xcom
69
+ if self._xcom_mapping is not None:
70
+ for parent_xcom_name, current_xcom_name in self._xcom_mapping.items():
71
+ parent_xcom = parent_session.shared_ctx.xcom[parent_xcom_name]
72
+ session.shared_ctx.xcom[current_xcom_name] = parent_xcom
66
73
  # run task and get result
67
74
  try:
68
75
  result = await self._task.async_run(session)
zrb/cmd/cmd_result.py CHANGED
@@ -1,7 +1,8 @@
1
1
  class CmdResult:
2
- def __init__(self, output: str, error: str):
2
+ def __init__(self, output: str, error: str, display: str):
3
3
  self.output = output
4
4
  self.error = error
5
+ self.display = display
5
6
 
6
7
  def __repr__(self):
7
8
  class_name = self.__class__.__name__