Show HN:Pocketty——当 Agent 被阻塞时会通知你的 iPhone SSH 终端
英文标题:🔶 Show HN: Pocketty – iPhone SSH terminal that pings you when an agent is blocked
Pocketty 是一款面向 iPhone 的 SSH 终端,主打在 AI Agent 执行受阻时向用户发送提醒。该项目在 Hacker News 上获得 28 分和 15 条评论。附带的代码变更将速率限制重试时间统一抽取为 `RETRY_AFTER` 常量,当前设为 60 秒,并同时用于授权与推送请求的限流响应,便于开发者集中维护限流策略。
34.0 KB
15.1 KB
67.8 KB
32.1 KB
77.1 KB
38.2 KB
80.0 KB
39.7 KB
29.2 KB
12.9 KB
135.6 KB
65.6 KB
131.4 KB
63.8 KB
134.2 KB
63.8 KB
190.1 KB
中文
13 13 pub const MAX_BODY: usize = 16 * 1024;
14 14 const APNS_TOKEN_LIFETIME: u64 = 40 * 60;
15 15 const FCM_TOKEN_MARGIN: u64 = 5 * 60;
16 + pub const RETRY_AFTER: u32 = 60;
16 17 const NO_PLATFORM: &str = "platform is not configured on this relay";
17 18 const NO_ENV: &str = "environment is not configured on this relay";
18 19 ``
46 47 ``
47 48 pub async fn grant(&self, body: &[u8], client: &str, now: u64) -> Reply {
48 49 if ! self.runtime.allow(Bucket::Grants, client).await {
49 - return error(429, "rate limited").with_retry(60);
50 + return error(429, "rate limited").with_retry(RETRY_AFTER);
50 51 }
51 52 let Ok(request) = serde_json::from_slice::<GrantRequest>(bod y) else {
52 53 return error(400, "malformed grant request");
79 80 }
80 81 };
81 82 if ! self.runtime.allow(Bucket::Push, &bucket_key(&claims)).await {
82 - return push_reply(&PushResponse::RateLimited { retry_after: 60 });
83 + return push_reply(&PushResponse::RateLimited { retry_after: RETRY_AFTER });
English / 原文
13 13 pub const MAX_BODY: usize = 16 * 1024;
14 14 const APNS_TOKEN_LIFETIME: u64 = 40 * 60;
15 15 const FCM_TOKEN_MARGIN: u64 = 5 * 60;
16 + pub const RETRY_AFTER: u32 = 60;
16 17 const NO_PLATFORM: &str = "platform is not configured on this relay";
17 18 const NO_ENV: &str = "environment is not configured on this relay";
18 19 ``
46 47 ``
47 48 pub async fn grant(&self, body: &[u8], client: &str, now: u64) -> Reply {
48 49 if ! self.runtime.allow(Bucket::Grants, client).await {
49 - return error(429, "rate limited").with_retry(60);
50 + return error(429, "rate limited").with_retry(RETRY_AFTER);
50 51 }
51 52 let Ok(request) = serde_json::from_slice::<GrantRequest>(bod y) else {
52 53 return error(400, "malformed grant request");
79 80 }
80 81 };
81 82 if ! self.runtime.allow(Bucket::Push, &bucket_key(&claims)).await {
82 - return push_reply(&PushResponse::RateLimited { retry_after: 60 });
83 + return push_reply(&PushResponse::RateLimited { retry_after: RETRY_AFTER });