u-foo 3.0.32 → 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 +1 -1
- package/src/agents/launch/launcher.js +4 -1
- package/src/agents/providers/upstreamTransport.js +8 -0
- package/src/app/cli/run.js +10 -5
- package/src/coordination/bus/index.js +4 -5
- package/src/coordination/bus/inject.js +10 -13
- package/src/coordination/bus/nickname.js +26 -3
- package/src/coordination/bus/subscriber.js +20 -3
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
|
|
package/src/app/cli/run.js
CHANGED
|
@@ -1609,14 +1609,15 @@ async function runCli(argv) {
|
|
|
1609
1609
|
});
|
|
1610
1610
|
bus
|
|
1611
1611
|
.command("inject")
|
|
1612
|
-
.description("Inject
|
|
1612
|
+
.description("Inject explicit raw prompt text into an agent terminal")
|
|
1613
1613
|
.argument("<subscriber>", "Subscriber ID to inject into")
|
|
1614
|
-
.
|
|
1614
|
+
.argument("<text...>", "Prompt text to inject")
|
|
1615
|
+
.action((subscriber, text) => {
|
|
1615
1616
|
const EventBus = require("../../coordination/bus");
|
|
1616
1617
|
const eventBus = new EventBus(process.cwd());
|
|
1617
1618
|
(async () => {
|
|
1618
1619
|
try {
|
|
1619
|
-
await eventBus.inject(subscriber);
|
|
1620
|
+
await eventBus.inject(subscriber, text.join(" "));
|
|
1620
1621
|
} catch (err) {
|
|
1621
1622
|
console.error(err.message);
|
|
1622
1623
|
process.exitCode = 1;
|
|
@@ -1625,7 +1626,7 @@ async function runCli(argv) {
|
|
|
1625
1626
|
});
|
|
1626
1627
|
bus
|
|
1627
1628
|
.command("wake")
|
|
1628
|
-
.description("
|
|
1629
|
+
.description("Send a notify-only wake event without injecting prompt text")
|
|
1629
1630
|
.argument("<target>", "Subscriber ID or nickname")
|
|
1630
1631
|
.option("--reason <reason>", "Wake reason")
|
|
1631
1632
|
.option("--no-shake", "Disable window shake")
|
|
@@ -2448,7 +2449,11 @@ async function runCli(argv) {
|
|
|
2448
2449
|
if (!subscriber) {
|
|
2449
2450
|
throw new Error("inject requires <subscriber-id>");
|
|
2450
2451
|
}
|
|
2451
|
-
|
|
2452
|
+
const text = rest.slice(2).join(" ").trim();
|
|
2453
|
+
if (!text) {
|
|
2454
|
+
throw new Error("inject requires <subscriber-id> <text>");
|
|
2455
|
+
}
|
|
2456
|
+
await eventBus.inject(subscriber, text);
|
|
2452
2457
|
} catch (err) {
|
|
2453
2458
|
console.error(err.message);
|
|
2454
2459
|
process.exitCode = 1;
|
|
@@ -829,7 +829,7 @@ class EventBus {
|
|
|
829
829
|
}
|
|
830
830
|
|
|
831
831
|
/**
|
|
832
|
-
*
|
|
832
|
+
* Notify a local agent without injecting a synthetic prompt.
|
|
833
833
|
*/
|
|
834
834
|
async wake(subscriber, options = {}) {
|
|
835
835
|
this.ensureBus();
|
|
@@ -847,6 +847,7 @@ class EventBus {
|
|
|
847
847
|
throw new Error(`Target "${subscriber}" not found`);
|
|
848
848
|
}
|
|
849
849
|
|
|
850
|
+
const injector = new Injector(this.busDir, this.agentsFile);
|
|
850
851
|
for (const target of targets) {
|
|
851
852
|
const safeName = subscriberToSafeName(target);
|
|
852
853
|
const queueDir = path.join(this.busDir, "queues", safeName);
|
|
@@ -860,10 +861,8 @@ class EventBus {
|
|
|
860
861
|
const countAfter = after.trim() ? after.trim().split(/\r?\n/).length : 0;
|
|
861
862
|
|
|
862
863
|
if (countAfter > countBefore) {
|
|
863
|
-
await sleep(50);
|
|
864
|
-
await this.injector.inject(target, options.command || "");
|
|
865
864
|
if (options.shake !== false) {
|
|
866
|
-
const tty =
|
|
865
|
+
const tty = injector.readTty(target);
|
|
867
866
|
if (tty) shakeTerminalByTty(tty, { skipFrontmost: true });
|
|
868
867
|
}
|
|
869
868
|
}
|
|
@@ -956,7 +955,7 @@ class EventBus {
|
|
|
956
955
|
/**
|
|
957
956
|
* 注入命令到订阅者终端
|
|
958
957
|
*/
|
|
959
|
-
async inject(subscriber, commandOverride
|
|
958
|
+
async inject(subscriber, commandOverride) {
|
|
960
959
|
this.ensureBus();
|
|
961
960
|
const injector = new Injector(this.busDir, this.agentsFile);
|
|
962
961
|
await injector.inject(subscriber, commandOverride);
|
|
@@ -455,23 +455,20 @@ class Injector {
|
|
|
455
455
|
* 2. tmux send-keys(无需权限)
|
|
456
456
|
* 3. Terminal.app/iTerm2 tty lookup(terminal mode fallback)
|
|
457
457
|
*/
|
|
458
|
-
async inject(subscriber, commandOverride
|
|
458
|
+
async inject(subscriber, commandOverride) {
|
|
459
459
|
if (String(subscriber || "").startsWith("ufoo-code:")) {
|
|
460
460
|
throw new Error(`Inject disabled for ${subscriber}. ufoo-code consumes bus internally.`);
|
|
461
461
|
}
|
|
462
462
|
|
|
463
|
-
//
|
|
464
|
-
//
|
|
465
|
-
// -
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
? "ubus"
|
|
473
|
-
: "/ubus"
|
|
474
|
-
);
|
|
463
|
+
// Terminal injection is a delivery adapter for explicit prompt text.
|
|
464
|
+
// Never synthesize a command for an empty payload: doing so turns wake or
|
|
465
|
+
// acknowledgement-adjacent lifecycle activity into a visible user turn.
|
|
466
|
+
const command = commandOverride === undefined || commandOverride === null
|
|
467
|
+
? ""
|
|
468
|
+
: String(commandOverride);
|
|
469
|
+
if (!command.trim()) {
|
|
470
|
+
throw new Error(`Inject requires non-empty prompt text for ${subscriber}`);
|
|
471
|
+
}
|
|
475
472
|
|
|
476
473
|
const meta = this.getAgentMeta(subscriber) || {};
|
|
477
474
|
const launchMode = meta.launch_mode || "";
|
|
@@ -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"
|