u-foo 3.0.32 → 3.1.0
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
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 || "";
|