char-slop/berry

multipurpose self-modifiable agentic harness

git clone https://git.t4t.associates/char-slop/berry

Charlotte Somsubscription: add usage limits for opencode-goaa0b468

main
926 B28 linesraw
1import * as j from "@char/justin";
2
3export const providers = ["anthropic", "openai", "openai-codex", "opencode-go"] as const;
4export type Provider = (typeof providers)[number];
5
6export const providerNames: Record<Provider, string> = {
7  anthropic: "Claude",
8  openai: "ChatGPT / Codex",
9  "openai-codex": "ChatGPT / Codex",
10  "opencode-go": "OpenCode Go",
11};
12
13const window = j.obj({
14  label: j.string,
15  usedPercent: j.number,
16  resetsAt: j.union(j.string, j.null),
17});
18export type UsageWindow = j.Infer<typeof window>;
19
20export const usageSchema = j.union(
21  j.obj({ status: j.literal("ok"), fetchedAt: j.string, windows: j.array(window) }),
22  j.obj({ status: j.union(j.literal("unavailable"), j.literal("error")), message: j.string }),
23);
24export type SubscriptionUsage = j.Infer<typeof usageSchema>;
25
26export function isProvider(value: string): value is Provider {
27  return (providers as readonly string[]).includes(value);
28}