|
6 | 6 | from kosong.tooling import CallableTool2, ToolError, ToolOk, ToolReturnValue |
7 | 7 | from pydantic import BaseModel, Field |
8 | 8 |
|
9 | | -from kimi_cli.soul.agent import BuiltinSystemPromptArgs |
| 9 | +from kimi_cli.soul.agent import Runtime |
10 | 10 | from kimi_cli.tools.file.utils import MEDIA_SNIFF_BYTES, FileType, detect_file_type |
11 | | -from kimi_cli.tools.utils import load_desc, truncate_line |
| 11 | +from kimi_cli.tools.utils import load_desc_jinja, truncate_line |
12 | 12 | from kimi_cli.utils.path import is_within_directory |
13 | 13 | from kimi_cli.wire.types import ImageURLPart, VideoURLPart |
14 | 14 |
|
@@ -52,20 +52,22 @@ class Params(BaseModel): |
52 | 52 |
|
53 | 53 | class ReadFile(CallableTool2[Params]): |
54 | 54 | name: str = "ReadFile" |
55 | | - description: str = load_desc( |
56 | | - Path(__file__).parent / "read.md", |
57 | | - { |
58 | | - "MAX_LINES": str(MAX_LINES), |
59 | | - "MAX_LINE_LENGTH": str(MAX_LINE_LENGTH), |
60 | | - "MAX_BYTES": str(MAX_BYTES), |
61 | | - "MAX_MEDIA_BYTES": str(MAX_MEDIA_BYTES), |
62 | | - }, |
63 | | - ) |
64 | 55 | params: type[Params] = Params |
65 | 56 |
|
66 | | - def __init__(self, builtin_args: BuiltinSystemPromptArgs) -> None: |
67 | | - super().__init__() |
68 | | - self._work_dir = builtin_args.KIMI_WORK_DIR |
| 57 | + def __init__(self, runtime: Runtime) -> None: |
| 58 | + capabilities = runtime.llm.capabilities if runtime.llm else set[str]() |
| 59 | + description = load_desc_jinja( |
| 60 | + Path(__file__).parent / "read.md", |
| 61 | + { |
| 62 | + "MAX_LINES": MAX_LINES, |
| 63 | + "MAX_LINE_LENGTH": MAX_LINE_LENGTH, |
| 64 | + "MAX_BYTES": MAX_BYTES, |
| 65 | + "MAX_MEDIA_BYTES": MAX_MEDIA_BYTES, |
| 66 | + "capabilities": capabilities, |
| 67 | + }, |
| 68 | + ) |
| 69 | + super().__init__(description=description) |
| 70 | + self._work_dir = runtime.builtin_args.KIMI_WORK_DIR |
69 | 71 |
|
70 | 72 | async def _validate_path(self, path: KaosPath) -> ToolError | None: |
71 | 73 | """Validate that the path is safe to read.""" |
|
0 commit comments