feat: add quota tracking

This commit is contained in:
2026-09-12 09:51:04 +02:00
parent 4ea9b4a695
commit 411cdd13ff
13 changed files with 1269 additions and 16 deletions
+25
View File
@@ -0,0 +1,25 @@
import { Rpc } from "@opencode/plugin/rpc";
import { z } from "zod";
const window = z.object({
id: z.string(),
label: z.string().nullable(),
seconds: z.number(),
used: z.number(),
resetsAt: z.number(),
remaining: z.number(),
sessionConsumed: z.number(),
});
export const QuotaRpc = Rpc.define({
id: "stanp-opencode.quota",
methods: {
status: {
input: z.object({ sessionID: z.string() }),
output: z
.object({ plan: z.string(), fetchedAt: z.number(), windows: z.array(window) })
.nullable(),
},
},
events: { updated: { schema: z.object({}) } },
});