codex-slot 0.1.32 → 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.
@@ -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 (!removed) {
45
- throw new Error((0, text_1.bi)(`未找到账号 ${name}`, `Account not found: ${name}`));
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
- console.log((0, text_1.bi)(`已删除账号配置: ${removed.id}`, `Removed account config: ${removed.id}`));
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}`));
@@ -12,6 +12,7 @@ const node_fs_1 = __importDefault(require("node:fs"));
12
12
  const account_store_1 = require("../account-store");
13
13
  const config_1 = require("../config");
14
14
  const login_1 = require("../login");
15
+ const relay_store_1 = require("../relay-store");
15
16
  const state_1 = require("../state");
16
17
  const text_1 = require("../text");
17
18
  /**
@@ -49,7 +50,11 @@ async function loginAccount(slotName) {
49
50
  * @throws 无显式抛出。
50
51
  */
51
52
  function removeAccount(slotName) {
52
- return (0, account_store_1.removeManagedAccount)(slotName);
53
+ const removed = (0, account_store_1.removeManagedAccount)(slotName);
54
+ if (removed) {
55
+ (0, relay_store_1.removeRelaySlot)(slotName);
56
+ }
57
+ return removed;
53
58
  }
54
59
  /**
55
60
  * 列出当前所有受管账号配置。
@@ -74,6 +79,9 @@ function listAccounts() {
74
79
  * @throws 当旧槽位不存在、新槽位已存在或目录迁移失败时抛出异常。
75
80
  */
76
81
  function renameAccount(oldName, newName) {
82
+ if ((0, relay_store_1.findRelaySlot)(oldName) && (0, relay_store_1.findRelaySlot)(newName)) {
83
+ throw new Error((0, text_1.bi)(`中转槽位 ${newName} 已存在`, `Relay slot already exists: ${newName}`));
84
+ }
77
85
  const config = (0, config_1.loadConfig)();
78
86
  const index = config.accounts.findIndex((item) => item.id === oldName);
79
87
  if (index < 0) {
@@ -121,5 +129,8 @@ function renameAccount(oldName, newName) {
121
129
  delete state.scheduler_stats[oldName];
122
130
  }
123
131
  });
132
+ if ((0, relay_store_1.findRelaySlot)(oldName)) {
133
+ (0, relay_store_1.renameRelaySlot)(oldName, newName);
134
+ }
124
135
  return renamedAccount;
125
136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-slot",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "description": "本地 Codex 多账号切换与状态管理工具",
5
5
  "type": "commonjs",
6
6
  "main": "dist/cli.js",