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 dataclasses import dataclass, field |
| #4 | from typing import Literal |
| #5 | |
| #6 | ShellPolicyLevel = Literal[ |
| #7 | "always_deny", |
| #8 | "allowlist_auto_else_ask", |
| #9 | "blocklist_ask_else_auto", |
| #10 | "always_allow", |
| #11 | ] |
| #12 | |
| #13 | |
| #14 | @dataclass(frozen=True) |
| #15 | class ShellCommandRule: |
| #16 | argv: tuple[str, ...] |
| #17 | match: Literal["exact", "prefix"] = "exact" |
| #18 | description: str = "" |
| #19 | |
| #20 | |
| #21 | @dataclass(frozen=True) |
| #22 | class RuntimeDefaults: |
| #23 | local_store_target: str = "local" |
| #24 | runtime_db_filename: str = ".agent_libos.sqlite" |
| #25 | workspace_namespace: str = "workspace" |
| #26 | default_image_id: str = "base-agent:v0" |
| #27 | coding_image_id: str = "coding-agent:v0" |
| #28 | default_human: str = "owner" |
| #29 | terminal_channel: str = "terminal" |
| #30 | run_until_idle_max_quanta: int = 25 |
| #31 | launcher_max_quanta: int = 40 |
| #32 | |
| #33 | @property |
| #34 | def default_human_resource(self) -> str: |
| #35 | return f"human:{self.default_human}" |
| #36 | |
| #37 | @property |
| #38 | def default_human_actor(self) -> str: |
| #39 | return f"human:{self.default_human}" |
| #40 | |
| #41 | |
| #42 | @dataclass(frozen=True) |
| #43 | class SchedulerDefaults: |
| #44 | max_quanta: int = 25 |
| #45 | poll_interval_s: float = 0.01 |
| #46 | |
| #47 | |
| #48 | @dataclass(frozen=True) |
| #49 | class ProcessDefaults: |
| #50 | max_tool_calls: int = 256 |
| #51 | max_child_processes: int = 16 |
| #52 | max_runtime_seconds: int | None = None |
| #53 | max_materialized_tokens: int = 65_536 |
| #54 | default_goal_text: str = "Run agent process" |
| #55 | default_working_directory: str = "." |
| #56 | fork_budget_divisor: int = 2 |
| #57 | fork_min_tool_calls: int = 1 |
| #58 | fork_min_child_processes: int = 0 |
| #59 | |
| #60 | |
| #61 | @dataclass(frozen=True) |
| #62 | class LLMDefaults: |
| #63 | temperature: float = 0.2 |
| #64 | max_tokens: int = 65_536 |
| #65 | timeout_s: float = 60.0 |
| #66 | max_retries: int = 2 |
| #67 | api_mode: Literal["auto", "responses", "chat"] = "auto" |
| #68 | store: bool = False |
| #69 | compatibility_retry_attempts: int = 8 |
| #70 | action_repair_attempts: int = 2 |
| #71 | content_preview_chars: int = 500 |
| #72 | tool_arguments_preview_chars: int = 500 |
| #73 | json_instruction: str = "You must respond with a valid JSON object." |
| #74 | fallback_status_codes: tuple[int, ...] = (404, 405) |
| #75 | |
| #76 | |
| #77 | @dataclass(frozen=True) |
| #78 | class ToolDefaults: |
| #79 | version: str = "1.0.0" |
| #80 | default_timeout_s: float = 30.0 |
| #81 | standard_timeout_s: float = 5.0 |
| #82 | interactive_timeout_s: float = 2.0 |
| #83 | default_text_encoding: str = "utf-8" |
| #84 | filesystem_read_max_bytes: int = 65_536 |
| #85 | filesystem_read_hard_limit_bytes: int = 1_048_576 |
| #86 | directory_entry_limit: int = 1_024 |
| #87 | directory_entry_hard_limit: int = 10_000 |
| #88 | memory_payload_chars: int = 12_000 |
| #89 | memory_payload_hard_limit_chars: int = 200_000 |
| #90 | object_file_max_bytes: int = 1_048_576 |
| #91 | object_file_hard_limit_bytes: int = 10_485_760 |
| #92 | shell_timeout_s: float = 30.0 |
| #93 | sandbox_timeout_s: float = 5.0 |
| #94 | deno_executable: str = "deno" |
| #95 | deno_timeout_s: float = 5.0 |
| #96 | deno_max_rpc_calls: int = 64 |
| #97 | deno_max_stdout_bytes: int = 1_000_000 |
| #98 | deno_max_stderr_bytes: int = 100_000 |
| #99 | deno_jsr_allowlist: tuple[str, ...] = ( |
| #100 | "@std/assert", |
| #101 | "@std/collections", |
| #102 | "@std/encoding", |
| #103 | "@std/path", |
| #104 | "@std/yaml", |
| #105 | ) |
| #106 | static_tool_id_digest_chars: int = 16 |
| #107 | approval_preview_chars: int = 256 |
| #108 | clock_timezone: str = "UTC" |
| #109 | max_sleep_seconds: float = 60.0 |
| #110 | sleep_timeout_grace_s: float = 5.0 |
| #111 | |
| #112 | @property |
| #113 | def sleep_tool_timeout_s(self) -> float: |
| #114 | return self.max_sleep_seconds + self.sleep_timeout_grace_s |
| #115 | |
| #116 | |
| #117 | @dataclass(frozen=True) |
| #118 | class ShellDefaults: |
| #119 | policy_capability_key: str = "shell_policy_level" |
| #120 | policy_resource: str = "shell:*" |
| #121 | default_policy_level: ShellPolicyLevel = "allowlist_auto_else_ask" |
| #122 | always_deny_level: ShellPolicyLevel = "always_deny" |
| #123 | allowlist_auto_else_ask_level: ShellPolicyLevel = "allowlist_auto_else_ask" |
| #124 | blocklist_ask_else_auto_level: ShellPolicyLevel = "blocklist_ask_else_auto" |
| #125 | always_allow_level: ShellPolicyLevel = "always_allow" |
| #126 | high_risk_level: ShellPolicyLevel = "always_allow" |
| #127 | timeout_hard_limit_s: float = 300.0 |
| #128 | max_stdout_chars: int = 32_000 |
| #129 | max_stderr_chars: int = 32_000 |
| #130 | stdout_hard_limit_chars: int = 200_000 |
| #131 | stderr_hard_limit_chars: int = 200_000 |
| #132 | whitelist: tuple[ShellCommandRule, ...] = ( |
| #133 | ShellCommandRule(("git", "status")), |
| #134 | ShellCommandRule(("git", "status", "--short")), |
| #135 | ShellCommandRule(("git", "branch", "--show-current")), |
| #136 | ShellCommandRule(("git", "rev-parse", "--show-toplevel")), |
| #137 | ShellCommandRule(("git", "diff", "--stat")), |
| #138 | ShellCommandRule(("python", "--version")), |
| #139 | ShellCommandRule(("python3", "--version")), |
| #140 | ShellCommandRule(("uv", "--version")), |
| #141 | ) |
| #142 | blacklist: tuple[ShellCommandRule, ...] = ( |
| #143 | ShellCommandRule(("cmd",), match="prefix"), |
| #144 | ShellCommandRule(("powershell",), match="prefix"), |
| #145 | ShellCommandRule(("pwsh",), match="prefix"), |
| #146 | ShellCommandRule(("sh",), match="prefix"), |
| #147 | ShellCommandRule(("bash",), match="prefix"), |
| #148 | ShellCommandRule(("zsh",), match="prefix"), |
| #149 | ShellCommandRule(("fish",), match="prefix"), |
| #150 | ShellCommandRule(("python",), match="prefix"), |
| #151 | ShellCommandRule(("python3",), match="prefix"), |
| #152 | ShellCommandRule(("py",), match="prefix"), |
| #153 | ShellCommandRule(("node",), match="prefix"), |
| #154 | ShellCommandRule(("npm",), match="prefix"), |
| #155 | ShellCommandRule(("npx",), match="prefix"), |
| #156 | ShellCommandRule(("yarn",), match="prefix"), |
| #157 | ShellCommandRule(("pnpm",), match="prefix"), |
| #158 | ShellCommandRule(("uv",), match="prefix"), |
| #159 | ShellCommandRule(("pip",), match="prefix"), |
| #160 | ShellCommandRule(("pip3",), match="prefix"), |
| #161 | ShellCommandRule(("ruby",), match="prefix"), |
| #162 | ShellCommandRule(("perl",), match="prefix"), |
| #163 | ShellCommandRule(("php",), match="prefix"), |
| #164 | ShellCommandRule(("java",), match="prefix"), |
| #165 | ShellCommandRule(("cargo",), match="prefix"), |
| #166 | ShellCommandRule(("docker",), match="prefix"), |
| #167 | ShellCommandRule(("kubectl",), match="prefix"), |
| #168 | ShellCommandRule(("ssh",), match="prefix"), |
| #169 | ShellCommandRule(("scp",), match="prefix"), |
| #170 | ShellCommandRule(("sftp",), match="prefix"), |
| #171 | ShellCommandRule(("curl",), match="prefix"), |
| #172 | ShellCommandRule(("wget",), match="prefix"), |
| #173 | ShellCommandRule(("nc",), match="prefix"), |
| #174 | ShellCommandRule(("ncat",), match="prefix"), |
| #175 | ShellCommandRule(("netcat",), match="prefix"), |
| #176 | ShellCommandRule(("rm",), match="prefix"), |
| #177 | ShellCommandRule(("del",), match="prefix"), |
| #178 | ShellCommandRule(("rmdir",), match="prefix"), |
| #179 | ShellCommandRule(("remove-item",), match="prefix"), |
| #180 | ShellCommandRule(("move-item",), match="prefix"), |
| #181 | ShellCommandRule(("copy-item",), match="prefix"), |
| #182 | ShellCommandRule(("chmod",), match="prefix"), |
| #183 | ShellCommandRule(("chown",), match="prefix"), |
| #184 | ShellCommandRule(("icacls",), match="prefix"), |
| #185 | ShellCommandRule(("reg",), match="prefix"), |
| #186 | ShellCommandRule(("regedit",), match="prefix"), |
| #187 | ShellCommandRule(("taskkill",), match="prefix"), |
| #188 | ShellCommandRule(("sudo",), match="prefix"), |
| #189 | ShellCommandRule(("su",), match="prefix"), |
| #190 | ShellCommandRule(("runas",), match="prefix"), |
| #191 | ) |
| #192 | |
| #193 | |
| #194 | @dataclass(frozen=True) |
| #195 | class ImageDefaults: |
| #196 | registry_resource: str = "image:*" |
| #197 | id_max_chars: int = 128 |
| #198 | name_max_chars: int = 128 |
| #199 | version_max_chars: int = 64 |
| #200 | max_default_tools: int = 128 |
| #201 | max_required_capabilities: int = 64 |
| #202 | yaml_max_bytes: int = 262_144 |
| #203 | yaml_hard_limit_bytes: int = 1_048_576 |
| #204 | |
| #205 | |
| #206 | @dataclass(frozen=True) |
| #207 | class ObjectMemoryDefaults: |
| #208 | object_schema_version: str = "1" |
| #209 | materialize_budget_tokens: int = 8_000 |
| #210 | query_limit: int = 50 |
| #211 | context_policy: str = "plan_first" |
| #212 | metadata_sensitivity: str = "normal" |
| #213 | metadata_retention_policy: str = "default" |
| #214 | process_namespace_prefix: str = "process" |
| #215 | |
| #216 | |
| #217 | @dataclass(frozen=True) |
| #218 | class LLMContextDefaults: |
| #219 | policy: str = "llm_context_object" |
| #220 | schema_version: int = 1 |
| #221 | object_name_prefix: str = "llm_context" |
| #222 | recent_event_limit: int = 20 |
| #223 | |
| #224 | |
| #225 | @dataclass(frozen=True) |
| #226 | class LauncherDefaults: |
| #227 | permission_presets: tuple[str, ...] = ("read-only", "edit", "full") |
| #228 | default_permission_preset: str = "edit" |
| #229 | read_only_preset: str = "read-only" |
| #230 | edit_preset: str = "edit" |
| #231 | full_preset: str = "full" |
| #232 | |
| #233 | |
| #234 | @dataclass(frozen=True) |
| #235 | class ScriptDefaults: |
| #236 | ask_file_max_bytes: int = 65_536 |
| #237 | ask_file_max_quanta: int = 6 |
| #238 | document_summary_max_bytes: int = 65_536 |
| #239 | document_summary_max_read_bytes: int = 1_048_576 |
| #240 | document_summary_max_quanta: int = 10 |
| #241 | document_context_min_tokens: int = 8_000 |
| #242 | document_context_slack_tokens: int = 12_000 |
| #243 | document_context_max_tokens: int = 120_000 |
| #244 | object_copy_max_quanta: int = 5 |
| #245 | llm_write_smoke_max_quanta: int = 5 |
| #246 | clock_demo_iterations: int = 3 |
| #247 | clock_demo_interval_s: float = 0.2 |
| #248 | clock_demo_timezone: str = "Asia/Shanghai" |
| #249 | chat_max_turns: int = 20 |
| #250 | chat_context_tokens: int = 64_000 |
| #251 | chat_quanta_per_turn: int = 5 |
| #252 | chat_quanta_overhead: int = 8 |
| #253 | |
| #254 | |
| #255 | @dataclass(frozen=True) |
| #256 | class AgentLibOSConfig: |
| #257 | runtime: RuntimeDefaults = field(default_factory=RuntimeDefaults) |
| #258 | scheduler: SchedulerDefaults = field(default_factory=SchedulerDefaults) |
| #259 | process: ProcessDefaults = field(default_factory=ProcessDefaults) |
| #260 | llm: LLMDefaults = field(default_factory=LLMDefaults) |
| #261 | tools: ToolDefaults = field(default_factory=ToolDefaults) |
| #262 | shell: ShellDefaults = field(default_factory=ShellDefaults) |
| #263 | image: ImageDefaults = field(default_factory=ImageDefaults) |
| #264 | memory: ObjectMemoryDefaults = field(default_factory=ObjectMemoryDefaults) |
| #265 | llm_context: LLMContextDefaults = field(default_factory=LLMContextDefaults) |
| #266 | launcher: LauncherDefaults = field(default_factory=LauncherDefaults) |
| #267 | scripts: ScriptDefaults = field(default_factory=ScriptDefaults) |
| #268 | |
| #269 | |
| #270 | DEFAULT_CONFIG = AgentLibOSConfig() |
| #271 |