@eddyskywalker/dsh-chatgpt-subscription 0.36.1 → 0.37.0

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +23 -3
  3. package/lib/client.js +340 -47
  4. package/lib/client.js.map +1 -1
  5. package/lib/index.js +3088 -54
  6. package/lib/types/client/common/ComposerQuotaBadge.d.ts +7 -0
  7. package/lib/types/client/common/ComposerQuotaBadge.d.ts.map +1 -1
  8. package/lib/types/client/locales-ru/opendesign.d.ts.map +1 -1
  9. package/lib/types/client/locales-ru/progress-updates.d.ts.map +1 -1
  10. package/lib/types/client/locales.d.ts +4 -4
  11. package/lib/types/client/opendesign/OpenDesignComposerQuota.d.ts +6 -0
  12. package/lib/types/client/opendesign/OpenDesignComposerQuota.d.ts.map +1 -1
  13. package/lib/types/client/opendesign/OpenDesignSection.d.ts.map +1 -1
  14. package/lib/types/client/opendesign/locales.d.ts +54 -0
  15. package/lib/types/client/opendesign/locales.d.ts.map +1 -1
  16. package/lib/types/client/opendesign/styles.d.ts +5 -0
  17. package/lib/types/client/opendesign/styles.d.ts.map +1 -1
  18. package/lib/types/client/progress-updates/locales.d.ts +17 -2
  19. package/lib/types/client/progress-updates/locales.d.ts.map +1 -1
  20. package/lib/types/client/progress-updates/settings-binding.d.ts +13 -3
  21. package/lib/types/client/progress-updates/settings-binding.d.ts.map +1 -1
  22. package/lib/types/client/progress-updates/settings-section.d.ts +5 -5
  23. package/lib/types/client/progress-updates/settings-section.d.ts.map +1 -1
  24. package/lib/types/client/progress-updates/styles.d.ts.map +1 -1
  25. package/lib/types/host/claude/routes.d.ts.map +1 -1
  26. package/lib/types/host/opendesign/client.d.ts +103 -0
  27. package/lib/types/host/opendesign/client.d.ts.map +1 -1
  28. package/lib/types/host/opendesign/routes.d.ts.map +1 -1
  29. package/lib/types/host/opendesign/types.d.ts +31 -0
  30. package/lib/types/host/opendesign/types.d.ts.map +1 -1
  31. package/lib/types/host/progress-updates/index.d.ts +5 -0
  32. package/lib/types/host/progress-updates/index.d.ts.map +1 -1
  33. package/lib/types/host/progress-updates/prompt.d.ts +37 -3
  34. package/lib/types/host/progress-updates/prompt.d.ts.map +1 -1
  35. package/lib/types/host/progress-updates/tool.d.ts.map +1 -1
  36. package/lib/types/host/proxy-manager.d.ts +63 -1
  37. package/lib/types/host/proxy-manager.d.ts.map +1 -1
  38. package/lib/types/host/widget-board/line-contracts.d.ts +192 -0
  39. package/lib/types/host/widget-board/line-contracts.d.ts.map +1 -0
  40. package/lib/types/host/widget-board/line-quota.d.ts +284 -0
  41. package/lib/types/host/widget-board/line-quota.d.ts.map +1 -0
  42. package/lib/types/host/widget-board/line-registry.d.ts +402 -0
  43. package/lib/types/host/widget-board/line-registry.d.ts.map +1 -0
  44. package/lib/types/host/widget-board/provider.d.ts +140 -0
  45. package/lib/types/host/widget-board/provider.d.ts.map +1 -0
  46. package/lib/types/index.d.ts +10 -0
  47. package/lib/types/index.d.ts.map +1 -1
  48. package/lib/types/shared/opendesign-contracts.d.ts +47 -0
  49. package/lib/types/shared/opendesign-contracts.d.ts.map +1 -1
  50. package/package.json +2 -1
  51. package/widgets/line-flip/index.html +58 -0
  52. package/widgets/line-flip/main.js +1102 -0
  53. package/widgets/line-flip/style.css +729 -0
  54. package/widgets/line-flip/widget.json +555 -0
@@ -0,0 +1,284 @@
1
+ /**
2
+ * One normalizer per subscription line: that line's own `GET /status` payload
3
+ * folded into shape C's `quota` half.
4
+ *
5
+ * Every function here takes `unknown` on purpose. The input is a loopback HTTP
6
+ * response — read from a route this plugin owns but not necessarily at the same
7
+ * version it was written against — so the mapper cannot lean on a DTO type that
8
+ * the running host might not satisfy. A field that is missing, null, a string
9
+ * where a number was expected, or an array where an object was expected must
10
+ * degrade to "nothing measured", never to a thrown error: one line's odd
11
+ * payload must not be able to take the card down.
12
+ *
13
+ * THE THREE THINGS EACH ONE EXISTS TO GET RIGHT
14
+ *
15
+ * 1. Units. The lines disagree: codex states Unix SECONDS (resetsAt),
16
+ * antigravity and cline-pass state ISO 8601 strings, kimi / minimax / qoder /
17
+ * glm / step / command-code state milliseconds. Each normalizer knows which
18
+ * family it holds and converts exactly once — nothing here guesses a unit
19
+ * from a magnitude.
20
+ * 2. Percentages. Some lines state used percent, some a used fraction in
21
+ * [0, 1], some only the remaining share. All of them leave here as used
22
+ * percent in [0, 100].
23
+ * 3. Absence. Null is not zero. A window without a measurement is dropped
24
+ * rather than drawn as a full bar, and a line that answered nothing leaves
25
+ * `quota` null with the reason carried beside it.
26
+ *
27
+ * Windows are ordered shortest first, unstated lengths last — the order a card
28
+ * relies on to draw the tightest limit at the top. The sort is stable, so equal
29
+ * lengths keep the order the line listed them in.
30
+ */
31
+ import type { LineCardQuota, LineCardWindow } from './line-contracts.ts';
32
+ /** What one line's status payload says about its quota, accounts aside. */
33
+ export interface LineQuotaFacts {
34
+ /** The normalized quota, or null when the payload carried nothing usable. */
35
+ quota: LineCardQuota | null;
36
+ /** Plan the line is metered on, when the payload states one. */
37
+ planLabel: string | null;
38
+ /**
39
+ * Account identity the payload itself states (usually a masked email).
40
+ *
41
+ * Null when the payload names no account, which is the caller's cue to fall
42
+ * back to the pool's own primary row.
43
+ */
44
+ accountLabel: string | null;
45
+ /** Whether the payload says a credential exists; null when it never said. */
46
+ signedIn: boolean | null;
47
+ /** The line's own reason its numbers are missing, when it reported one. */
48
+ error: string | null;
49
+ }
50
+ /**
51
+ * The ChatGPT line's quota, as `GET /status` answers it.
52
+ *
53
+ * Units: `QuotaWindowDto.resetsAt`, `resetCredits.expiresAt` and
54
+ * `quota.fetchedAt` are Unix SECONDS here (that line's own quota service
55
+ * multiplies them by 1000 further out), while everything else on the payload is
56
+ * already milliseconds. The bucket list also carries an older
57
+ * `primary`/`secondary` pair that some payload generations state instead of
58
+ * `windows`; both are read, so the card shows the same bars the settings card
59
+ * does.
60
+ *
61
+ * @param status - The route's `value`.
62
+ * @returns The facts.
63
+ */
64
+ export declare function normalizeCodexQuota(status: unknown): LineQuotaFacts;
65
+ /**
66
+ * The Kimi Code line's quota.
67
+ *
68
+ * Units: `resetsAt` and `fetchedAt` are already milliseconds. The fallback
69
+ * wallet (`extraUsage`) is stated in the currency's minor unit, so it is
70
+ * divided once and kept with its currency: a bare "75.00" would be read as
71
+ * provider credits by every other card on the board.
72
+ *
73
+ * @param status - The route's `value`.
74
+ * @returns The facts.
75
+ */
76
+ export declare function normalizeKimiCodeQuota(status: unknown): LineQuotaFacts;
77
+ /**
78
+ * The MiniMax Code line's quota.
79
+ *
80
+ * Units: milliseconds throughout (`resetsAtMs`, `fetchedAtMs`). The windows are
81
+ * keyed (`interval` / `weekly`) rather than labelled — the line leaves the
82
+ * wording to the client — and carry a REMAINING percent, sometimes only a
83
+ * remaining one; both are inverted into the used share here.
84
+ *
85
+ * @param status - The route's `value`.
86
+ * @returns The facts.
87
+ */
88
+ export declare function normalizeMinimaxCodeQuota(status: unknown): LineQuotaFacts;
89
+ /**
90
+ * The Antigravity line's quota.
91
+ *
92
+ * Units: the harder one of the set. Each allowance is stated as
93
+ * `remainingFraction` in [0, 1] (null when the service measured nothing, and
94
+ * NOT zero), named windows arrive as `window: '5h' | 'weekly'`, and reset
95
+ * instants as ISO 8601. Windows are grouped (Gemini models, third-party
96
+ * models); each bucket's label is prefixed with its group once there is more
97
+ * than one group, because "Weekly" twice on one card says nothing about which
98
+ * allowance it is.
99
+ *
100
+ * @param status - The route's `value`.
101
+ * @returns The facts.
102
+ */
103
+ export declare function normalizeAntigravityQuota(status: unknown): LineQuotaFacts;
104
+ /**
105
+ * The Command Code line's quota.
106
+ *
107
+ * Units: two different meter shapes, and both are needed. `windows[]` is
108
+ * already normalized (`usedPercent`, `windowDurationMins`, milliseconds);
109
+ * `meters[]` states a used FRACTION that is null whenever the service reports a
110
+ * spend meter instead of a bounded allowance, and only the ones that did state
111
+ * a fraction become bars. The credit balance is that line's own string, kept
112
+ * verbatim.
113
+ *
114
+ * @param status - The route's `value`.
115
+ * @returns The facts.
116
+ */
117
+ export declare function normalizeCommandCodeQuota(status: unknown): LineQuotaFacts;
118
+ /**
119
+ * The Claude line's quota.
120
+ *
121
+ * Units: millisecond `fetchedAt` / `observedAt`, ISO 8601 `resetsAt`, and a
122
+ * used share that may be stated as percent or as a fraction in [0, 1] — the
123
+ * three numeric fields are null together when the source said nothing, so the
124
+ * fraction is only consulted when the percent is absent.
125
+ *
126
+ * The line answers `quota: null` on a first read and only fills it after its
127
+ * own `POST /quota`; that is what the refresh capability exists for, so an
128
+ * empty first read is reported as-is rather than as an error.
129
+ *
130
+ * @param status - The route's `value`.
131
+ * @returns The facts.
132
+ */
133
+ export declare function normalizeClaudeQuota(status: unknown): LineQuotaFacts;
134
+ /**
135
+ * The GLM Coding Plan line's quota.
136
+ *
137
+ * Units: milliseconds (`resetsAt`, `fetchedAt`). Windows are keyed
138
+ * (`five-hour` / `weekly` / `monthly`) and their used percent is null when the
139
+ * upstream reported no bounded allowance — an unlimited plan states no
140
+ * fraction, and drawing that as 0% used would invent a measurement.
141
+ *
142
+ * @param status - The route's `value`.
143
+ * @returns The facts.
144
+ */
145
+ export declare function normalizeGlmCodingPlanQuota(status: unknown): LineQuotaFacts;
146
+ /**
147
+ * The Step Code line's quota.
148
+ *
149
+ * Units: milliseconds. Two payload generations share one snapshot: an older
150
+ * account has 5-hour and weekly windows, a newer one has `creditBuckets` — an
151
+ * absolute amount per bucket, with no percentage at all. The buckets become the
152
+ * card's credit figure (their remaining amounts summed) rather than being
153
+ * squeezed into a progress bar nobody measured; the `credit` window key, which
154
+ * names the same thing, is deliberately left without a bar for the same reason.
155
+ *
156
+ * @param status - The route's `value`.
157
+ * @returns The facts.
158
+ */
159
+ export declare function normalizeStepCodeQuota(status: unknown): LineQuotaFacts;
160
+ /**
161
+ * The Qoder line's quota.
162
+ *
163
+ * Units: milliseconds, with one sentinel: the account period ends at
164
+ * `253402214400000` (year 9999) for a subscription that never expires, and a
165
+ * card would print that as a real date, so the shared ceiling drops it.
166
+ *
167
+ * Qoder states ABSOLUTE amounts (total / used / remaining + unit), not windows.
168
+ * A ratio is derived only when both total and used are stated AND total is
169
+ * positive; anything else is reported as a credit balance instead of a bar.
170
+ *
171
+ * @param status - The route's `value`.
172
+ * @returns The facts.
173
+ */
174
+ export declare function normalizeQoderQuota(status: unknown): LineQuotaFacts;
175
+ /**
176
+ * The Cline Pass line's quota.
177
+ *
178
+ * Units: `percentUsed` is a percent, `resetsAt` is an ISO 8601 string, and the
179
+ * window's length is only stated as a gateway token (`five_hour` / `weekly` /
180
+ * `monthly`). The payload carries one reading PER ACCOUNT, so the row shown is
181
+ * the pool's active account when it has a reading, else the first account that
182
+ * did read something. An account that failed states its own reason, which is
183
+ * what the card shows instead of an empty frame.
184
+ *
185
+ * @param status - The route's `value`.
186
+ * @returns The facts.
187
+ */
188
+ export declare function normalizeClinePassQuota(status: unknown): LineQuotaFacts;
189
+ /**
190
+ * The OpenDesign line's quota.
191
+ *
192
+ * Units: this line's REAL allowance is the "Design Plan" window pair the console
193
+ * renders as a remaining percentage — a 5-hour window and a 7-day one, each
194
+ * stating an integer credit LIMIT and what is LEFT of it, plus an ISO reset
195
+ * instant. A bar is therefore the USED share, `(limit − remaining) / limit`;
196
+ * the remaining percentage is `100 − used` and is derived by whoever prints it.
197
+ *
198
+ * `quota.credits` keeps the WALLET balance, and only that: the spendable USD
199
+ * figure is a different quantity from a window's allowance, and folding one into
200
+ * the other is how a card ends up stating a percentage of the wrong thing.
201
+ *
202
+ * Absence is the honest half of this reader. The endpoint is only known to accept
203
+ * a browser session, so a control-key read may be refused; `codingPlan.error`
204
+ * then carries the reason and `windows` is empty. An empty list is reported as
205
+ * exactly that — never padded with a 0 % bar, which would claim a limit nobody
206
+ * observed — and the reason rides along so the card can say why.
207
+ *
208
+ * @param status - The route's `value`.
209
+ * @returns The facts.
210
+ */
211
+ export declare function normalizeOpenDesignQuota(status: unknown): LineQuotaFacts;
212
+ /**
213
+ * One pooled account's own quota, as a card row draws it.
214
+ *
215
+ * A row states a bar, the instant it reopens, and — since this reading is the
216
+ * only place any line computes an account's windows — the WHOLE list behind that
217
+ * bar. Never a plan, a label or an error: those belong to the pool's row.
218
+ *
219
+ * `null` in either scalar keeps the contract's own meaning — nobody measured that
220
+ * fact — and is what makes a half-known reading useless rather than half-true
221
+ * (see the two readers below). `windows` is then `[]` rather than a padded
222
+ * placeholder: a line that measured nothing has no window to show, and a 0 % bar
223
+ * would report a limit nobody observed.
224
+ */
225
+ export interface LineAccountQuotaReading {
226
+ /** Share of the account's shortest window consumed, 0-100, or null. */
227
+ usedPercent: number | null;
228
+ /** Unix MILLISECONDS that window reopens, or null when nobody said. */
229
+ resetsAt: number | null;
230
+ /**
231
+ * Every window this account's quota stated, shortest first.
232
+ *
233
+ * Empty — never absent — when the line has no window vocabulary of its own
234
+ * (Qoder states absolute amounts, not percentages) or measured nothing.
235
+ */
236
+ windows: LineCardWindow[];
237
+ }
238
+ /**
239
+ * The Qoder account's own reading, from one `quota/usage` snapshot.
240
+ *
241
+ * Qoder states ABSOLUTE amounts per bucket (total / used / remaining), never a
242
+ * percentage, so a share is derived here only under the same rule
243
+ * {@link normalizeQoderQuota} already applies to the line-level card: BOTH a
244
+ * total (positive) and a used figure must be stated. A bucket that states
245
+ * amounts without a bounded allowance — a top-up balance, an org cap nobody
246
+ * measured — is not turned into a bar, and a snapshot with no such bucket
247
+ * answers null rather than a made-up zero.
248
+ *
249
+ * No window list accompanies it: this line has no percentage windows at all
250
+ * (its buckets are absolute amounts, and its only instant is the snapshot's own
251
+ * expiry), so `windows` is `[]` — the honest answer rather than a manufactured
252
+ * one-window list nobody measured.
253
+ *
254
+ * @param snapshot - The account's quota snapshot (`{ buckets, expiresAt }`).
255
+ * @returns The reading, or null when nothing bounded was measured.
256
+ */
257
+ export declare function qoderAccountQuotaReading(snapshot: unknown): LineAccountQuotaReading | null;
258
+ /**
259
+ * The MiniMax Code account's own reading, from one Token Plan snapshot.
260
+ *
261
+ * The window the row's BAR draws is the rolling 5-hour one — the line's own
262
+ * headline, and the tightest limit the plan has: its machine key is `interval`,
263
+ * and a payload that named no key is placed by its nominal length instead. The
264
+ * weekly window is deliberately NOT substituted (a row saying 5% while the
265
+ * 5-hour window is spent is worse than a row saying nothing), and an `unlimited`
266
+ * window states no share at all, so nothing becomes a bar.
267
+ *
268
+ * `windows` carries the WHOLE list all the same: this line states it — `interval`
269
+ * and `weekly`, each with a share and a reset instant — so an account can be
270
+ * opened up and show both of its limits instead of only the bar.
271
+ *
272
+ * @param quota - The parsed `MinimaxCodeQuota`.
273
+ * @returns The reading, or null when the 5-hour window measured nothing.
274
+ */
275
+ export declare function minimaxAccountQuotaReading(quota: unknown): LineAccountQuotaReading | null;
276
+ /**
277
+ * Every normalizer, keyed by the line id a card names.
278
+ *
279
+ * The registry looks a line up here; a line that is registered but has no entry
280
+ * falls back to nothing measured, so adding a pool without a normalizer
281
+ * degrades to "no quota window" instead of to a thrown error.
282
+ */
283
+ export declare const LINE_QUOTA_NORMALIZERS: Readonly<Record<string, (status: unknown) => LineQuotaFacts>>;
284
+ //# sourceMappingURL=line-quota.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"line-quota.d.ts","sourceRoot":"","sources":["../../../../src/host/widget-board/line-quota.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,EAEV,aAAa,EAEb,cAAc,EACf,MAAM,qBAAqB,CAAA;AAE5B,2EAA2E;AAC3E,MAAM,WAAW,cAAc;IAC7B,6EAA6E;IAC7E,KAAK,EAAE,aAAa,GAAG,IAAI,CAAA;IAC3B,gEAAgE;IAChE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB;;;;;OAKG;IACH,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,6EAA6E;IAC7E,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAA;IACxB,2EAA2E;IAC3E,KAAK,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