@coda-console/codex 1.8.2 → 1.8.3
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/package.json +1 -1
- package/scripts/quota.mjs +5 -7
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"id": "codex",
|
|
4
4
|
"displayName": "Codex",
|
|
5
5
|
"description": "Codex Agent:Coda 自带的入口运行 codex-acp,报告子 Agent 与后台命令。额度与登录由账号来源插件接管;未接入账号来源时使用 Codex 自己的登录面板。",
|
|
6
|
-
"version": "1.8.
|
|
6
|
+
"version": "1.8.3",
|
|
7
7
|
"categories": ["Agent"],
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@agentclientprotocol/codex-acp": "1.12.0",
|
package/scripts/quota.mjs
CHANGED
|
@@ -15,11 +15,9 @@ const identity = (account, workspace) => {
|
|
|
15
15
|
return email && typeof workspace === 'string' && workspace ? { identity: `codex:${hash(`${email}\n${hash(workspace)}`)}` } : {};
|
|
16
16
|
};
|
|
17
17
|
const unixTime = value => typeof value === 'number' && Number.isFinite(new Date(value * 1000).getTime()) ? new Date(value * 1000).toISOString() : null;
|
|
18
|
-
// A credit's expiry
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return `${d.getUTCFullYear()}/${String(d.getUTCMonth() + 1).padStart(2, '0')}/${String(d.getUTCDate()).padStart(2, '0')} ${d.getUTCHours()}:${String(d.getUTCMinutes()).padStart(2, '0')}`;
|
|
22
|
-
}
|
|
18
|
+
// A credit's expiry in a figure's text: a time mark, which each client writes in its own time zone (Coda's
|
|
19
|
+
// docs/agent-protocol.md「文字里的时刻」).
|
|
20
|
+
const mark = seconds => `<t:${unixTime(seconds)}>`;
|
|
23
21
|
|
|
24
22
|
// A bar per window of each limit, of what is left. A limit's name is said only when there are several.
|
|
25
23
|
export function windows(result) {
|
|
@@ -54,11 +52,11 @@ export function card(account, result, workspace) {
|
|
|
54
52
|
const items = windows(result), resets = credits(result);
|
|
55
53
|
if (resets) {
|
|
56
54
|
const first = resets.listed[0];
|
|
57
|
-
const lines = resets.listed.map((c, i) => ({ type: 'stat', label: `第 ${i + 1} 次`, value: c.expiresAt == null ? '不会过期' : `${
|
|
55
|
+
const lines = resets.listed.map((c, i) => ({ type: 'stat', label: `第 ${i + 1} 次`, value: c.expiresAt == null ? '不会过期' : `${mark(c.expiresAt)} 到期` }));
|
|
58
56
|
const room = CARD_ITEMS - items.length - (first ? 2 : 1);
|
|
59
57
|
items.push({ type: 'stat', label: '完全重置', value: `剩余 ${resets.count} 次` }, ...lines.slice(0, Math.max(0, room)));
|
|
60
58
|
if (first && resets.count > 0) items.unshift({ type: 'button', label: '使用完全重置', action: 'reset', args: { creditId: first.id },
|
|
61
|
-
confirm: `使用 ${line(name, 60)} 的完全重置?\n用最早到期的那一次(${first.expiresAt == null ? '不会过期' : `${
|
|
59
|
+
confirm: `使用 ${line(name, 60)} 的完全重置?\n用最早到期的那一次(${first.expiresAt == null ? '不会过期' : `${mark(first.expiresAt)} 到期`})。成功后消耗 1 次,无法撤销。` });
|
|
62
60
|
}
|
|
63
61
|
if (!items.length) items.push({ type: 'error', text: '暂时无法获取额度:Codex 没有给出额度窗口' });
|
|
64
62
|
return { type: 'card', title: name, ...(line(account.planType) ? { subtitle: line(account.planType) } : {}), ...identity(account, workspace), items: items.slice(0, CARD_ITEMS) };
|