codex-slot 0.1.33 → 0.1.34
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/account-commands.js +15 -3
- package/package.json +1 -1
package/dist/account-commands.js
CHANGED
|
@@ -6,6 +6,7 @@ exports.handleAccountRemove = handleAccountRemove;
|
|
|
6
6
|
exports.handleAccountRemoveCommand = handleAccountRemoveCommand;
|
|
7
7
|
exports.handleAccountRename = handleAccountRename;
|
|
8
8
|
const account_service_1 = require("./app/account-service");
|
|
9
|
+
const relay_store_1 = require("./relay-store");
|
|
9
10
|
const text_1 = require("./text");
|
|
10
11
|
/**
|
|
11
12
|
* 将已有的 Codex HOME 目录中的登录态复制到 cslot 自己的隔离目录并纳入管理。
|
|
@@ -41,10 +42,16 @@ async function handleAccountLogin(name) {
|
|
|
41
42
|
*/
|
|
42
43
|
function handleAccountRemove(name) {
|
|
43
44
|
const removed = (0, account_service_1.removeAccount)(name);
|
|
44
|
-
if (
|
|
45
|
-
|
|
45
|
+
if (removed) {
|
|
46
|
+
console.log((0, text_1.bi)(`已删除账号配置: ${removed.id}`, `Removed account config: ${removed.id}`));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const removedRelay = (0, relay_store_1.removeRelaySlot)(name);
|
|
50
|
+
if (removedRelay) {
|
|
51
|
+
console.log((0, text_1.bi)(`已删除中转槽位: ${removedRelay.name}`, `Relay slot removed: ${removedRelay.name}`));
|
|
52
|
+
return;
|
|
46
53
|
}
|
|
47
|
-
|
|
54
|
+
throw new Error((0, text_1.bi)(`未找到账号或中转槽位 ${name}`, `Account or relay slot not found: ${name}`));
|
|
48
55
|
}
|
|
49
56
|
/**
|
|
50
57
|
* `del` 子命令入口:在未提供 name 时先展示当前已录入账号列表,便于选择。
|
|
@@ -85,6 +92,11 @@ function handleAccountRemoveCommand(name) {
|
|
|
85
92
|
* @throws 当旧槽位不存在、新槽位已存在或目录迁移失败时抛出异常。
|
|
86
93
|
*/
|
|
87
94
|
function handleAccountRename(oldName, newName) {
|
|
95
|
+
if (!(0, account_service_1.listAccounts)().some((account) => account.id === oldName) && (0, relay_store_1.findRelaySlot)(oldName)) {
|
|
96
|
+
const slot = (0, relay_store_1.renameRelaySlot)(oldName, newName);
|
|
97
|
+
console.log((0, text_1.bi)(`已重命名中转槽位: ${oldName} -> ${slot.name}`, `Relay slot renamed: ${oldName} -> ${slot.name}`));
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
88
100
|
const renamed = (0, account_service_1.renameAccount)(oldName, newName);
|
|
89
101
|
console.log((0, text_1.bi)(`已重命名账号: ${oldName} -> ${newName}`, `Renamed account: ${oldName} -> ${newName}`));
|
|
90
102
|
console.log((0, text_1.bi)(`当前目录: ${renamed.codex_home}`, `Current home: ${renamed.codex_home}`));
|