yycode 0.3.2__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.
- agent/__init__.py +33 -0
- agent/acp/__init__.py +2 -0
- agent/acp/approval_adapter.py +134 -0
- agent/acp/content_adapter.py +45 -0
- agent/acp/jsonrpc.py +92 -0
- agent/acp/server.py +197 -0
- agent/acp/session_manager.py +193 -0
- agent/acp/update_adapter.py +192 -0
- agent/app_paths.py +25 -0
- agent/approval.py +169 -0
- agent/cancellation.py +52 -0
- agent/change_snapshot.py +186 -0
- agent/context_compressor.py +116 -0
- agent/graph.py +137 -0
- agent/llm_retry.py +434 -0
- agent/logger.py +97 -0
- agent/lsp/__init__.py +13 -0
- agent/lsp/client.py +151 -0
- agent/lsp/manager.py +234 -0
- agent/lsp/types.py +119 -0
- agent/message_context_manager.py +322 -0
- agent/message_format.py +105 -0
- agent/nodes/llm_node.py +58 -0
- agent/nodes/state.py +12 -0
- agent/nodes/task_guard_node.py +50 -0
- agent/nodes/tools_node.py +70 -0
- agent/plan_snapshot.py +70 -0
- agent/providers/__init__.py +13 -0
- agent/providers/anthropic_provider.py +268 -0
- agent/providers/base.py +52 -0
- agent/providers/openai_provider.py +279 -0
- agent/providers/text_tool_calls.py +118 -0
- agent/runtime/approval_service.py +184 -0
- agent/runtime/context.py +43 -0
- agent/runtime/tool_events.py +368 -0
- agent/runtime/tool_executor.py +208 -0
- agent/runtime/tool_output.py +261 -0
- agent/runtime/tool_registry.py +91 -0
- agent/runtime/tool_scheduler.py +35 -0
- agent/runtime/workflow_guard.py +217 -0
- agent/runtime/workspace.py +5 -0
- agent/runtime/workspace_tools.py +22 -0
- agent/session.py +787 -0
- agent/session_replay.py +95 -0
- agent/session_store.py +186 -0
- agent/skills.py +254 -0
- agent/streaming.py +248 -0
- agent/subagent.py +634 -0
- agent/task_memory.py +340 -0
- agent/todo_manager.py +304 -0
- agent/tool_retry.py +106 -0
- agent/tui/__init__.py +14 -0
- agent/tui/app.py +1325 -0
- agent/tui/approval.py +53 -0
- agent/tui/commands/__init__.py +6 -0
- agent/tui/commands/base.py +48 -0
- agent/tui/commands/clear.py +37 -0
- agent/tui/commands/help.py +27 -0
- agent/tui/commands/registry.py +94 -0
- agent/tui/help_content.py +108 -0
- agent/tui/renderers.py +1961 -0
- agent/tui/runner.py +439 -0
- agent/tui/state.py +653 -0
- main.py +465 -0
- tools/__init__.py +50 -0
- tools/apply_patch.py +305 -0
- tools/bash.py +76 -0
- tools/diff_utils.py +139 -0
- tools/edit_file.py +40 -0
- tools/git_diff.py +72 -0
- tools/git_show.py +65 -0
- tools/grep.py +149 -0
- tools/list_files.py +90 -0
- tools/list_skills.py +24 -0
- tools/load_skill.py +30 -0
- tools/lsp_definition.py +27 -0
- tools/lsp_diagnostics.py +32 -0
- tools/lsp_document_symbols.py +23 -0
- tools/lsp_hover.py +29 -0
- tools/lsp_references.py +37 -0
- tools/lsp_utils.py +38 -0
- tools/lsp_workspace_symbols.py +23 -0
- tools/read_file.py +61 -0
- tools/read_many_files.py +50 -0
- tools/safety.py +50 -0
- tools/subagent.py +57 -0
- tools/todo.py +89 -0
- tools/verify.py +107 -0
- tools/web_search.py +250 -0
- tools/workspace.py +36 -0
- tools/workspace_state.py +60 -0
- tools/write_file.py +88 -0
- utils/__init__.py +5 -0
- utils/retry.py +13 -0
- yycode-0.3.2.data/data/skills/code_review.md +61 -0
- yycode-0.3.2.data/data/skills/code_workflow.md +404 -0
- yycode-0.3.2.data/data/skills/drawio/SKILL.md +636 -0
- yycode-0.3.2.data/data/skills/drawio/agents/openai.yaml +19 -0
- yycode-0.3.2.data/data/skills/drawio/assets/demo-erd.drawio +84 -0
- yycode-0.3.2.data/data/skills/drawio/assets/demo-layered-cn.drawio +91 -0
- yycode-0.3.2.data/data/skills/drawio/assets/demo-layered-cn.png +0 -0
- yycode-0.3.2.data/data/skills/drawio/assets/demo-layered.drawio +112 -0
- yycode-0.3.2.data/data/skills/drawio/assets/demo-layered.png +0 -0
- yycode-0.3.2.data/data/skills/drawio/assets/demo-ml.drawio +90 -0
- yycode-0.3.2.data/data/skills/drawio/assets/demo-ring-cn.drawio +68 -0
- yycode-0.3.2.data/data/skills/drawio/assets/demo-ring-cn.png +0 -0
- yycode-0.3.2.data/data/skills/drawio/assets/demo-ring.drawio +86 -0
- yycode-0.3.2.data/data/skills/drawio/assets/demo-ring.png +0 -0
- yycode-0.3.2.data/data/skills/drawio/assets/demo-sequence.drawio +116 -0
- yycode-0.3.2.data/data/skills/drawio/assets/demo-star-cn.drawio +66 -0
- yycode-0.3.2.data/data/skills/drawio/assets/demo-star-cn.png +0 -0
- yycode-0.3.2.data/data/skills/drawio/assets/demo-star.drawio +79 -0
- yycode-0.3.2.data/data/skills/drawio/assets/demo-star.png +0 -0
- yycode-0.3.2.data/data/skills/drawio/assets/demo-uml-class.drawio +64 -0
- yycode-0.3.2.data/data/skills/drawio/assets/microservices-example.drawio +173 -0
- yycode-0.3.2.data/data/skills/drawio/assets/microservices-example.png +0 -0
- yycode-0.3.2.data/data/skills/drawio/assets/workflow-cn.drawio +120 -0
- yycode-0.3.2.data/data/skills/drawio/assets/workflow-cn.png +0 -0
- yycode-0.3.2.data/data/skills/drawio/assets/workflow.drawio +120 -0
- yycode-0.3.2.data/data/skills/drawio/assets/workflow.png +0 -0
- yycode-0.3.2.data/data/skills/drawio/docs/index.html +469 -0
- yycode-0.3.2.data/data/skills/drawio/docs/zh.html +456 -0
- yycode-0.3.2.data/data/skills/drawio/references/style-extraction.md +254 -0
- yycode-0.3.2.data/data/skills/drawio/styles/schema.json +112 -0
- yycode-0.3.2.data/data/skills/plan.md +115 -0
- yycode-0.3.2.data/data/skills/ppt/SKILL.md +254 -0
- yycode-0.3.2.dist-info/METADATA +12 -0
- yycode-0.3.2.dist-info/RECORD +131 -0
- yycode-0.3.2.dist-info/WHEEL +5 -0
- yycode-0.3.2.dist-info/entry_points.txt +2 -0
- yycode-0.3.2.dist-info/top_level.txt +4 -0
agent/tool_retry.py
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"""Retry utilities for agent tool execution."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import inspect
|
|
5
|
+
import time
|
|
6
|
+
from typing import Callable, TypeVar
|
|
7
|
+
|
|
8
|
+
from agent.llm_retry import LLMCallError
|
|
9
|
+
|
|
10
|
+
T = TypeVar("T")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def run_with_retry(
|
|
14
|
+
func: Callable[..., T],
|
|
15
|
+
max_retries: int = 2,
|
|
16
|
+
retry_delay: float = 0.5,
|
|
17
|
+
backoff_factor: float = 2.0,
|
|
18
|
+
) -> T:
|
|
19
|
+
"""Run a function with automatic retry on failure."""
|
|
20
|
+
retry_count = 0
|
|
21
|
+
|
|
22
|
+
while True:
|
|
23
|
+
try:
|
|
24
|
+
return func()
|
|
25
|
+
except Exception:
|
|
26
|
+
retry_count += 1
|
|
27
|
+
if retry_count > max_retries:
|
|
28
|
+
raise
|
|
29
|
+
delay = retry_delay * (backoff_factor ** (retry_count - 1))
|
|
30
|
+
time.sleep(delay)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def run_tool_with_retry(
|
|
34
|
+
handler: Callable[..., str],
|
|
35
|
+
tool_name: str,
|
|
36
|
+
max_retries: int = 2,
|
|
37
|
+
**kwargs
|
|
38
|
+
) -> str:
|
|
39
|
+
"""Run a synchronous tool handler with retry and error handling."""
|
|
40
|
+
retry_count = 0
|
|
41
|
+
|
|
42
|
+
while retry_count <= max_retries:
|
|
43
|
+
try:
|
|
44
|
+
if not handler:
|
|
45
|
+
return f"Unknown tool: {tool_name}"
|
|
46
|
+
return handler(**kwargs)
|
|
47
|
+
except Exception as e:
|
|
48
|
+
retry_count += 1
|
|
49
|
+
if retry_count > max_retries:
|
|
50
|
+
return f"Error executing tool {tool_name}: {str(e)}"
|
|
51
|
+
time.sleep(0.5 * retry_count)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
async def async_run_tool_with_retry(
|
|
55
|
+
handler: Callable[..., str],
|
|
56
|
+
tool_name: str,
|
|
57
|
+
max_retries: int = 5,
|
|
58
|
+
timeout_seconds: float | None = None,
|
|
59
|
+
**kwargs
|
|
60
|
+
) -> str:
|
|
61
|
+
"""Run a sync or async tool handler with retry and error handling."""
|
|
62
|
+
retry_count = 0
|
|
63
|
+
|
|
64
|
+
# Filter out unexpected keyword arguments that the handler doesn't accept
|
|
65
|
+
if handler:
|
|
66
|
+
sig = inspect.signature(handler)
|
|
67
|
+
accepts_var_kwargs = any(
|
|
68
|
+
param.kind == inspect.Parameter.VAR_KEYWORD
|
|
69
|
+
for param in sig.parameters.values()
|
|
70
|
+
)
|
|
71
|
+
if not accepts_var_kwargs:
|
|
72
|
+
param_names = list(sig.parameters.keys())
|
|
73
|
+
kwargs = {k: v for k, v in kwargs.items() if k in param_names}
|
|
74
|
+
|
|
75
|
+
while retry_count <= max_retries:
|
|
76
|
+
try:
|
|
77
|
+
if not handler:
|
|
78
|
+
return f"Unknown tool: {tool_name}"
|
|
79
|
+
return await _run_once(handler, timeout_seconds, **kwargs)
|
|
80
|
+
except asyncio.TimeoutError:
|
|
81
|
+
retry_count += 1
|
|
82
|
+
if retry_count > max_retries:
|
|
83
|
+
return f"Error executing tool {tool_name}: Timeout after {timeout_seconds}s"
|
|
84
|
+
await asyncio.sleep(0.5 * retry_count)
|
|
85
|
+
except LLMCallError:
|
|
86
|
+
raise
|
|
87
|
+
except Exception as e:
|
|
88
|
+
retry_count += 1
|
|
89
|
+
if retry_count > max_retries:
|
|
90
|
+
return f"Error executing tool {tool_name}: {str(e)}"
|
|
91
|
+
await asyncio.sleep(0.5 * retry_count)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
async def _run_once(handler: Callable[..., str], timeout_seconds: float | None, **kwargs) -> str:
|
|
95
|
+
"""Run a single tool attempt with an optional timeout."""
|
|
96
|
+
async def call_handler():
|
|
97
|
+
if inspect.iscoroutinefunction(handler):
|
|
98
|
+
return await handler(**kwargs)
|
|
99
|
+
result = await asyncio.to_thread(lambda: handler(**kwargs))
|
|
100
|
+
if inspect.isawaitable(result):
|
|
101
|
+
return await result
|
|
102
|
+
return result
|
|
103
|
+
|
|
104
|
+
if timeout_seconds is None:
|
|
105
|
+
return await call_handler()
|
|
106
|
+
return await asyncio.wait_for(call_handler(), timeout=timeout_seconds)
|
agent/tui/__init__.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Terminal UI support for yoyoagent."""
|
|
2
|
+
|
|
3
|
+
from .approval import TuiApprovalAdapter
|
|
4
|
+
from .runner import AgentTuiRunner
|
|
5
|
+
from .state import PendingApproval, SubagentStatus, TimelineItem, TuiState
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"AgentTuiRunner",
|
|
9
|
+
"PendingApproval",
|
|
10
|
+
"SubagentStatus",
|
|
11
|
+
"TimelineItem",
|
|
12
|
+
"TuiApprovalAdapter",
|
|
13
|
+
"TuiState",
|
|
14
|
+
]
|