repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
Mirrored from https://github.com/yingqi-z20/Agent-libOS
stars
latest
clone command
git clone gitlawb://did:key:z6MkqRzA...RfoM/yingqi-z20-Agen...git clone gitlawb://did:key:z6MkqRzA.../yingqi-z20-Agen...d98dd2c9IPC1d ago| #1 | from __future__ import annotations |
| #2 | |
| #3 | from collections.abc import Sequence |
| #4 | from dataclasses import dataclass |
| #5 | from datetime import datetime, tzinfo |
| #6 | from typing import Any, Protocol |
| #7 | |
| #8 | from agent_libos.config import DEFAULT_CONFIG |
| #9 | |
| #10 | _TOOL_DEFAULTS = DEFAULT_CONFIG.tools |
| #11 | |
| #12 | |
| #13 | @dataclass(frozen=True) |
| #14 | class ResolvedPath: |
| #15 | relative: str |
| #16 | display: str |
| #17 | is_root: bool = False |
| #18 | |
| #19 | |
| #20 | @dataclass(frozen=True) |
| #21 | class PathState: |
| #22 | exists: bool |
| #23 | kind: str |
| #24 | size_bytes: int | None = None |
| #25 | modified_at: str | None = None |
| #26 | |
| #27 | |
| #28 | @dataclass(frozen=True) |
| #29 | class DirectoryEntrySnapshot: |
| #30 | name: str |
| #31 | path: str |
| #32 | kind: str |
| #33 | size_bytes: int | None |
| #34 | modified_at: str |
| #35 | |
| #36 | |
| #37 | @dataclass(frozen=True) |
| #38 | class CommandResult: |
| #39 | argv: list[str] |
| #40 | returncode: int |
| #41 | stdout: str |
| #42 | stderr: str |
| #43 | stdout_truncated: bool = False |
| #44 | stderr_truncated: bool = False |
| #45 | |
| #46 | |
| #47 | class FilesystemProvider(Protocol): |
| #48 | namespace: str |
| #49 | root_display: str |
| #50 | |
| #51 | def resolve(self, path: Any) -> ResolvedPath: ... |
| #52 | |
| #53 | def state(self, path: ResolvedPath) -> PathState: ... |
| #54 | |
| #55 | def read_bytes(self, path: ResolvedPath) -> bytes: ... |
| #56 | |
| #57 | def write_text(self, path: ResolvedPath, text: str, encoding: str, newline: str | None = "\n") -> None: ... |
| #58 | |
| #59 | def make_directory(self, path: ResolvedPath, *, parents: bool, exist_ok: bool) -> None: ... |
| #60 | |
| #61 | def list_directory(self, path: ResolvedPath) -> Sequence[DirectoryEntrySnapshot]: ... |
| #62 | |
| #63 | def delete_file(self, path: ResolvedPath) -> None: ... |
| #64 | |
| #65 | def delete_directory(self, path: ResolvedPath, *, recursive: bool) -> None: ... |
| #66 | |
| #67 | |
| #68 | class ClockProvider(Protocol): |
| #69 | def now(self, timezone: tzinfo) -> datetime: ... |
| #70 | |
| #71 | def monotonic(self) -> float: ... |
| #72 | |
| #73 | def sleep(self, seconds: float) -> None: ... |
| #74 | |
| #75 | async def asleep(self, seconds: float) -> None: ... |
| #76 | |
| #77 | |
| #78 | class ShellProvider(Protocol): |
| #79 | def run( |
| #80 | self, |
| #81 | argv: list[str], |
| #82 | *, |
| #83 | timeout: float = _TOOL_DEFAULTS.shell_timeout_s, |
| #84 | cwd: str | None = None, |
| #85 | ) -> CommandResult: ... |
| #86 | |
| #87 | |
| #88 | class HumanProvider(Protocol): |
| #89 | def write(self, message: str) -> None: ... |
| #90 | |
| #91 | def read(self, prompt: str) -> str: ... |
| #92 | |
| #93 | |
| #94 | class ResourceProviderSubstrate(Protocol): |
| #95 | filesystem: FilesystemProvider |
| #96 | clock: ClockProvider |
| #97 | shell: ShellProvider |
| #98 | human: HumanProvider |
| #99 | workspace_display: str |
| #100 |