agent-yes 1.190.0 → 1.192.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/ts/subcommands.ts CHANGED
@@ -11,6 +11,7 @@
11
11
  * to the normal agent-spawning flow.
12
12
  */
13
13
 
14
+ import { randomBytes } from "crypto";
14
15
  import { appendFile, mkdir, open, readFile, stat, writeFile } from "fs/promises";
15
16
  import ms from "ms";
16
17
  import { homedir } from "os";
@@ -2653,7 +2654,7 @@ async function cmdSpawn(rest: string[]): Promise<number> {
2653
2654
  * (`send`, `key`, `select`): refuse a self-targeting loop, and require that THIS
2654
2655
  * sender actually looked at THIS target recently — an agent is blocked, an
2655
2656
  * interactive human is only warned — unless `force`. Returns the sender context
2656
- * so a caller can reuse it (e.g. `send`'s `[from …]` prefix). Extracted from
2657
+ * so a caller can reuse it (e.g. `send`'s `[ay-msg …]` header). Extracted from
2657
2658
  * cmdSend so the action commands enforce the identical guard.
2658
2659
  */
2659
2660
  async function enforceSendGuards(
@@ -2962,13 +2963,21 @@ async function cmdSend(rest: string[]): Promise<number> {
2962
2963
  // prefix would bump it to line 2 and the CLI would type the command as plain
2963
2964
  // text. So skip the prefix for a command body and send it verbatim —
2964
2965
  // attribution is dropped for the command, but it actually runs.
2966
+ // The header/footer pair shares a random nonce so the recipient can trust the
2967
+ // block's boundaries: text INSIDE the body can't forge a matching open/close
2968
+ // marker (the nonce is generated here, after the body was authored), so a
2969
+ // spoofed "[from …]" line or a premature "[/ay-msg]" embedded in a message
2970
+ // can't impersonate another sender or truncate/extend the trusted region.
2965
2971
  const replyTarget = sender.agent?.agent_id || sender.agent?.pid;
2966
- const prefix =
2967
- sender.agent && !isSlashCommand(body)
2968
- ? `[from ${sender.agent.cli} #${sender.agent.pid} @ ${shortenPath(sender.agent.cwd)} — reply: ay send ${replyTarget} "..."]\n`
2969
- : "";
2972
+ let prefix = "";
2973
+ let suffix = "";
2974
+ if (sender.agent && !isSlashCommand(body)) {
2975
+ const nonce = randomBytes(4).toString("hex");
2976
+ prefix = `[ay-msg ${nonce} from ${sender.agent.cli} #${sender.agent.pid} @ ${shortenPath(sender.agent.cwd)} — reply: ay send ${replyTarget} "..."]\n`;
2977
+ suffix = `\n[/ay-msg ${nonce}]`;
2978
+ }
2970
2979
 
2971
- const fullBody = prefix + body;
2980
+ const fullBody = prefix + body + suffix;
2972
2981
  const noWait = Boolean(argv.noWait) || process.env.AGENT_YES_SEND_NO_WAIT === "1";
2973
2982
 
2974
2983
  // Back off while the user is typing at the target's terminal — injecting our
@@ -1,8 +0,0 @@
1
- import "./ts-CeGEhsC9.js";
2
- import "./logger-CDIsZ-Pp.js";
3
- import "./versionChecker-DXwf5ip7.js";
4
- import "./pidStore-BIvsBQ8X.js";
5
- import "./globalPidIndex-CoNr7tS8.js";
6
- import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-BB7Br0fS.js";
7
-
8
- export { SUPPORTED_CLIS };