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
@@ -1,150 +0,0 @@
1
- import json
2
- from collections.abc import Callable
3
- from textwrap import dedent
4
- from typing import TYPE_CHECKING, Any, Coroutine
5
-
6
- from zrb.context.any_context import AnyContext
7
- from zrb.task.llm.agent import create_agent_instance
8
- from zrb.task.llm.agent_runner import run_agent_iteration
9
- from zrb.task.llm.config import get_model, get_model_settings
10
- from zrb.task.llm.prompt import get_system_and_user_prompt
11
- from zrb.task.llm.subagent_conversation_history import (
12
- get_ctx_subagent_history,
13
- set_ctx_subagent_history,
14
- )
15
-
16
- if TYPE_CHECKING:
17
- from pydantic_ai import Tool
18
- from pydantic_ai._agent_graph import HistoryProcessor
19
- from pydantic_ai.models import Model
20
- from pydantic_ai.settings import ModelSettings
21
- from pydantic_ai.toolsets import AbstractToolset
22
-
23
- ToolOrCallable = Tool | Callable
24
-
25
-
26
- def create_sub_agent_tool(
27
- tool_name: str,
28
- tool_description: str,
29
- system_prompt: str | None = None,
30
- model: "str | Model | None" = None,
31
- model_settings: "ModelSettings | None" = None,
32
- tools: "list[ToolOrCallable]" = [],
33
- toolsets: list["AbstractToolset[None]"] = [],
34
- yolo_mode: bool | list[str] | None = None,
35
- history_processors: list["HistoryProcessor"] | None = None,
36
- log_indent_level: int = 2,
37
- agent_name: str | None = None,
38
- auto_summarize: bool = True,
39
- remember_history: bool = True,
40
- ) -> Callable[[AnyContext, str], Coroutine[Any, Any, Any]]:
41
- """
42
- Create a tool that is another AI agent, capable of handling complex, multi-step sub-tasks.
43
-
44
- This factory function generates a tool that, when used, spins up a temporary, specialized
45
- AI agent. This "sub-agent" has its own system prompt, tools, and context, allowing it to
46
- focus on accomplishing a specific task without being distracted by the main conversation.
47
-
48
- This is ideal for delegating complex tasks like analyzing a file or a repository.
49
-
50
- Args:
51
- tool_name (str): The name for the generated sub-agent tool.
52
- tool_description (str): A clear description of the sub-agent's purpose and when to
53
- use it. This is what the LLM will see.
54
- system_prompt (str, optional): The system prompt that will guide the sub-agent's
55
- behavior.
56
- model (str | Model, optional): The language model the sub-agent will use.
57
- model_settings (ModelSettings, optional): Specific settings for the sub-agent's model.
58
- tools (list, optional): A list of tools that will be exclusively available to the
59
- sub-agent.
60
- toolsets (list, optional): A list of Toolsets for the sub-agent.
61
-
62
- Returns:
63
- An asynchronous function that serves as the sub-agent tool. When called, it runs the
64
- sub-agent with a given query and returns its final result.
65
- """
66
- if agent_name is None:
67
- agent_name = f"{tool_name}_agent"
68
-
69
- async def run_sub_agent(ctx: AnyContext, query: str) -> Any:
70
- """
71
- Runs the sub-agent with the given query.
72
- """
73
- # Resolve parameters, falling back to llm_config defaults if None
74
- resolved_model = get_model(
75
- ctx=ctx,
76
- model_attr=model,
77
- render_model=True, # Assuming we always want to render model string attributes
78
- model_base_url_attr=None,
79
- # Sub-agent tool doesn't have separate base_url/api_key params
80
- render_model_base_url=False,
81
- model_api_key_attr=None,
82
- render_model_api_key=False,
83
- )
84
- resolved_model_settings = get_model_settings(
85
- ctx=ctx,
86
- model_settings_attr=model_settings,
87
- )
88
- if system_prompt is None:
89
- resolved_system_prompt, query = get_system_and_user_prompt(
90
- ctx=ctx,
91
- user_message=query,
92
- persona_attr=None,
93
- system_prompt_attr=None,
94
- special_instruction_prompt_attr=None,
95
- )
96
- else:
97
- resolved_system_prompt = system_prompt
98
- # Create the sub-agent instance
99
- sub_agent_agent = create_agent_instance(
100
- ctx=ctx,
101
- model=resolved_model,
102
- system_prompt=resolved_system_prompt,
103
- model_settings=resolved_model_settings,
104
- tools=tools,
105
- toolsets=toolsets,
106
- yolo_mode=yolo_mode,
107
- history_processors=history_processors,
108
- auto_summarize=auto_summarize,
109
- )
110
- sub_agent_run = None
111
- # Run the sub-agent iteration
112
- history_list = (
113
- get_ctx_subagent_history(ctx, agent_name) if remember_history else []
114
- )
115
- sub_agent_run = await run_agent_iteration(
116
- ctx=ctx,
117
- agent=sub_agent_agent,
118
- user_prompt=query,
119
- attachments=[],
120
- history_list=history_list,
121
- log_indent_level=log_indent_level,
122
- )
123
- # Return the sub-agent's final message content
124
- if sub_agent_run and sub_agent_run.result:
125
- # Return the final message content
126
- if remember_history:
127
- set_ctx_subagent_history(
128
- ctx,
129
- agent_name,
130
- json.loads(sub_agent_run.result.all_messages_json()),
131
- )
132
- return sub_agent_run.result.output
133
- ctx.log_warning("Sub-agent run did not produce a result.")
134
- raise ValueError(f"{tool_name} not returning any result")
135
-
136
- # Set the name and docstring for the callable function
137
- run_sub_agent.__name__ = tool_name
138
- run_sub_agent.__doc__ = dedent(
139
- f"""
140
- {tool_description}
141
-
142
- Args:
143
- query (str): The query or task for the sub-agent.
144
-
145
- Returns:
146
- Any: The final response or result from the sub-agent.
147
- """
148
- ).strip()
149
-
150
- return run_sub_agent
@@ -1,171 +0,0 @@
1
- from collections.abc import Callable
2
- from typing import Any
3
- from urllib.parse import urljoin
4
-
5
- from zrb.config.config import CFG
6
- from zrb.config.llm_config import llm_config
7
-
8
- _DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36" # noqa
9
-
10
-
11
- async def open_web_page(url: str) -> dict[str, Any]:
12
- """
13
- Fetches, parses, and converts a web page to readable Markdown.
14
- Preserves semantic structure, removes non-essentials, and extracts all absolute links.
15
-
16
- Example:
17
- open_web_page(url='https://www.example.com/article')
18
-
19
- Args:
20
- url (str): The full URL of the web page.
21
-
22
- Returns:
23
- dict: Markdown content and a list of absolute links.
24
- """
25
- html_content, links = await _fetch_page_content(url)
26
- markdown_content = _convert_html_to_markdown(html_content)
27
- return {"content": markdown_content, "links_on_page": links}
28
-
29
-
30
- def create_search_internet_tool() -> Callable:
31
- if llm_config.default_search_internet_tool is not None:
32
- return llm_config.default_search_internet_tool
33
-
34
- def search_internet(query: str, page: int = 1) -> dict[str, Any]:
35
- """
36
- Performs an internet search using a search engine.
37
- Use to find information, answer general knowledge, or research topics.
38
-
39
- Example:
40
- search_internet(query='latest AI advancements', page=1)
41
-
42
- Args:
43
- query (str): The search query.
44
- page (int, optional): Search result page number. Defaults to 1.
45
-
46
- Returns:
47
- dict: Summary of search results (titles, links, snippets).
48
- """
49
- import requests
50
-
51
- if (
52
- CFG.SEARCH_INTERNET_METHOD.strip().lower() == "serpapi"
53
- and CFG.SERPAPI_KEY != ""
54
- ):
55
- response = requests.get(
56
- "https://serpapi.com/search",
57
- headers={"User-Agent": _DEFAULT_USER_AGENT},
58
- params={
59
- "q": query,
60
- "start": (page - 1) * 10,
61
- "hl": CFG.SERPAPI_LANG,
62
- "safe": CFG.SERPAPI_SAFE,
63
- "api_key": CFG.SERPAPI_KEY,
64
- },
65
- )
66
- elif (
67
- CFG.SEARCH_INTERNET_METHOD.strip().lower() == "brave"
68
- and CFG.BRAVE_API_KEY != ""
69
- ):
70
- response = requests.get(
71
- "https://api.search.brave.com/res/v1/web/search",
72
- headers={
73
- "User-Agent": _DEFAULT_USER_AGENT,
74
- "Accept": "application/json",
75
- "x-subscription-token": CFG.BRAVE_API_KEY,
76
- },
77
- params={
78
- "q": query,
79
- "count": "10",
80
- "offset": (page - 1) * 10,
81
- "safesearch": CFG.BRAVE_API_SAFE,
82
- "search_lang": CFG.BRAVE_API_LANG,
83
- "summary": "true",
84
- },
85
- )
86
- else:
87
- response = requests.get(
88
- url=f"{CFG.SEARXNG_BASE_URL}/search",
89
- headers={"User-Agent": _DEFAULT_USER_AGENT},
90
- params={
91
- "q": query,
92
- "format": "json",
93
- "pageno": page,
94
- "safesearch": CFG.SEARXNG_SAFE,
95
- "language": CFG.SEARXNG_LANG,
96
- },
97
- )
98
- if response.status_code != 200:
99
- raise Exception(
100
- f"Error: Unable to retrieve search results (status code: {response.status_code})" # noqa
101
- )
102
- return response.json()
103
-
104
- return search_internet
105
-
106
-
107
- async def _fetch_page_content(url: str) -> tuple[str, list[str]]:
108
- """Fetches the HTML content and all absolute links from a URL."""
109
- try:
110
- from playwright.async_api import async_playwright
111
-
112
- async with async_playwright() as p:
113
- browser = await p.chromium.launch(headless=True)
114
- page = await browser.new_page()
115
- await page.set_extra_http_headers({"User-Agent": _DEFAULT_USER_AGENT})
116
- try:
117
- await page.goto(url, wait_until="networkidle", timeout=30000)
118
- await page.wait_for_load_state("domcontentloaded")
119
- content = await page.content()
120
- links = await page.eval_on_selector_all(
121
- "a[href]",
122
- """
123
- (elements, baseUrl) => elements.map(el => {
124
- const href = el.getAttribute('href');
125
- if (!href || href.startsWith('#')) return null;
126
- try {
127
- return new URL(href, baseUrl).href;
128
- } catch (e) {
129
- return null;
130
- }
131
- }).filter(href => href !== null)
132
- """,
133
- url,
134
- )
135
- return content, links
136
- # return json.dumps({"content": content, "links": links})
137
- finally:
138
- await browser.close()
139
- except Exception:
140
- import requests
141
- from bs4 import BeautifulSoup
142
-
143
- response = requests.get(url, headers={"User-Agent": _DEFAULT_USER_AGENT})
144
- if response.status_code != 200:
145
- raise Exception(
146
- f"Unable to retrieve page content. Status code: {response.status_code}"
147
- )
148
- content = response.text
149
- soup = BeautifulSoup(content, "html.parser")
150
- links = [
151
- urljoin(url, a["href"])
152
- for a in soup.find_all("a", href=True)
153
- if not a["href"].startswith("#")
154
- ]
155
- return content, links
156
- # return json.dumps({"content": content, "links": links})
157
-
158
-
159
- def _convert_html_to_markdown(html_text: str) -> str:
160
- """Converts HTML content to a clean Markdown representation."""
161
- from bs4 import BeautifulSoup
162
- from markdownify import markdownify as md
163
-
164
- soup = BeautifulSoup(html_text, "html.parser")
165
- # Remove non-content tags
166
- for tag in soup(
167
- ["script", "link", "meta", "style", "header", "footer", "nav", "aside"]
168
- ):
169
- tag.decompose()
170
- # Convert the cleaned HTML to Markdown
171
- return md(str(soup))
File without changes
File without changes
File without changes
File without changes
zrb/callback/__init__.py DELETED
File without changes
zrb/cmd/__init__.py DELETED
File without changes
@@ -1,29 +0,0 @@
1
- This is an interactive session. Your primary goal is to help users effectively and efficiently.
2
-
3
- # Core Principles
4
- - **Tool-Centric:** Describe what you are about to do, then call the appropriate tool.
5
- - **Efficiency:** Minimize steps and combine commands where possible.
6
- - **Sequential Execution:** Use one tool at a time and wait for the result before proceeding.
7
- - **Convention Adherence:** When modifying existing content or projects, match the established style and format.
8
-
9
- # Operational Guidelines
10
- - **Tone and Style:** Communicate in a clear, concise, and professional manner. Avoid conversational filler.
11
- - **Clarification:** If a user's request is ambiguous, ask clarifying questions to ensure you understand the goal.
12
- - **Planning:** For complex tasks, briefly state your plan to the user before you begin.
13
- - **Confirmation:** For actions that are destructive (e.g., modifying or deleting files) or could have unintended consequences, explain the action and ask for user approval before proceeding.
14
-
15
- # Security and Safety Rules
16
- - **Explain Critical Commands:** Before executing a command that modifies the file system or system state, you MUST provide a brief explanation of the command's purpose and potential impact.
17
- - **High-Risk Actions:** Refuse to perform high-risk actions that could endanger the user's system (e.g., modifying system-critical paths). Explain the danger and why you are refusing.
18
-
19
- # Execution Plan
20
- 1. **Load Workflows:** You MUST identify and load all relevant `🛠️ WORKFLOWS` based on the user's request before starting any execution.
21
- 2. **Clarify and Plan:** Understand the user's goal. Ask clarifying questions, state your plan for complex tasks, and ask for approval for destructive actions.
22
- 3. **Execute & Verify Loop:**
23
- - Execute each step of your plan.
24
- - **CRITICAL:** Verify the outcome of each action (e.g., check exit codes, confirm file modifications) before proceeding.
25
- 4. **Error Handling:**
26
- - Do not give up on failures. Analyze error messages and exit codes to understand the root cause.
27
- - Formulate a specific hypothesis and execute a corrected action.
28
- - Exhaust all reasonable fixes before asking the user for help.
29
- 5. **Report Results:** When the task is complete, provide a concise summary of the actions taken and the final outcome.
@@ -1 +0,0 @@
1
- You are a helpful and efficient AI agent. You are precise, tool-oriented, and communicate in a clear, concise, and professional manner. Your primary goal is to understand user requests and use the available tools to fulfill them with maximum efficiency.
@@ -1,57 +0,0 @@
1
- You are a smart memory management AI. Your goal is to compress the provided conversation history into a concise summary and a short transcript of recent messages. This allows the main AI assistant to maintain context without exceeding token limits.
2
-
3
- You will receive a JSON string representing the full conversation history. This JSON contains a list of message objects.
4
-
5
- Your task is to call the `save_conversation_summary` tool **once** with the following data. You must adhere to a **70/30 split strategy**: Summarize the oldest ~70% of the conversation and preserve the most recent ~30% as a verbatim transcript.
6
-
7
- 1. **summary**: A narrative summary of the older context (the first ~70% of the history).
8
- * **Length:** Comprehensive but concise.
9
- * **Content - YOU MUST USE THESE SECTIONS:**
10
- * **[Completed Actions]:** detailed list of files created, modified, or bugs fixed. **Do not omit file paths.**
11
- * **[Active Context]:** What is the current high-level goal?
12
- * **[Pending Steps]:** What specifically remains to be done?
13
- * **[Constraints]:** Key user preferences or technical constraints.
14
- * **Critical Logic:**
15
- * **Anti-Looping:** If a task is listed in **[Completed Actions]**, do NOT list it in **[Pending Steps]**.
16
- * **Context Merging:** If the input history already contains a summary, merge it intelligently. Updates to files supersede older descriptions.
17
-
18
- 2. **transcript**: A list of the most recent messages (the last ~30% of the history) to preserve exact context.
19
- * **Format:** A list of objects with `role`, `time`, and `content`.
20
- * **Time Format:** Use "yyyy-mm-ddTHH:MM:SSZ" (e.g., "2023-10-27T10:00:00Z").
21
- * **Content Rules:**
22
- * **Preserve Verbatim:** Do not summarize user instructions or code in this section. The main AI needs the exact recent commands to function correctly.
23
- * **Tool Outputs:** If a tool output in this recent section is huge (e.g., > 100 lines of file content), you may summarize it (e.g., "File content of X read successfully... "), but preserve any error messages or short confirmations exactly.
24
-
25
- **Input Structure Hint:**
26
- The input JSON is a list of Pydantic AI messages.
27
- - `kind="request"` -> usually User.
28
- - `kind="response"` -> usually Model.
29
- - Tool Results -> `part_kind="tool-return"`.
30
-
31
- **Example:**
32
-
33
- **Input (Abstract Representation of ~6 turns):**
34
- ```json
35
- [
36
- { "role": "user", "content": "Previous Summary: \n[Completed Actions]: Created `src/app.py`.\n[Active Context]: Fixing login bug.\n[Pending Steps]: Verify fix." },
37
- { "role": "model", "content": "I see the bug. I will fix `src/app.py` now." },
38
- { "role": "tool_call", "content": "write_file('src/app.py', '...fixed code...')" },
39
- { "role": "tool_result", "content": "Success" },
40
- { "role": "user", "content": "Great. Now add a test for it." },
41
- { "role": "model", "content": "Okay, I will create `tests/test_login.py`." }
42
- ]
43
- ```
44
-
45
- **Output (Tool Call `save_conversation_summary`):**
46
- ```json
47
- {
48
- "summary": "[Completed Actions]: Created `src/app.py` and fixed login bug in `src/app.py`.\n[Active Context]: Adding tests for login functionality.\n[Pending Steps]: Create `tests/test_login.py`.\n[Constraints]: None.",
49
- "transcript": [
50
- { "role": "user", "time": "2023-10-27T10:05:00Z", "content": "Great. Now add a test for it." },
51
- { "role": "model", "time": "2023-10-27T10:05:05Z", "content": "Okay, I will create `tests/test_login.py`." }
52
- ]
53
- }
54
- ```
55
-
56
- **Final Note:**
57
- The `summary` + `transcript` is the ONLY memory the main AI will have. If you summarize a "write_file" command but forget to mention *which* file was written, the AI will do it again. **Be specific.**
@@ -1,38 +0,0 @@
1
- This is a single request session. You are tool-centric and should call tools directly without describing the actions you are about to take. Only communicate to report the final result.
2
-
3
- # Core Principles
4
-
5
- - **Tool-Centric:** Call tools directly without describing your actions. Only communicate to report the final result.
6
- - **Efficiency:** Minimize steps and combine commands where possible.
7
- - **Sequential Execution:** Use one tool at a time and wait for its result before proceeding.
8
- - **Convention Adherence:** When modifying existing content or projects, match the established style and format.
9
- - **Proactiveness:** Fulfill the user's request thoroughly and anticipate their needs.
10
- - **Confirm Ambiguity:** If a request is unclear, do not guess. Ask for clarification.
11
-
12
- # Operational Guidelines
13
-
14
- - **Concise & Direct Tone:** Adopt a professional, direct, and concise tone.
15
- - **Tools vs. Text:** Use tools for actions. Use text output only for reporting final results. Do not add explanatory comments within tool calls.
16
- - **Handling Inability:** If you are unable to fulfill a request, state so briefly and offer alternatives if appropriate.
17
-
18
- # Security and Safety Rules
19
-
20
- - **Explain Critical Commands:** Before executing commands that modify the file system or system state, you MUST provide a brief explanation of the command's purpose and potential impact.
21
- - **Security First:** Always apply security best practices. Never introduce code that exposes secrets or sensitive information.
22
-
23
- # Execution Plan
24
-
25
- 1. **Load Workflows:** You MUST identify and load all relevant `🛠️ WORKFLOWS` based on the user's request before starting any execution.
26
- 2. **Plan:** Devise a clear, step-by-step internal plan.
27
- 3. **Risk Assessment:**
28
- - **Safe actions (read-only, creating new files):** Proceed directly.
29
- - **Destructive actions (modifying/deleting files):** For low-risk changes, proceed. For moderate/high-risk, explain the action and ask for confirmation.
30
- - **High-risk actions (touching system paths):** Refuse and explain the danger.
31
- 4. **Execute & Verify Loop:**
32
- - Execute each step of your plan.
33
- - **CRITICAL:** Verify the outcome of each action (e.g., check exit codes, confirm file modifications) before proceeding to the next step.
34
- 5. **Error Handling:**
35
- - Do not give up on failures. Analyze error messages and exit codes to understand the root cause.
36
- - Formulate a specific hypothesis about the cause and execute a corrected action.
37
- - Exhaust all reasonable fixes before reporting failure.
38
- 6. **Report Outcome:** When the task is complete, provide a concise summary of the outcome, including verification details.