Repository navigation
Expand file tree
/
Copy pathtask_get.py
More file actions
63 lines (48 loc) · 1.89 KB
/
Copy pathtask_get.py
File metadata and controls
63 lines (48 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# 来源:公众号@小林coding
# 后端八股网站:xiaolincoding.com
# Agent网站:xiaolinnote.com
# 简历模版:jianli.xiaolinnote.com
from __future__ import annotations
from typing import TYPE_CHECKING
from pydantic import BaseModel
from kkcode.tools.base import Tool, ToolResult
if TYPE_CHECKING:
from kkcode.teams.manager import TeamManager
class TaskGetParams(BaseModel):
task_id: str
class TaskGetTool(Tool):
name = "TaskGet"
description = (
"Get details of a shared task by ID, including dependency information."
)
params_model = TaskGetParams
category = "read"
is_concurrency_safe = True
def __init__(self, team_manager: TeamManager, team_name: str) -> None:
self._team_manager = team_manager
self._team_name = team_name
async def execute(self, params: BaseModel) -> ToolResult:
p: TaskGetParams = params # type: ignore[assignment]
store = self._team_manager.get_task_store(self._team_name)
if store is None:
return ToolResult(
output=f"Task store not found for team '{self._team_name}'",
is_error=True,
)
task = store.get(p.task_id)
if task is None:
return ToolResult(output=f"Task '{p.task_id}' not found", is_error=True)
lines = [
f"Task {task.id}:",
f" Title: {task.title}",
f" Status: {task.status}",
f" Assignee: {task.assignee or '(unassigned)'}",
f" Created by: {task.created_by or '(unknown)'}",
]
if task.description:
lines.append(f" Description: {task.description}")
if task.blocks:
lines.append(f" Blocks: {', '.join(task.blocks)}")
if task.blocked_by:
lines.append(f" Blocked by: {', '.join(task.blocked_by)}")
return ToolResult(output="\n".join(lines))