u-foo 3.1.0 → 3.1.1
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
CHANGED
|
@@ -5,6 +5,7 @@ const fs = require("fs");
|
|
|
5
5
|
const net = require("net");
|
|
6
6
|
const path = require("path");
|
|
7
7
|
const EventBus = require("../../coordination/bus");
|
|
8
|
+
const { isMismatchedAutoNickname } = require("../../coordination/bus/nickname");
|
|
8
9
|
const { isAgentPidAlive } = require("../../coordination/bus/utils");
|
|
9
10
|
const { showBanner } = require("../../ui/format/banner");
|
|
10
11
|
const AgentNotifier = require("./notifier");
|
|
@@ -206,7 +207,9 @@ function findPreviousSession(cwd, agentType, tty, tmuxPane) {
|
|
|
206
207
|
return {
|
|
207
208
|
sessionId: parts[1],
|
|
208
209
|
subscriberId: id,
|
|
209
|
-
nickname: meta.nickname
|
|
210
|
+
nickname: isMismatchedAutoNickname(meta.nickname, agentType)
|
|
211
|
+
? ""
|
|
212
|
+
: (meta.nickname || ""),
|
|
210
213
|
providerSessionId: meta.provider_session_id || "",
|
|
211
214
|
};
|
|
212
215
|
}
|
|
@@ -330,6 +330,7 @@ async function resolveUpstreamRuntime({
|
|
|
330
330
|
return {
|
|
331
331
|
provider: "codex",
|
|
332
332
|
transport: "codex-responses",
|
|
333
|
+
requestProfile: useCodexOAuth ? "codex-subscription" : "openai-responses",
|
|
333
334
|
model: resolvedModel,
|
|
334
335
|
baseUrl,
|
|
335
336
|
credential,
|
|
@@ -472,6 +473,13 @@ async function sendUpstreamRequest({
|
|
|
472
473
|
}
|
|
473
474
|
}
|
|
474
475
|
const requestBody = request && typeof request === "object" ? { ...request } : {};
|
|
476
|
+
// The ChatGPT subscription Codex endpoint is Responses-shaped but does not
|
|
477
|
+
// accept the public Responses API's optional max_output_tokens field. Keep
|
|
478
|
+
// the limit for api.openai.com/API-key traffic and omit it only for the
|
|
479
|
+
// OAuth-backed Codex subscription profile.
|
|
480
|
+
if (isCodexResponses && resolvedRuntime.requestProfile === "codex-subscription") {
|
|
481
|
+
delete requestBody.max_output_tokens;
|
|
482
|
+
}
|
|
475
483
|
if (isKimi) requestBody.model = requestModel;
|
|
476
484
|
const body = JSON.stringify(requestBody);
|
|
477
485
|
|
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 昵称管理和解析
|
|
3
3
|
*/
|
|
4
|
+
const AUTO_NICKNAME_PREFIXES = new Set([
|
|
5
|
+
"claude",
|
|
6
|
+
"codex",
|
|
7
|
+
"agy",
|
|
8
|
+
"grok",
|
|
9
|
+
"kimi",
|
|
10
|
+
"ucode",
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
function resolveAutoNicknamePrefix(agentType = "") {
|
|
14
|
+
const normalized = String(agentType || "").trim().toLowerCase();
|
|
15
|
+
if (normalized === "claude" || normalized === "claude-code") return "claude";
|
|
16
|
+
if (normalized === "ufoo" || normalized === "ucode" || normalized === "ufoo-code") return "ucode";
|
|
17
|
+
return normalized;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function isMismatchedAutoNickname(nickname = "", agentType = "") {
|
|
21
|
+
const match = String(nickname || "").trim().toLowerCase().match(/^([a-z][a-z0-9]*)-(\d+)$/);
|
|
22
|
+
if (!match || !AUTO_NICKNAME_PREFIXES.has(match[1])) return false;
|
|
23
|
+
const expectedPrefix = resolveAutoNicknamePrefix(agentType);
|
|
24
|
+
return Boolean(expectedPrefix && match[1] !== expectedPrefix);
|
|
25
|
+
}
|
|
26
|
+
|
|
4
27
|
class NicknameManager {
|
|
5
28
|
constructor(busData) {
|
|
6
29
|
this.busData = busData;
|
|
@@ -47,9 +70,7 @@ class NicknameManager {
|
|
|
47
70
|
*/
|
|
48
71
|
generateAutoNickname(agentType) {
|
|
49
72
|
const subscribers = this.busData.agents || {};
|
|
50
|
-
const prefix = agentType
|
|
51
|
-
: agentType === "ufoo-code" ? "ucode"
|
|
52
|
-
: agentType;
|
|
73
|
+
const prefix = resolveAutoNicknamePrefix(agentType);
|
|
53
74
|
|
|
54
75
|
// 找出所有相同前缀的昵称
|
|
55
76
|
const existing = Object.values(subscribers)
|
|
@@ -97,3 +118,5 @@ class NicknameManager {
|
|
|
97
118
|
}
|
|
98
119
|
|
|
99
120
|
module.exports = NicknameManager;
|
|
121
|
+
module.exports.isMismatchedAutoNickname = isMismatchedAutoNickname;
|
|
122
|
+
module.exports.resolveAutoNicknamePrefix = resolveAutoNicknamePrefix;
|
|
@@ -2,6 +2,7 @@ const fs = require("fs");
|
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const { getTimestamp, isAgentPidAlive, isMetaActive, isValidTty, getTtyProcessInfo } = require("./utils");
|
|
4
4
|
const NicknameManager = require("./nickname");
|
|
5
|
+
const { isMismatchedAutoNickname } = require("./nickname");
|
|
5
6
|
const { spawnSync } = require("child_process");
|
|
6
7
|
const { appendAgentRegistryDiagnostic } = require("../state/agentRegistryDiagnostics");
|
|
7
8
|
|
|
@@ -185,7 +186,12 @@ class SubscriberManager {
|
|
|
185
186
|
if (metaTty === ttyPath) {
|
|
186
187
|
const sameAgentType = !currentAgentType || meta?.agent_type === currentAgentType;
|
|
187
188
|
// Inherit user-set nickname only when replacing the same agent type.
|
|
188
|
-
if (
|
|
189
|
+
if (
|
|
190
|
+
sameAgentType
|
|
191
|
+
&& meta.nickname
|
|
192
|
+
&& !inheritedNickname
|
|
193
|
+
&& !isMismatchedAutoNickname(meta.nickname, currentAgentType)
|
|
194
|
+
) {
|
|
189
195
|
inheritedNickname = meta.nickname;
|
|
190
196
|
}
|
|
191
197
|
// Remove stale subscriber using same tty
|
|
@@ -236,6 +242,11 @@ class SubscriberManager {
|
|
|
236
242
|
|
|
237
243
|
// 检查是否是重新加入(rejoin)
|
|
238
244
|
const existingMeta = this.busData.agents[subscriber];
|
|
245
|
+
const existingNicknameMismatched = Boolean(
|
|
246
|
+
existingMeta
|
|
247
|
+
&& existingMeta.nickname
|
|
248
|
+
&& isMismatchedAutoNickname(existingMeta.nickname, agentType)
|
|
249
|
+
);
|
|
239
250
|
let finalNickname = nickname;
|
|
240
251
|
let finalScopedNickname = typeof options.scopedNickname === "string"
|
|
241
252
|
? options.scopedNickname.trim()
|
|
@@ -248,7 +259,11 @@ class SubscriberManager {
|
|
|
248
259
|
throw new Error(`Nickname "${nickname}" already exists`);
|
|
249
260
|
}
|
|
250
261
|
finalNickname = nickname;
|
|
251
|
-
} else if (
|
|
262
|
+
} else if (
|
|
263
|
+
existingMeta
|
|
264
|
+
&& existingMeta.nickname
|
|
265
|
+
&& !existingNicknameMismatched
|
|
266
|
+
) {
|
|
252
267
|
// 重新加入,保留原昵称
|
|
253
268
|
finalNickname = existingMeta.nickname;
|
|
254
269
|
finalScopedNickname = existingMeta.scoped_nickname || finalScopedNickname || finalNickname;
|
|
@@ -259,7 +274,9 @@ class SubscriberManager {
|
|
|
259
274
|
}
|
|
260
275
|
|
|
261
276
|
if (!finalScopedNickname) {
|
|
262
|
-
finalScopedNickname =
|
|
277
|
+
finalScopedNickname = existingNicknameMismatched
|
|
278
|
+
? finalNickname
|
|
279
|
+
: (existingMeta?.scoped_nickname || finalNickname);
|
|
263
280
|
}
|
|
264
281
|
|
|
265
282
|
const explicitLaunchMode = typeof options.launchMode === "string"
|