@opencode/schema 0.0.0-dev-21775 → 0.0.0-dev-21776
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/usage-limits.d.ts +227 -0
- package/dist/usage-limits.js +59 -0
- package/package.json +1 -1
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
export * as UsageLimits from "./usage-limits.js";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
/** One window of the OpenCode Go allowance. */
|
|
4
|
+
export interface Meter extends Schema.Schema.Type<typeof Meter> {
|
|
5
|
+
}
|
|
6
|
+
export declare const Meter: Schema.Struct<{
|
|
7
|
+
/** How much of the window's allowance is used. */
|
|
8
|
+
readonly percent: Schema.Finite;
|
|
9
|
+
/** Go refuses requests until the window resets. */
|
|
10
|
+
readonly limited: Schema.Boolean;
|
|
11
|
+
readonly resetsAt: Schema.Finite;
|
|
12
|
+
}>;
|
|
13
|
+
/** The OpenCode Go allowance of a workspace the member subscribes to Go in. */
|
|
14
|
+
export interface Go extends Schema.Schema.Type<typeof Go> {
|
|
15
|
+
}
|
|
16
|
+
export declare const Go: Schema.Struct<{
|
|
17
|
+
readonly rolling: Schema.Struct<{
|
|
18
|
+
/** How much of the window's allowance is used. */
|
|
19
|
+
readonly percent: Schema.Finite;
|
|
20
|
+
/** Go refuses requests until the window resets. */
|
|
21
|
+
readonly limited: Schema.Boolean;
|
|
22
|
+
readonly resetsAt: Schema.Finite;
|
|
23
|
+
}>;
|
|
24
|
+
readonly weekly: Schema.Struct<{
|
|
25
|
+
/** How much of the window's allowance is used. */
|
|
26
|
+
readonly percent: Schema.Finite;
|
|
27
|
+
/** Go refuses requests until the window resets. */
|
|
28
|
+
readonly limited: Schema.Boolean;
|
|
29
|
+
readonly resetsAt: Schema.Finite;
|
|
30
|
+
}>;
|
|
31
|
+
readonly monthly: Schema.Struct<{
|
|
32
|
+
/** How much of the window's allowance is used. */
|
|
33
|
+
readonly percent: Schema.Finite;
|
|
34
|
+
/** Go refuses requests until the window resets. */
|
|
35
|
+
readonly limited: Schema.Boolean;
|
|
36
|
+
readonly resetsAt: Schema.Finite;
|
|
37
|
+
}>;
|
|
38
|
+
}>;
|
|
39
|
+
/** A model a budget covers, by the IDs OpenCode knows it by. */
|
|
40
|
+
export interface BudgetModel extends Schema.Schema.Type<typeof BudgetModel> {
|
|
41
|
+
}
|
|
42
|
+
export declare const BudgetModel: Schema.Struct<{
|
|
43
|
+
readonly providerID: Schema.brand<Schema.String, "Provider.ID"> & {
|
|
44
|
+
opencode: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
45
|
+
anthropic: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
46
|
+
openai: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
47
|
+
google: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
48
|
+
googleVertex: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
49
|
+
githubCopilot: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
50
|
+
amazonBedrock: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
51
|
+
azure: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
52
|
+
openrouter: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
53
|
+
mistral: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
54
|
+
gitlab: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
55
|
+
};
|
|
56
|
+
readonly modelID: Schema.brand<Schema.String, "Model.ID">;
|
|
57
|
+
readonly name: Schema.String;
|
|
58
|
+
/** What a per-model budget's member has spent on this model this month. */
|
|
59
|
+
readonly spent: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.Finite, "Money.USD"> & {
|
|
60
|
+
zero: number & import("effect/Brand").Brand<"Money.USD">;
|
|
61
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.Finite, "Money.USD"> & {
|
|
62
|
+
zero: number & import("effect/Brand").Brand<"Money.USD">;
|
|
63
|
+
}>, never, never>;
|
|
64
|
+
}>;
|
|
65
|
+
/** A monthly spend limit the OpenCode Console workspace sets on the member. */
|
|
66
|
+
export interface Budget extends Schema.Schema.Type<typeof Budget> {
|
|
67
|
+
}
|
|
68
|
+
export declare const Budget: Schema.Struct<{
|
|
69
|
+
readonly id: Schema.String;
|
|
70
|
+
readonly limit: Schema.brand<Schema.Finite, "Money.USD"> & {
|
|
71
|
+
zero: number & import("effect/Brand").Brand<"Money.USD">;
|
|
72
|
+
};
|
|
73
|
+
/** The member's spend this month, or the pooled spend of a combined budget; per model, the most on one model. */
|
|
74
|
+
readonly spent: Schema.brand<Schema.Finite, "Money.USD"> & {
|
|
75
|
+
zero: number & import("effect/Brand").Brand<"Money.USD">;
|
|
76
|
+
};
|
|
77
|
+
/** `each` limits every member separately; `combined` pools everyone's spend against one limit. */
|
|
78
|
+
readonly scope: Schema.Literals<readonly ["each", "combined"]>;
|
|
79
|
+
/** `set` counts spend across the budget's models; `model` limits each model separately. */
|
|
80
|
+
readonly per: Schema.Literals<readonly ["set", "model"]>;
|
|
81
|
+
/** `all` covers every model and billable service; `models` covers only `models`. */
|
|
82
|
+
readonly coverage: Schema.Literals<readonly ["all", "models"]>;
|
|
83
|
+
readonly models: Schema.$Array<Schema.Struct<{
|
|
84
|
+
readonly providerID: Schema.brand<Schema.String, "Provider.ID"> & {
|
|
85
|
+
opencode: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
86
|
+
anthropic: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
87
|
+
openai: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
88
|
+
google: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
89
|
+
googleVertex: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
90
|
+
githubCopilot: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
91
|
+
amazonBedrock: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
92
|
+
azure: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
93
|
+
openrouter: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
94
|
+
mistral: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
95
|
+
gitlab: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
96
|
+
};
|
|
97
|
+
readonly modelID: Schema.brand<Schema.String, "Model.ID">;
|
|
98
|
+
readonly name: Schema.String;
|
|
99
|
+
/** What a per-model budget's member has spent on this model this month. */
|
|
100
|
+
readonly spent: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.Finite, "Money.USD"> & {
|
|
101
|
+
zero: number & import("effect/Brand").Brand<"Money.USD">;
|
|
102
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.Finite, "Money.USD"> & {
|
|
103
|
+
zero: number & import("effect/Brand").Brand<"Money.USD">;
|
|
104
|
+
}>, never, never>;
|
|
105
|
+
}>>;
|
|
106
|
+
/** The vendors whose models the budget counts, by name; empty when it doesn't count by vendor. */
|
|
107
|
+
readonly vendors: Schema.$Array<Schema.String>;
|
|
108
|
+
/** The input price per 1M tokens from which the budget counts a model, when it sets one. */
|
|
109
|
+
readonly inputPriceAtLeast: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.Finite, "Money.USDPerMillionTokens"> & {
|
|
110
|
+
zero: number & import("effect/Brand").Brand<"Money.USDPerMillionTokens">;
|
|
111
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.Finite, "Money.USDPerMillionTokens"> & {
|
|
112
|
+
zero: number & import("effect/Brand").Brand<"Money.USDPerMillionTokens">;
|
|
113
|
+
}>, never, never>;
|
|
114
|
+
/** The budget counts models picked one by one, rather than by vendor or price. */
|
|
115
|
+
readonly picked: Schema.Boolean;
|
|
116
|
+
/** Everyone in the workspace pools spend against it, so reaching it pauses model use for all of them. */
|
|
117
|
+
readonly shared: Schema.Boolean;
|
|
118
|
+
readonly resetsAt: Schema.Finite;
|
|
119
|
+
}>;
|
|
120
|
+
/** The usage limits of the OpenCode Console workspace a location is signed in to. */
|
|
121
|
+
export interface Info extends Schema.Schema.Type<typeof Info> {
|
|
122
|
+
}
|
|
123
|
+
export declare const Info: Schema.Struct<{
|
|
124
|
+
readonly workspace: Schema.Struct<{
|
|
125
|
+
readonly id: Schema.String;
|
|
126
|
+
readonly name: Schema.decodeTo<Schema.optional<Schema.toType<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
|
|
127
|
+
/** The member's usage page in OpenCode Console. */
|
|
128
|
+
readonly usageURL: Schema.String;
|
|
129
|
+
}>;
|
|
130
|
+
readonly go: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Struct<{
|
|
131
|
+
readonly rolling: Schema.Struct<{
|
|
132
|
+
/** How much of the window's allowance is used. */
|
|
133
|
+
readonly percent: Schema.Finite;
|
|
134
|
+
/** Go refuses requests until the window resets. */
|
|
135
|
+
readonly limited: Schema.Boolean;
|
|
136
|
+
readonly resetsAt: Schema.Finite;
|
|
137
|
+
}>;
|
|
138
|
+
readonly weekly: Schema.Struct<{
|
|
139
|
+
/** How much of the window's allowance is used. */
|
|
140
|
+
readonly percent: Schema.Finite;
|
|
141
|
+
/** Go refuses requests until the window resets. */
|
|
142
|
+
readonly limited: Schema.Boolean;
|
|
143
|
+
readonly resetsAt: Schema.Finite;
|
|
144
|
+
}>;
|
|
145
|
+
readonly monthly: Schema.Struct<{
|
|
146
|
+
/** How much of the window's allowance is used. */
|
|
147
|
+
readonly percent: Schema.Finite;
|
|
148
|
+
/** Go refuses requests until the window resets. */
|
|
149
|
+
readonly limited: Schema.Boolean;
|
|
150
|
+
readonly resetsAt: Schema.Finite;
|
|
151
|
+
}>;
|
|
152
|
+
}>>>, Schema.optionalKey<Schema.Struct<{
|
|
153
|
+
readonly rolling: Schema.Struct<{
|
|
154
|
+
/** How much of the window's allowance is used. */
|
|
155
|
+
readonly percent: Schema.Finite;
|
|
156
|
+
/** Go refuses requests until the window resets. */
|
|
157
|
+
readonly limited: Schema.Boolean;
|
|
158
|
+
readonly resetsAt: Schema.Finite;
|
|
159
|
+
}>;
|
|
160
|
+
readonly weekly: Schema.Struct<{
|
|
161
|
+
/** How much of the window's allowance is used. */
|
|
162
|
+
readonly percent: Schema.Finite;
|
|
163
|
+
/** Go refuses requests until the window resets. */
|
|
164
|
+
readonly limited: Schema.Boolean;
|
|
165
|
+
readonly resetsAt: Schema.Finite;
|
|
166
|
+
}>;
|
|
167
|
+
readonly monthly: Schema.Struct<{
|
|
168
|
+
/** How much of the window's allowance is used. */
|
|
169
|
+
readonly percent: Schema.Finite;
|
|
170
|
+
/** Go refuses requests until the window resets. */
|
|
171
|
+
readonly limited: Schema.Boolean;
|
|
172
|
+
readonly resetsAt: Schema.Finite;
|
|
173
|
+
}>;
|
|
174
|
+
}>>, never, never>;
|
|
175
|
+
readonly budgets: Schema.$Array<Schema.Struct<{
|
|
176
|
+
readonly id: Schema.String;
|
|
177
|
+
readonly limit: Schema.brand<Schema.Finite, "Money.USD"> & {
|
|
178
|
+
zero: number & import("effect/Brand").Brand<"Money.USD">;
|
|
179
|
+
};
|
|
180
|
+
/** The member's spend this month, or the pooled spend of a combined budget; per model, the most on one model. */
|
|
181
|
+
readonly spent: Schema.brand<Schema.Finite, "Money.USD"> & {
|
|
182
|
+
zero: number & import("effect/Brand").Brand<"Money.USD">;
|
|
183
|
+
};
|
|
184
|
+
/** `each` limits every member separately; `combined` pools everyone's spend against one limit. */
|
|
185
|
+
readonly scope: Schema.Literals<readonly ["each", "combined"]>;
|
|
186
|
+
/** `set` counts spend across the budget's models; `model` limits each model separately. */
|
|
187
|
+
readonly per: Schema.Literals<readonly ["set", "model"]>;
|
|
188
|
+
/** `all` covers every model and billable service; `models` covers only `models`. */
|
|
189
|
+
readonly coverage: Schema.Literals<readonly ["all", "models"]>;
|
|
190
|
+
readonly models: Schema.$Array<Schema.Struct<{
|
|
191
|
+
readonly providerID: Schema.brand<Schema.String, "Provider.ID"> & {
|
|
192
|
+
opencode: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
193
|
+
anthropic: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
194
|
+
openai: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
195
|
+
google: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
196
|
+
googleVertex: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
197
|
+
githubCopilot: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
198
|
+
amazonBedrock: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
199
|
+
azure: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
200
|
+
openrouter: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
201
|
+
mistral: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
202
|
+
gitlab: string & import("effect/Brand").Brand<"Provider.ID">;
|
|
203
|
+
};
|
|
204
|
+
readonly modelID: Schema.brand<Schema.String, "Model.ID">;
|
|
205
|
+
readonly name: Schema.String;
|
|
206
|
+
/** What a per-model budget's member has spent on this model this month. */
|
|
207
|
+
readonly spent: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.Finite, "Money.USD"> & {
|
|
208
|
+
zero: number & import("effect/Brand").Brand<"Money.USD">;
|
|
209
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.Finite, "Money.USD"> & {
|
|
210
|
+
zero: number & import("effect/Brand").Brand<"Money.USD">;
|
|
211
|
+
}>, never, never>;
|
|
212
|
+
}>>;
|
|
213
|
+
/** The vendors whose models the budget counts, by name; empty when it doesn't count by vendor. */
|
|
214
|
+
readonly vendors: Schema.$Array<Schema.String>;
|
|
215
|
+
/** The input price per 1M tokens from which the budget counts a model, when it sets one. */
|
|
216
|
+
readonly inputPriceAtLeast: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.Finite, "Money.USDPerMillionTokens"> & {
|
|
217
|
+
zero: number & import("effect/Brand").Brand<"Money.USDPerMillionTokens">;
|
|
218
|
+
}>>, Schema.optionalKey<Schema.brand<Schema.Finite, "Money.USDPerMillionTokens"> & {
|
|
219
|
+
zero: number & import("effect/Brand").Brand<"Money.USDPerMillionTokens">;
|
|
220
|
+
}>, never, never>;
|
|
221
|
+
/** The budget counts models picked one by one, rather than by vendor or price. */
|
|
222
|
+
readonly picked: Schema.Boolean;
|
|
223
|
+
/** Everyone in the workspace pools spend against it, so reaching it pauses model use for all of them. */
|
|
224
|
+
readonly shared: Schema.Boolean;
|
|
225
|
+
readonly resetsAt: Schema.Finite;
|
|
226
|
+
}>>;
|
|
227
|
+
}>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export * as UsageLimits from "./usage-limits.js";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
import { Model } from "./model.js";
|
|
4
|
+
import { Money } from "./money.js";
|
|
5
|
+
import { Provider } from "./provider.js";
|
|
6
|
+
import { optional } from "./schema.js";
|
|
7
|
+
const Percent = Schema.Finite.check(Schema.isBetween({ minimum: 0, maximum: 100 }));
|
|
8
|
+
const Instant = Schema.Finite.annotate({ description: "Milliseconds since the Unix epoch" });
|
|
9
|
+
export const Meter = Schema.Struct({
|
|
10
|
+
/** How much of the window's allowance is used. */
|
|
11
|
+
percent: Percent,
|
|
12
|
+
/** Go refuses requests until the window resets. */
|
|
13
|
+
limited: Schema.Boolean,
|
|
14
|
+
resetsAt: Instant,
|
|
15
|
+
}).annotate({ identifier: "UsageLimits.Meter" });
|
|
16
|
+
export const Go = Schema.Struct({
|
|
17
|
+
rolling: Meter,
|
|
18
|
+
weekly: Meter,
|
|
19
|
+
monthly: Meter,
|
|
20
|
+
}).annotate({ identifier: "UsageLimits.Go" });
|
|
21
|
+
export const BudgetModel = Schema.Struct({
|
|
22
|
+
providerID: Provider.ID,
|
|
23
|
+
modelID: Model.ID,
|
|
24
|
+
name: Schema.String,
|
|
25
|
+
/** What a per-model budget's member has spent on this model this month. */
|
|
26
|
+
spent: Money.USD.pipe(optional),
|
|
27
|
+
}).annotate({ identifier: "UsageLimits.BudgetModel" });
|
|
28
|
+
export const Budget = Schema.Struct({
|
|
29
|
+
id: Schema.String,
|
|
30
|
+
limit: Money.USD,
|
|
31
|
+
/** The member's spend this month, or the pooled spend of a combined budget; per model, the most on one model. */
|
|
32
|
+
spent: Money.USD,
|
|
33
|
+
/** `each` limits every member separately; `combined` pools everyone's spend against one limit. */
|
|
34
|
+
scope: Schema.Literals(["each", "combined"]),
|
|
35
|
+
/** `set` counts spend across the budget's models; `model` limits each model separately. */
|
|
36
|
+
per: Schema.Literals(["set", "model"]),
|
|
37
|
+
/** `all` covers every model and billable service; `models` covers only `models`. */
|
|
38
|
+
coverage: Schema.Literals(["all", "models"]),
|
|
39
|
+
models: Schema.Array(BudgetModel),
|
|
40
|
+
/** The vendors whose models the budget counts, by name; empty when it doesn't count by vendor. */
|
|
41
|
+
vendors: Schema.Array(Schema.String),
|
|
42
|
+
/** The input price per 1M tokens from which the budget counts a model, when it sets one. */
|
|
43
|
+
inputPriceAtLeast: Money.USDPerMillionTokens.pipe(optional),
|
|
44
|
+
/** The budget counts models picked one by one, rather than by vendor or price. */
|
|
45
|
+
picked: Schema.Boolean,
|
|
46
|
+
/** Everyone in the workspace pools spend against it, so reaching it pauses model use for all of them. */
|
|
47
|
+
shared: Schema.Boolean,
|
|
48
|
+
resetsAt: Instant,
|
|
49
|
+
}).annotate({ identifier: "UsageLimits.Budget" });
|
|
50
|
+
export const Info = Schema.Struct({
|
|
51
|
+
workspace: Schema.Struct({
|
|
52
|
+
id: Schema.String,
|
|
53
|
+
name: Schema.String.pipe(optional),
|
|
54
|
+
/** The member's usage page in OpenCode Console. */
|
|
55
|
+
usageURL: Schema.String,
|
|
56
|
+
}),
|
|
57
|
+
go: Go.pipe(optional),
|
|
58
|
+
budgets: Schema.Array(Budget),
|
|
59
|
+
}).annotate({ identifier: "UsageLimits.Info" });
|