QuickRouter · 人工操作教材 · 非目标产品 UI / 非模型会话日志
Codex skills 教程 · 配置与操作材料
.agents/skills/devices-client/SKILL.md
---
name: devices-client
description: Generate a small client from the local devices OpenAPI spec and prove pagination, 404, and bounded 429 behavior against fixtures.
---
Read openapi.json. Use localhost only. Limit retries to two. Add tests before suggesting external integration.
client.py
import json,time,urllib.request,urllib.error
class DeviceClient:
def __init__(self,base):self.base=base
def get(self,path,retries=2):
for attempt in range(retries+1):
try:
with urllib.request.urlopen(self.base+path,timeout=3) as r:return json.load(r)
except urllib.error.HTTPError as e:
if e.code!=429 or attempt==retries:raise
time.sleep(max(0,float(e.headers.get('Retry-After','0'))))
def all(self):
rows=[];cursor='';seen=set()
while True:
data=self.get('/devices'+('?cursor='+cursor if cursor else ''));rows+=data['items'];cursor=data.get('nextCursor')
if not cursor:return rows
if cursor in seen:raise ValueError('repeated cursor')
seen.add(cursor)