mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-16 12:50:48 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
|
|
@ -2,21 +2,7 @@
|
|||
name: weather
|
||||
description: Get current weather and forecasts (no API key required).
|
||||
homepage: https://wttr.in/:help
|
||||
metadata:
|
||||
clawdbot:
|
||||
emoji: "🌤️"
|
||||
requires:
|
||||
bins: ["curl"]
|
||||
oclaw:
|
||||
runtime:
|
||||
type: python
|
||||
entry: scripts/run.py
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
location: { type: string, description: "City name (e.g. Shanghai, London)" }
|
||||
format: { type: string, description: "wttr.in format (default: 3)" }
|
||||
additionalProperties: false
|
||||
metadata: {"clawdbot":{"emoji":"🌤️","requires":{"bins":["curl"]}}}
|
||||
---
|
||||
|
||||
# Weather
|
||||
|
|
|
|||
|
|
@ -1,54 +0,0 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import sys
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
|
||||
def _read_stdin_json() -> dict:
|
||||
try:
|
||||
raw = input()
|
||||
except EOFError:
|
||||
raw = ""
|
||||
raw = (raw or "").strip()
|
||||
if not raw:
|
||||
return {}
|
||||
try:
|
||||
obj = json.loads(raw)
|
||||
except Exception:
|
||||
return {}
|
||||
return obj if isinstance(obj, dict) else {}
|
||||
|
||||
|
||||
def main() -> None:
|
||||
# Windows default console encoding may be GBK; force UTF-8 so symbols like ☀ do not crash.
|
||||
try:
|
||||
sys.stdout.reconfigure(encoding="utf-8")
|
||||
except Exception:
|
||||
pass
|
||||
payload = _read_stdin_json()
|
||||
args = payload.get("args") if isinstance(payload.get("args"), dict) else {}
|
||||
location = str(args.get("location") or "Shanghai").strip() or "Shanghai"
|
||||
fmt = str(args.get("format") or "3").strip() or "3"
|
||||
# wttr.in: GET /<location>?format=<fmt>
|
||||
loc_q = urllib.parse.quote(location, safe="")
|
||||
url = f"https://wttr.in/{loc_q}?format={urllib.parse.quote(fmt, safe='')}"
|
||||
req = urllib.request.Request(url, headers={"User-Agent": "oclaw-skill-weather/1.0"})
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=10) as resp:
|
||||
text = resp.read().decode("utf-8", errors="ignore").strip()
|
||||
out = {"ok": True, "location": location, "format": fmt, "text": text}
|
||||
except Exception as exc:
|
||||
out = {"ok": False, "error_code": "fetch_failed", "error": f"{type(exc).__name__}:{exc}"}
|
||||
output = json.dumps(out, ensure_ascii=False)
|
||||
try:
|
||||
print(output)
|
||||
except UnicodeEncodeError:
|
||||
# Last-resort fallback for environments where stdout reconfigure is unavailable.
|
||||
sys.stdout.buffer.write((output + "\n").encode("utf-8", errors="replace"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue