@eddyskywalker/dsh-chatgpt-subscription 0.36.2 → 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.
- package/CHANGELOG.md +39 -0
- package/README.md +23 -3
- package/lib/client.js +340 -47
- package/lib/client.js.map +1 -1
- package/lib/index.js +3043 -40
- package/lib/types/client/common/ComposerQuotaBadge.d.ts +7 -0
- package/lib/types/client/common/ComposerQuotaBadge.d.ts.map +1 -1
- package/lib/types/client/locales-ru/opendesign.d.ts.map +1 -1
- package/lib/types/client/locales-ru/progress-updates.d.ts.map +1 -1
- package/lib/types/client/locales.d.ts +4 -4
- package/lib/types/client/opendesign/OpenDesignComposerQuota.d.ts +6 -0
- package/lib/types/client/opendesign/OpenDesignComposerQuota.d.ts.map +1 -1
- package/lib/types/client/opendesign/OpenDesignSection.d.ts.map +1 -1
- package/lib/types/client/opendesign/locales.d.ts +54 -0
- package/lib/types/client/opendesign/locales.d.ts.map +1 -1
- package/lib/types/client/opendesign/styles.d.ts +5 -0
- package/lib/types/client/opendesign/styles.d.ts.map +1 -1
- package/lib/types/client/progress-updates/locales.d.ts +17 -2
- package/lib/types/client/progress-updates/locales.d.ts.map +1 -1
- package/lib/types/client/progress-updates/settings-binding.d.ts +13 -3
- package/lib/types/client/progress-updates/settings-binding.d.ts.map +1 -1
- package/lib/types/client/progress-updates/settings-section.d.ts +5 -5
- package/lib/types/client/progress-updates/settings-section.d.ts.map +1 -1
- package/lib/types/client/progress-updates/styles.d.ts.map +1 -1
- package/lib/types/host/opendesign/client.d.ts +103 -0
- package/lib/types/host/opendesign/client.d.ts.map +1 -1
- package/lib/types/host/opendesign/routes.d.ts.map +1 -1
- package/lib/types/host/opendesign/types.d.ts +31 -0
- package/lib/types/host/opendesign/types.d.ts.map +1 -1
- package/lib/types/host/progress-updates/index.d.ts +5 -0
- package/lib/types/host/progress-updates/index.d.ts.map +1 -1
- package/lib/types/host/progress-updates/prompt.d.ts +37 -3
- package/lib/types/host/progress-updates/prompt.d.ts.map +1 -1
- package/lib/types/host/progress-updates/tool.d.ts.map +1 -1
- package/lib/types/host/proxy-manager.d.ts +63 -1
- package/lib/types/host/proxy-manager.d.ts.map +1 -1
- package/lib/types/host/widget-board/line-contracts.d.ts +192 -0
- package/lib/types/host/widget-board/line-contracts.d.ts.map +1 -0
- package/lib/types/host/widget-board/line-quota.d.ts +284 -0
- package/lib/types/host/widget-board/line-quota.d.ts.map +1 -0
- package/lib/types/host/widget-board/line-registry.d.ts +402 -0
- package/lib/types/host/widget-board/line-registry.d.ts.map +1 -0
- package/lib/types/host/widget-board/provider.d.ts +140 -0
- package/lib/types/host/widget-board/provider.d.ts.map +1 -0
- package/lib/types/index.d.ts +10 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/shared/opendesign-contracts.d.ts +47 -0
- package/lib/types/shared/opendesign-contracts.d.ts.map +1 -1
- package/package.json +2 -1
- package/widgets/line-flip/index.html +58 -0
- package/widgets/line-flip/main.js +1102 -0
- package/widgets/line-flip/style.css +729 -0
- package/widgets/line-flip/widget.json +555 -0
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
* 文本用函数形式提供(而不是静态字符串):开关关闭时返回空串,装配期就地
|
|
5
5
|
* 抹掉引导,不需要重启会话、也不需要重挂插件行。
|
|
6
6
|
*
|
|
7
|
+
* ## 为什么是英文
|
|
8
|
+
*
|
|
9
|
+
* 提示词是写给模型看的,不是写给用户看的:同一段要求在英文下最短、歧义最少,
|
|
10
|
+
* 也和工具描述(`tool.ts` 的 `PROGRESS_UPDATE_DESCRIPTION`,本来就是英文)保持
|
|
11
|
+
* 同一套措辞。用户看到的语言由 {@link progressLanguageDirective} 单独钉住——
|
|
12
|
+
* 「指令用英文」与「输出用中文」是两件事,不要混在一起。
|
|
13
|
+
*
|
|
7
14
|
* @module dsh-chatgpt-subscription/host/progress-updates/prompt
|
|
8
15
|
*/
|
|
9
16
|
/**
|
|
@@ -19,16 +26,43 @@ export declare const PROGRESS_SECTION_NAME = "plugin:progress-updates";
|
|
|
19
26
|
* 不与它们并列。
|
|
20
27
|
*/
|
|
21
28
|
export declare const PROGRESS_SECTION_ORDER = 220;
|
|
29
|
+
/**
|
|
30
|
+
* 进展更新的输出语言。
|
|
31
|
+
*
|
|
32
|
+
* - `auto`:跟随对话语言(默认);
|
|
33
|
+
* - `zh`:一律中文;
|
|
34
|
+
* - `en`:一律英文。
|
|
35
|
+
*
|
|
36
|
+
* 只管 `progress_update` 的标题与正文,不影响会话里其它任何输出。
|
|
37
|
+
*/
|
|
38
|
+
export type ProgressUpdateLanguage = 'auto' | 'zh' | 'en';
|
|
39
|
+
/** 允许的取值,供设置解析做白名单校验(配置里写错就等于没写)。 */
|
|
40
|
+
export declare const PROGRESS_UPDATE_LANGUAGES: readonly ProgressUpdateLanguage[];
|
|
22
41
|
/**
|
|
23
42
|
* 引导词正文。写法对齐 Kimi 的「进展更新」:先说清多步任务早期的思路,再报
|
|
24
43
|
* 有意义的结论、阶段判断、长等待与阻塞;每条给一行标题,细节放正文;不重复
|
|
25
|
-
*
|
|
44
|
+
* 没有变化的状态。开头与结尾两条被提成硬要求——没有它们,面板在任务的两端
|
|
45
|
+
* 都是空的。
|
|
26
46
|
*/
|
|
27
47
|
export declare const PROGRESS_GUIDANCE: string;
|
|
48
|
+
/**
|
|
49
|
+
* 每个语言档位对应的一句指令。
|
|
50
|
+
*
|
|
51
|
+
* 只约束输出的标题与正文,不约束引导词本身;三条都必须自洽——`auto` 不许在
|
|
52
|
+
* 用户说中文时滑回英文,`zh`/`en` 则明确压过对话语言。
|
|
53
|
+
*/
|
|
54
|
+
export declare const PROGRESS_LANGUAGE_DIRECTIVES: Readonly<Record<ProgressUpdateLanguage, string>>;
|
|
55
|
+
/**
|
|
56
|
+
* 取一个语言档位的指令文本;未知取值按 `auto` 处理。
|
|
57
|
+
* @param language - 配置里读到的语言档位。
|
|
58
|
+
* @returns 追加到引导词末尾的一句指令。
|
|
59
|
+
*/
|
|
60
|
+
export declare function progressLanguageDirective(language: ProgressUpdateLanguage): string;
|
|
28
61
|
/**
|
|
29
62
|
* 生成提示词分节的文本提供者。
|
|
30
63
|
* @param isEnabled - 读取当前开关状态的函数(每次装配重新求值)。
|
|
31
|
-
* @
|
|
64
|
+
* @param language - 读取当前输出语言的函数;缺省按 `auto` 处理。
|
|
65
|
+
* @returns 开关打开时返回引导词加语言指令,关闭时返回空串。
|
|
32
66
|
*/
|
|
33
|
-
export declare function progressSectionText(isEnabled: () => boolean): () => string;
|
|
67
|
+
export declare function progressSectionText(isEnabled: () => boolean, language?: () => ProgressUpdateLanguage): () => string;
|
|
34
68
|
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../../src/host/progress-updates/prompt.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../../src/host/progress-updates/prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,4BAA4B,CAAA;AAE9D;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,MAAM,CAAA;AAEzC;;;;;;;;GAQG;AACH,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,CAAA;AAEzD,qCAAqC;AACrC,eAAO,MAAM,yBAAyB,EAAE,SAAS,sBAAsB,EAAyB,CAAA;AAEhG;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,QAwBlB,CAAA;AAEZ;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,MAAM,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAIzF,CAAA;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,sBAAsB,GAAG,MAAM,CAElF;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,OAAO,EACxB,QAAQ,GAAE,MAAM,sBAAqC,GACpD,MAAM,MAAM,CAEd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../../src/host/progress-updates/tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAE5D,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,YAAY,CAAA;AAE9D,4BAA4B;AAC5B,eAAO,MAAM,gBAAgB,oBAAoB,CAAA;AAEjD,iDAAiD;AACjD,eAAO,MAAM,oBAAoB,iEAAiE,CAAA;AAElG,iBAAiB;AACjB,eAAO,MAAM,2BAA2B,
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../../src/host/progress-updates/tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAE5D,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,YAAY,CAAA;AAE9D,4BAA4B;AAC5B,eAAO,MAAM,gBAAgB,oBAAoB,CAAA;AAEjD,iDAAiD;AACjD,eAAO,MAAM,oBAAoB,iEAAiE,CAAA;AAElG,iBAAiB;AACjB,eAAO,MAAM,2BAA2B,QAa7B,CAAA;AAEX,wCAAwC;AACxC,MAAM,WAAW,kBAAkB;IACjC,yBAAyB;IACzB,IAAI,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAA;CACtC;AAED,sCAAsC;AACtC,MAAM,WAAW,oBAAoB;IACnC,sBAAsB;IACtB,SAAS,EAAE,OAAO,CAAA;CACnB;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAC7C,0BAA0B;IAC1B,SAAS,EAAE,MAAM,OAAO,CAAA;IACxB,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,kBAAkB,GAAG,SAAS,CAAA;IAC3C,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,CAAA;CACjD,GAAG,cAAc,CAgDjB"}
|
|
@@ -12,27 +12,89 @@ export interface ParseEnvProxyOptions {
|
|
|
12
12
|
envFile?: string | null;
|
|
13
13
|
}
|
|
14
14
|
export declare function parseEnvProxy(env?: Record<string, string | undefined>, options?: ParseEnvProxyOptions): string | null;
|
|
15
|
-
export
|
|
15
|
+
export interface ParseNoProxyOptions {
|
|
16
|
+
/**
|
|
17
|
+
* `$DSH_HOME/.env`, consulted after the process environment; `null` disables
|
|
18
|
+
* the file fallback, exactly like {@link ParseEnvProxyOptions}.
|
|
19
|
+
*/
|
|
20
|
+
envFile?: string | null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The raw `NO_PROXY` list, or an empty string when none is configured.
|
|
24
|
+
*
|
|
25
|
+
* Read next to the proxy itself on purpose: a proxy that a line is *told* to use
|
|
26
|
+
* and a bypass list that lives somewhere else are how "the local gateway
|
|
27
|
+
* suddenly goes through Clash" happens.
|
|
28
|
+
*/
|
|
29
|
+
export declare function parseNoProxy(env?: Record<string, string | undefined>, options?: ParseNoProxyOptions): string;
|
|
30
|
+
/**
|
|
31
|
+
* Whether a host is loopback, and therefore never worth a proxy hop.
|
|
32
|
+
*
|
|
33
|
+
* The whole `127.0.0.0/8` block, not just `127.0.0.1`: a second loopback alias
|
|
34
|
+
* is a normal way to run a local gateway, and a proxy cannot reach it any
|
|
35
|
+
* better than the process itself can.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isLoopbackHostname(hostname: string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Standard `NO_PROXY` matching: `*`, exact hosts, domain suffixes, `host:port`.
|
|
40
|
+
*
|
|
41
|
+
* Deliberately not CIDR: a proxy configured for this plugin is a local GUI
|
|
42
|
+
* proxy, and the entries that matter are the ones a user types.
|
|
43
|
+
*/
|
|
44
|
+
export declare function noProxyBypasses(hostname: string, port: string, list: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Whether a request target must skip the proxy.
|
|
47
|
+
*
|
|
48
|
+
* Loopback first: a local gateway behind a proxy hop is a request the proxy has
|
|
49
|
+
* to refuse (or worse, forwards to itself), and the plugin's own loopback reads
|
|
50
|
+
* already use a bare fetch for the same reason.
|
|
51
|
+
*/
|
|
52
|
+
export declare function shouldBypassProxy(target: URL | string, noProxyList?: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* GNOME's manual proxy, the Linux equivalent of the Windows registry read.
|
|
55
|
+
*
|
|
56
|
+
* `auto` is a PAC URL, which cannot be applied by posting through an agent, and
|
|
57
|
+
* `none` means no system proxy; both fall through to the environment.
|
|
58
|
+
*/
|
|
59
|
+
export declare function parseLinuxSystemProxy(read: (key: string) => string | null): string | null;
|
|
60
|
+
export declare function detectSystemProxy(platform?: NodeJS.Platform, env?: Record<string, string | undefined>, readSettings?: (key: string) => string | null): string | null;
|
|
16
61
|
/** Called with the proxy URL the first time detection reports one after a `null`. */
|
|
17
62
|
export type SystemProxyListener = (proxyUrl: string) => void;
|
|
18
63
|
export interface ProxyFetchOptions {
|
|
19
64
|
getPreferences: () => Pick<SubscriptionPreferencesDto, 'proxyMode' | 'customProxyUrl'>;
|
|
20
65
|
baseFetch?: FetchLike;
|
|
21
66
|
systemProxyDetector?: () => string | null;
|
|
67
|
+
/**
|
|
68
|
+
* The `NO_PROXY` list, read per request (subject to the same TTL as the system
|
|
69
|
+
* proxy) so an edit takes effect without a restart. A test injects this rather
|
|
70
|
+
* than inheriting the machine's own bypass list.
|
|
71
|
+
*/
|
|
72
|
+
noProxyReader?: () => string;
|
|
22
73
|
logger?: Pick<Console, 'info' | 'warn' | 'error'>;
|
|
23
74
|
}
|
|
24
75
|
export declare class ProxyManager {
|
|
25
76
|
private readonly getPreferences;
|
|
26
77
|
private readonly baseFetch;
|
|
27
78
|
private readonly systemProxyDetector;
|
|
79
|
+
private readonly noProxyReader;
|
|
28
80
|
private readonly logger?;
|
|
29
81
|
private cachedSystemProxy;
|
|
30
82
|
private lastSystemProxyCheck;
|
|
83
|
+
private cachedNoProxy;
|
|
84
|
+
private lastNoProxyCheck;
|
|
31
85
|
private detected;
|
|
32
86
|
private readonly proxyListeners;
|
|
33
87
|
private readonly agents;
|
|
34
88
|
constructor(options: ProxyFetchOptions);
|
|
35
89
|
getSystemProxy(force?: boolean): string | null;
|
|
90
|
+
/**
|
|
91
|
+
* The active `NO_PROXY` list, re-read at most once per TTL.
|
|
92
|
+
*
|
|
93
|
+
* A reader that throws (an unreadable `$DSH_HOME/.env`) reads as "no bypass
|
|
94
|
+
* list", never as "bypass everything": the wrong guess in that direction would
|
|
95
|
+
* take an active proxy away from every line at once.
|
|
96
|
+
*/
|
|
97
|
+
getNoProxyList(force?: boolean): string;
|
|
36
98
|
/**
|
|
37
99
|
* Observe the system proxy becoming known.
|
|
38
100
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy-manager.d.ts","sourceRoot":"","sources":["../../../src/host/proxy-manager.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAa,0BAA0B,EAAE,MAAM,wBAAwB,CAAA;AAEnF,MAAM,MAAM,SAAS,GAAG,OAAO,KAAK,CAAA;AAqBpC,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAOxD;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAqCvE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAwBnE;AAED,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB;AAED,wBAAgB,aAAa,CAC3B,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CA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AC,oBAAoB,CAAI;IAChC,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,gBAAgB,CAAI;IAC5B,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiC;IAChE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgC;gBAE3C,OAAO,EAAE,iBAAiB;IAQtC,cAAc,CAAC,KAAK,UAAQ,GAAG,MAAM,GAAG,IAAI;IA8B5C;;;;;;OAMG;IACH,cAAc,CAAC,KAAK,UAAQ,GAAG,MAAM;IAYrC;;;;;;;;;OASG;IACH,qBAAqB,CAAC,QAAQ,EAAE,mBAAmB,GAAG,MAAM,IAAI;IAKhE,qBAAqB,IAAI,MAAM,GAAG,IAAI;IAgBtC,OAAO,CAAC,gBAAgB;IAcxB,WAAW,IAAI,SAAS;IA8BxB,OAAO,IAAI,IAAI;CAOhB"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shape C: everything ONE card needs about ONE subscription line.
|
|
3
|
+
*
|
|
4
|
+
* A card is identified by \`props.line\`, so the whole answer is produced per
|
|
5
|
+
* line: the line's own quota windows, plus the account rows of that line's
|
|
6
|
+
* pool. The two halves come from different authorities and are merged here:
|
|
7
|
+
*
|
|
8
|
+
* - the account half reads this plugin's own pool objects through ONE generic
|
|
9
|
+
* adapter (every line's pool speaks \`listAccounts\` / \`setPrimary\` /
|
|
10
|
+
* \`setStrategy\`), never over HTTP;
|
|
11
|
+
* - the quota half reads the line's OWN \`/status\` route over loopback HTTP,
|
|
12
|
+
* because each line already normalizes its upstream payload into its own
|
|
13
|
+
* DTO and duplicating those readers here would be a second implementation
|
|
14
|
+
* of the same thing, free to drift.
|
|
15
|
+
*
|
|
16
|
+
* The mix is deliberate: an account list is a local document read (no upstream
|
|
17
|
+
* call, no credential needed), while a quota answer travels through the line's
|
|
18
|
+
* route, which owns its cache, its refresh flight and its error reporting.
|
|
19
|
+
*
|
|
20
|
+
* Two conventions this file fixes once, because a card must not have to know:
|
|
21
|
+
*
|
|
22
|
+
* - EVERY instant here is Unix MILLISECONDS. The lines disagree on the wire
|
|
23
|
+
* (codex states seconds, antigravity and cline-pass state ISO strings,
|
|
24
|
+
* kimi/minimax/qoder/glm/step state milliseconds); the normalizers convert,
|
|
25
|
+
* so a card never guesses a unit from a magnitude.
|
|
26
|
+
* - \`null\` means "nobody measured this", and is never 0. A window that was
|
|
27
|
+
* never read, a plan nobody named, a balance that could not be fetched —
|
|
28
|
+
* all null, all rendered as a placeholder rather than as a zero.
|
|
29
|
+
*/
|
|
30
|
+
import type { AccountAuthStatus, AccountRotationStrategy } from '../../shared/account-pool-contracts.ts';
|
|
31
|
+
/**
|
|
32
|
+
* Provider name this plugin registers under: the BARE package id, without the
|
|
33
|
+
* `@eddyskywalker/` scope.
|
|
34
|
+
*
|
|
35
|
+
* A manifest names a data source or a capability as `<provider>:<id>`, and that
|
|
36
|
+
* whole string has to match the board's id regular expression
|
|
37
|
+
* `^[a-z][a-z0-9.-]{1,39}(?::[a-z][a-z0-9.-]{1,39})?$` — which accepts neither
|
|
38
|
+
* `@` nor `/`. A scoped provider name would therefore be registrable on the host
|
|
39
|
+
* and unreachable from every manifest, so the registration and the manifests
|
|
40
|
+
* must agree on this literal.
|
|
41
|
+
*/
|
|
42
|
+
export declare const WIDGET_BOARD_PROVIDER = "dsh-chatgpt-subscription";
|
|
43
|
+
/**
|
|
44
|
+
* The name a widget manifest writes to reach one of this provider's
|
|
45
|
+
* registrations, e.g. `dsh-chatgpt-subscription:line-card`.
|
|
46
|
+
*
|
|
47
|
+
* @param id - One of the four registration ids below.
|
|
48
|
+
* @returns The `<provider>:<id>` spelling, which is the only one the board resolves.
|
|
49
|
+
*/
|
|
50
|
+
export declare function widgetFullName(id: string): string;
|
|
51
|
+
/** Data source: shape C for the line named by \`props.line\`. */
|
|
52
|
+
export declare const LINE_CARD_DATA_SOURCE_ID = "line-card";
|
|
53
|
+
/** Capability: refresh one line's quota, then answer shape C. */
|
|
54
|
+
export declare const LINE_REFRESH_CAPABILITY_ID = "line-refresh";
|
|
55
|
+
/** Capability: pin one pooled account of one line, then answer shape C. */
|
|
56
|
+
export declare const LINE_ACCOUNT_SWITCH_CAPABILITY_ID = "line-account-switch";
|
|
57
|
+
/** Capability: change one line's rotation strategy, then answer shape C. */
|
|
58
|
+
export declare const LINE_ACCOUNT_STRATEGY_CAPABILITY_ID = "line-account-strategy";
|
|
59
|
+
/** One quota window of a line, already normalized for the card. */
|
|
60
|
+
export interface LineCardWindow {
|
|
61
|
+
/**
|
|
62
|
+
* Display name, e.g. \`5 小时\`.
|
|
63
|
+
*
|
|
64
|
+
* Filled by the line's normalizer whenever the source states it or the
|
|
65
|
+
* window's nominal length makes it inferable; empty when nobody said, in
|
|
66
|
+
* which case the card falls back to its own wording.
|
|
67
|
+
*/
|
|
68
|
+
label: string;
|
|
69
|
+
/** Share of the window consumed, clamped to 0-100. */
|
|
70
|
+
usedPercent: number;
|
|
71
|
+
/** Nominal window length in minutes, when the source stated one. */
|
|
72
|
+
windowMinutes: number | null;
|
|
73
|
+
/** Unix MILLISECONDS the window reopens, when the source stated one. */
|
|
74
|
+
resetsAt: number | null;
|
|
75
|
+
}
|
|
76
|
+
/** Credit balance a line reports beside its windows. */
|
|
77
|
+
export interface LineCardCredits {
|
|
78
|
+
unlimited: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Balance as the line strings it, unit included when the line has one
|
|
81
|
+
* (\`"10.00"\` for provider credits, \`"12.34 USD"\` for a wallet).
|
|
82
|
+
*
|
|
83
|
+
* A string rather than a number on purpose: the units differ per line and a
|
|
84
|
+
* single numeric field would silently invite arithmetic across them.
|
|
85
|
+
*/
|
|
86
|
+
balance: string | null;
|
|
87
|
+
}
|
|
88
|
+
/** Reset credits available to reopen a spent window. */
|
|
89
|
+
export interface LineCardResetCredits {
|
|
90
|
+
available: number;
|
|
91
|
+
/** Unix MILLISECONDS the earliest credit expires, when stated. */
|
|
92
|
+
expiresAt: number | null;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* One line's quota.
|
|
96
|
+
*
|
|
97
|
+
* \`null\` on the card means "this line answered nothing usable" — which is a
|
|
98
|
+
* different statement from "this line has no windows", and the reason the whole
|
|
99
|
+
* object is nullable rather than an empty one.
|
|
100
|
+
*/
|
|
101
|
+
export interface LineCardQuota {
|
|
102
|
+
windows: LineCardWindow[];
|
|
103
|
+
credits: LineCardCredits | null;
|
|
104
|
+
resetCredits: LineCardResetCredits | null;
|
|
105
|
+
/** Unix MILLISECONDS the snapshot was taken, when the line stated one. */
|
|
106
|
+
fetchedAt: number | null;
|
|
107
|
+
/** Whether THIS line's own refresh is running behind the answer. */
|
|
108
|
+
refreshing: boolean;
|
|
109
|
+
/** Why these numbers are missing or old, when the line said so. */
|
|
110
|
+
error: string | null;
|
|
111
|
+
}
|
|
112
|
+
/** One pooled account of this line, as the card renders it. */
|
|
113
|
+
export interface LineCardAccount {
|
|
114
|
+
id: string;
|
|
115
|
+
/** Alias when one is set, then the email, then the id. Never blank. */
|
|
116
|
+
label: string;
|
|
117
|
+
email: string | null;
|
|
118
|
+
primary: boolean;
|
|
119
|
+
/** Plan label the account's own credential states, when it states one. */
|
|
120
|
+
plan: string | null;
|
|
121
|
+
/** Unix MILLISECONDS a 429 cooldown lifts, when one is running. */
|
|
122
|
+
cooldownUntil: number | null;
|
|
123
|
+
authStatus: AccountAuthStatus | null;
|
|
124
|
+
/**
|
|
125
|
+
* Share of THIS account's own newest snapshot, shortest window.
|
|
126
|
+
*
|
|
127
|
+
* Absent together with \`resetsAt\` when the account was never read — a
|
|
128
|
+
* different statement from "nothing used".
|
|
129
|
+
*/
|
|
130
|
+
usedPercent: number | null;
|
|
131
|
+
resetsAt: number | null;
|
|
132
|
+
/**
|
|
133
|
+
* Every window THIS account's own reading stated, shortest first.
|
|
134
|
+
*
|
|
135
|
+
* ABSENT, not empty, on a line with no per-account quota hook: there is
|
|
136
|
+
* nothing per-account to say there, and an empty list would claim "we asked
|
|
137
|
+
* this account and it has no windows". `[]` on a hooked line means exactly
|
|
138
|
+
* that — the read was made and measured nothing — which is why the list is
|
|
139
|
+
* never padded with a 0 % placeholder to look like data.
|
|
140
|
+
*
|
|
141
|
+
* It sits BESIDE `usedPercent` rather than replacing it: that field stays the
|
|
142
|
+
* headline (shortest) window's share, which the card's back face draws as one
|
|
143
|
+
* small bar, while this list is what the account's own detail view opens up.
|
|
144
|
+
*/
|
|
145
|
+
windows?: LineCardWindow[];
|
|
146
|
+
}
|
|
147
|
+
/** Shape C: what \`line-card\` and the three line capabilities answer. */
|
|
148
|
+
export interface LineCardData {
|
|
149
|
+
/** Line id this card reads, e.g. \`codex\`. */
|
|
150
|
+
line: string;
|
|
151
|
+
/** Display name of the line, e.g. \`ChatGPT\`. */
|
|
152
|
+
label: string;
|
|
153
|
+
/** Whether the line holds any credential that could serve a request. */
|
|
154
|
+
signedIn: boolean;
|
|
155
|
+
/** Whether this plugin's pool for the line is installed at all. */
|
|
156
|
+
installed: boolean;
|
|
157
|
+
/** Plan the line is metered on (e.g. \`free\`), when stated. */
|
|
158
|
+
planLabel: string | null;
|
|
159
|
+
/** Signed-in account label, when known. */
|
|
160
|
+
accountLabel: string | null;
|
|
161
|
+
/** Accounts in this line's pool; empty when it has none. */
|
|
162
|
+
accounts: LineCardAccount[];
|
|
163
|
+
activeAccountId: string | null;
|
|
164
|
+
strategy: AccountRotationStrategy;
|
|
165
|
+
quota: LineCardQuota | null;
|
|
166
|
+
/**
|
|
167
|
+
* Why this card cannot show its numbers: the line's interface is
|
|
168
|
+
* unreachable, OR the line reached its upstream and reported a failure.
|
|
169
|
+
*
|
|
170
|
+
* Both cases leave the card with nothing to draw, and both need the same
|
|
171
|
+
* thing from the user (a reason), so they share one field instead of one of
|
|
172
|
+
* them being dropped — a \`quota: null\` alone would say "no data" and lose the
|
|
173
|
+
* sentence that explains it.
|
|
174
|
+
*/
|
|
175
|
+
error: string | null;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The JSON Schema a capability's return value is validated against.
|
|
179
|
+
*
|
|
180
|
+
* Capability outputs only, like the two older shapes: the DATA SOURCE's answer
|
|
181
|
+
* is validated against the \`data\` schema of the card that reads it, which
|
|
182
|
+
* lives in \`widgets/<id>/widget.json\` and is therefore a second declaration of
|
|
183
|
+
* this shape (kept aligned by a test that compares their key sets literally).
|
|
184
|
+
*/
|
|
185
|
+
export declare const LINE_CARD_SCHEMA: Record<string, unknown>;
|
|
186
|
+
/** Arguments of the quota-refresh capability. */
|
|
187
|
+
export declare const LINE_REFRESH_INPUT_SCHEMA: Record<string, unknown>;
|
|
188
|
+
/** Arguments of the account-switch capability. */
|
|
189
|
+
export declare const LINE_ACCOUNT_SWITCH_INPUT_SCHEMA: Record<string, unknown>;
|
|
190
|
+
/** Arguments of the account-strategy capability. */
|
|
191
|
+
export declare const LINE_ACCOUNT_STRATEGY_INPUT_SCHEMA: Record<string, unknown>;
|
|
192
|
+
//# sourceMappingURL=line-contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line-contracts.d.ts","sourceRoot":"","sources":["../../../../src/host/widget-board/line-contracts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAA;AAExG;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,6BAA6B,CAAA;AAE/D;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,iEAAiE;AACjE,eAAO,MAAM,wBAAwB,cAAc,CAAA;AACnD,iEAAiE;AACjE,eAAO,MAAM,0BAA0B,iBAAiB,CAAA;AACxD,2EAA2E;AAC3E,eAAO,MAAM,iCAAiC,wBAAwB,CAAA;AACtE,4EAA4E;AAC5E,eAAO,MAAM,mCAAmC,0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
* 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
|