oclaw/runtime/tools/experts/generalist/system_info.py
oliver 420abac9f1 refactor: root-package imports (svc/runtime/interfaces) and fix PYTHONPATH
- Rename platform/ to svc/ to avoid shadowing stdlib platform.
- Replace from oclaw.* with from svc/runtime/interfaces; update -m CLI paths.
- tests/conftest: prepend repo root to sys.path (no parent-folder package name).
- CI: paths and offline_eval script under repo root.
- Ops scripts: PYTHONPATH must be repo root for python -m runtime.* (fixes gateway/WhatsApp sidecar startup).
- Fix default oclaw.json path in tabular/file attachment limits; stabilize attachment test config.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 14:51:17 +08:00

33 lines
1.1 KiB
Python

from __future__ import annotations
import datetime
import time
from typing import Any
from runtime.tools.base import ToolSpec
def system_info_tool() -> ToolSpec:
def handler(args: dict[str, Any]) -> dict[str, Any]:
now = datetime.datetime.now()
utc_now = datetime.datetime.now(datetime.timezone.utc)
timezone_name = time.tzname[0] if time.daylight == 0 else time.tzname[1]
timezone_offset = (now - utc_now.replace(tzinfo=None)).total_seconds() / 3600
return {
"ok": True,
"current_time": now.strftime("%Y-%m-%d %H:%M:%S"),
"timezone": timezone_name,
"timezone_offset": f"UTC{'+' if timezone_offset >= 0 else ''}{timezone_offset:g}",
"timestamp": int(time.time()),
}
return ToolSpec(
name="get_system_time",
description="Return the current local time, timezone name, and UTC offset.",
parameters={"type": "object", "properties": {}, "additionalProperties": False},
handler=handler,
read_only=True,
)
__all__ = ["system_info_tool"]