opencode-codebuddy-quota 0.1.0 → 0.1.2
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/config.default.json +41 -38
- package/package.json +2 -1
- package/rpc.ts +92 -92
- package/server.ts +132 -17
- package/src/gui/battery.tsx +81 -81
- package/src/gui/pace.ts +76 -76
- package/src/gui/quota.ts +198 -198
- package/src/gui/store.ts +181 -181
- package/src/gui.tsx +111 -111
- package/src/server/catalog.ts +264 -264
- package/src/server/config-writer.ts +621 -621
- package/src/server/config.ts +215 -195
- package/src/server/embedding-local.ts +166 -0
- package/src/server/embedding-mode.ts +14 -0
- package/src/server/gateway-owner.ts +243 -0
- package/src/server/gateway-setup.ts +51 -0
- package/src/server/logger.ts +26 -26
- package/src/server/model-cache.ts +136 -0
- package/src/server/model-info.ts +109 -109
- package/src/server/model-prewarm.ts +123 -0
- package/src/server/models-dev.ts +77 -77
- package/src/server/models-endpoint.ts +74 -0
- package/src/server/package-spec.ts +42 -42
- package/src/server/package-version.ts +51 -51
- package/src/server/pricing.ts +169 -169
- package/src/server/proxy.ts +335 -7
- package/src/server/stream-collect.ts +166 -0
- package/src/server/wire.ts +67 -67
package/src/server/wire.ts
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
import type { SiteInfo } from "../shared"
|
|
2
|
-
import type { Reading } from "./quota-source"
|
|
3
|
-
|
|
4
|
-
/** The object the RPC returns; the fields mirror `rpc.ts`'s output schema. */
|
|
5
|
-
export interface WireReading {
|
|
6
|
-
ok: boolean
|
|
7
|
-
stale: boolean
|
|
8
|
-
/** Served from the 30-second cache: the numbers are real but not from this call. */
|
|
9
|
-
cached: boolean
|
|
10
|
-
/** How old the numbers are, in whole seconds. */
|
|
11
|
-
ageSeconds: number | null
|
|
12
|
-
remaining: number | null
|
|
13
|
-
used: number | null
|
|
14
|
-
total: number | null
|
|
15
|
-
cycleStart: string | null
|
|
16
|
-
cycleEnd: string | null
|
|
17
|
-
resetAt: string | null
|
|
18
|
-
fetchedAt: string | null
|
|
19
|
-
error: string | null
|
|
20
|
-
site: "cn" | "intl"
|
|
21
|
-
sites: SiteInfo[]
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* `ok` answers "do we have numbers", `stale` answers "did the latest attempt
|
|
26
|
-
* fail". A reading with numbers but a failed refresh is `ok: true, stale: true`
|
|
27
|
-
* — the GUI shows the old figure marked stale. Only a source that never
|
|
28
|
-
* succeeded says `ok: false`, which the GUI treats as unavailable rather than
|
|
29
|
-
* as a stale number.
|
|
30
|
-
*/
|
|
31
|
-
export function toWireReading(
|
|
32
|
-
reading: Reading,
|
|
33
|
-
info: { site: "cn" | "intl"; sites: SiteInfo[] },
|
|
34
|
-
): WireReading {
|
|
35
|
-
const numbers = {
|
|
36
|
-
remaining: reading.remaining,
|
|
37
|
-
used: reading.used,
|
|
38
|
-
total: reading.total,
|
|
39
|
-
cycleStart: reading.cycleStart,
|
|
40
|
-
cycleEnd: reading.cycleEnd,
|
|
41
|
-
resetAt: reading.resetAt,
|
|
42
|
-
fetchedAt: reading.fetchedAt,
|
|
43
|
-
error: reading.error,
|
|
44
|
-
}
|
|
45
|
-
if (reading.fetchedAt === null) {
|
|
46
|
-
return {
|
|
47
|
-
ok: false,
|
|
48
|
-
stale: true,
|
|
49
|
-
cached: false,
|
|
50
|
-
ageSeconds: null,
|
|
51
|
-
...numbers,
|
|
52
|
-
remaining: null,
|
|
53
|
-
used: null,
|
|
54
|
-
total: null,
|
|
55
|
-
cycleStart: null,
|
|
56
|
-
cycleEnd: null,
|
|
57
|
-
resetAt: null,
|
|
58
|
-
fetchedAt: null,
|
|
59
|
-
site: info.site,
|
|
60
|
-
sites: info.sites,
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
ok: true, stale: reading.stale, cached: reading.cached, ageSeconds: reading.ageSeconds,
|
|
65
|
-
...numbers, site: info.site, sites: info.sites,
|
|
66
|
-
}
|
|
67
|
-
}
|
|
1
|
+
import type { SiteInfo } from "../shared"
|
|
2
|
+
import type { Reading } from "./quota-source"
|
|
3
|
+
|
|
4
|
+
/** The object the RPC returns; the fields mirror `rpc.ts`'s output schema. */
|
|
5
|
+
export interface WireReading {
|
|
6
|
+
ok: boolean
|
|
7
|
+
stale: boolean
|
|
8
|
+
/** Served from the 30-second cache: the numbers are real but not from this call. */
|
|
9
|
+
cached: boolean
|
|
10
|
+
/** How old the numbers are, in whole seconds. */
|
|
11
|
+
ageSeconds: number | null
|
|
12
|
+
remaining: number | null
|
|
13
|
+
used: number | null
|
|
14
|
+
total: number | null
|
|
15
|
+
cycleStart: string | null
|
|
16
|
+
cycleEnd: string | null
|
|
17
|
+
resetAt: string | null
|
|
18
|
+
fetchedAt: string | null
|
|
19
|
+
error: string | null
|
|
20
|
+
site: "cn" | "intl"
|
|
21
|
+
sites: SiteInfo[]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* `ok` answers "do we have numbers", `stale` answers "did the latest attempt
|
|
26
|
+
* fail". A reading with numbers but a failed refresh is `ok: true, stale: true`
|
|
27
|
+
* — the GUI shows the old figure marked stale. Only a source that never
|
|
28
|
+
* succeeded says `ok: false`, which the GUI treats as unavailable rather than
|
|
29
|
+
* as a stale number.
|
|
30
|
+
*/
|
|
31
|
+
export function toWireReading(
|
|
32
|
+
reading: Reading,
|
|
33
|
+
info: { site: "cn" | "intl"; sites: SiteInfo[] },
|
|
34
|
+
): WireReading {
|
|
35
|
+
const numbers = {
|
|
36
|
+
remaining: reading.remaining,
|
|
37
|
+
used: reading.used,
|
|
38
|
+
total: reading.total,
|
|
39
|
+
cycleStart: reading.cycleStart,
|
|
40
|
+
cycleEnd: reading.cycleEnd,
|
|
41
|
+
resetAt: reading.resetAt,
|
|
42
|
+
fetchedAt: reading.fetchedAt,
|
|
43
|
+
error: reading.error,
|
|
44
|
+
}
|
|
45
|
+
if (reading.fetchedAt === null) {
|
|
46
|
+
return {
|
|
47
|
+
ok: false,
|
|
48
|
+
stale: true,
|
|
49
|
+
cached: false,
|
|
50
|
+
ageSeconds: null,
|
|
51
|
+
...numbers,
|
|
52
|
+
remaining: null,
|
|
53
|
+
used: null,
|
|
54
|
+
total: null,
|
|
55
|
+
cycleStart: null,
|
|
56
|
+
cycleEnd: null,
|
|
57
|
+
resetAt: null,
|
|
58
|
+
fetchedAt: null,
|
|
59
|
+
site: info.site,
|
|
60
|
+
sites: info.sites,
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
ok: true, stale: reading.stale, cached: reading.cached, ageSeconds: reading.ageSeconds,
|
|
65
|
+
...numbers, site: info.site, sites: info.sites,
|
|
66
|
+
}
|
|
67
|
+
}
|