agent-yes 1.132.1 → 1.132.3

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.
@@ -99,6 +99,11 @@
99
99
  "items": { "type": "string" },
100
100
  "description": "Default arguments to always pass to the CLI"
101
101
  },
102
+ "yesArgs": {
103
+ "type": "array",
104
+ "items": { "type": "string" },
105
+ "description": "Arguments appended when -y/--yes is passed: the per-CLI 'yolo' flag (claude: --dangerously-skip-permissions; codex: --dangerously-bypass-approvals-and-sandbox)"
106
+ },
102
107
  "ready": {
103
108
  "type": "array",
104
109
  "items": { "$ref": "#/definitions/RegexSource" },
@@ -2,6 +2,9 @@ clis:
2
2
  claude:
3
3
  promptArg: last-arg
4
4
  systemPrompt: --append-system-prompt
5
+ # yesArgs: appended when `-y` / --yes is passed. The per-CLI "yolo" flag.
6
+ yesArgs:
7
+ - --dangerously-skip-permissions
5
8
  install:
6
9
  powershell: 'powershell -Command "irm https://claude.ai/install.ps1 | iex"'
7
10
  bash: "curl -fsSL https://claude.ai/install.sh | bash"
@@ -96,6 +99,18 @@ clis:
96
99
 
97
100
  codex:
98
101
  promptArg: first-arg
102
+ # yesArgs: `-y` / --yes maps to codex's own "yolo" flag. Codex rejects
103
+ # claude's --dangerously-skip-permissions outright, and its bwrap sandbox
104
+ # cannot initialize inside an already-sandboxed/containerized environment
105
+ # ("bwrap: Failed to make / slave: Permission denied"), blocking command
106
+ # exec AND apply_patch before they run. --dangerously-bypass-approvals-and
107
+ # -sandbox skips both the approval prompts and the sandbox wrapper, which is
108
+ # exactly codex's documented mode for "environments that are externally
109
+ # sandboxed" (the agent-yes-in-a-container case). Invoke as `ay -y codex
110
+ # "<task>"` — agent-yes's own `-y` must precede the cli name (everything
111
+ # after it is forwarded verbatim to codex via trailing_var_arg).
112
+ yesArgs:
113
+ - --dangerously-bypass-approvals-and-sandbox
99
114
  install:
100
115
  npm: "npm install -g @openai/codex@latest"
101
116
  updateAvailable:
@@ -0,0 +1,8 @@
1
+ import "./ts-DPHRmiCs.js";
2
+ import "./logger-CDIsZ-Pp.js";
3
+ import "./versionChecker-DKKMBlh1.js";
4
+ import "./pidStore-fqXqTKkh.js";
5
+ import "./globalPidIndex-DlmmJlO8.js";
6
+ import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-CxjY-iC3.js";
7
+
8
+ export { SUPPORTED_CLIS };
@@ -1,8 +1,8 @@
1
- import { t as CLIS_CONFIG } from "./ts-D9W-U-KX.js";
1
+ import { t as CLIS_CONFIG } from "./ts-DPHRmiCs.js";
2
2
 
3
3
  //#region ts/SUPPORTED_CLIS.ts
4
4
  const SUPPORTED_CLIS = Object.keys(CLIS_CONFIG);
5
5
 
6
6
  //#endregion
7
7
  export { SUPPORTED_CLIS as t };
8
- //# sourceMappingURL=SUPPORTED_CLIS-BPesg_4L.js.map
8
+ //# sourceMappingURL=SUPPORTED_CLIS-CxjY-iC3.js.map
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bun
2
2
  import { t as invokedCliName } from "./invokedCli-zdFbz1ST.js";
3
3
  import { n as logger } from "./logger-CDIsZ-Pp.js";
4
- import { i as versionString, n as displayVersion, r as getInstalledPackage, t as checkAndAutoUpdate } from "./versionChecker-CVnISin2.js";
4
+ import { i as versionString, n as displayVersion, r as getInstalledPackage, t as checkAndAutoUpdate } from "./versionChecker-DKKMBlh1.js";
5
5
  import { argv } from "process";
6
6
  import { execFileSync, spawn } from "child_process";
7
7
  import ms from "ms";
@@ -86,7 +86,7 @@ function parseCliArgs(argv, supportedClis) {
86
86
  default: "yes"
87
87
  }).option("yes", {
88
88
  type: "boolean",
89
- description: "Pass --dangerously-skip-permissions to the CLI (claude shortcut)",
89
+ description: "Pass the CLI's 'yolo' flag (claude: --dangerously-skip-permissions; codex: --dangerously-bypass-approvals-and-sandbox)",
90
90
  default: false,
91
91
  alias: "y"
92
92
  }).option("tray", {
@@ -207,7 +207,8 @@ function parseCliArgs(argv, supportedClis) {
207
207
  cwd: process.cwd(),
208
208
  env: process.env,
209
209
  cli: cliName || parsedArgv.cli || (dashIndex !== 0 ? parsedArgv._[0]?.toString()?.replace?.(/-yes$/, "") : void 0),
210
- cliArgs: [...cliArgsForSpawn, ...parsedArgv.yes ? ["--dangerously-skip-permissions"] : []],
210
+ cliArgs: cliArgsForSpawn,
211
+ skipPermissions: parsedArgv.yes,
211
212
  prompt: [
212
213
  parsedArgv.prompt,
213
214
  positionalPrompt,
@@ -479,7 +480,7 @@ function buildRustArgs(argv, cliFromScript, supportedClis) {
479
480
  const rawArg = process.argv[2];
480
481
  const managerCommands = !invokedCliName(process.argv);
481
482
  const isHelpFlag = rawArg === "-h" || rawArg === "--help";
482
- const { isSubcommand, runSubcommand, cmdHelp } = await import("./subcommands-DNT7eMot.js");
483
+ const { isSubcommand, runSubcommand, cmdHelp } = await import("./subcommands-YAld7NfQ.js");
483
484
  if (isHelpFlag && process.argv.length === 3) {
484
485
  cmdHelp(managerCommands);
485
486
  process.exit(0);
@@ -512,7 +513,7 @@ if (config.useRust) {
512
513
  }
513
514
  }
514
515
  if (rustBinary) {
515
- const { SUPPORTED_CLIS } = await import("./SUPPORTED_CLIS-DjJdQYz6.js");
516
+ const { SUPPORTED_CLIS } = await import("./SUPPORTED_CLIS-8T-zDStW.js");
516
517
  const rustArgs = buildRustArgs(process.argv, config.cli, SUPPORTED_CLIS);
517
518
  if (config.verbose) {
518
519
  console.log(`[rust] Using binary: ${rustBinary}`);
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { a as removeControlCharacters, i as AgentContext, n as agentYes, r as config, t as CLIS_CONFIG } from "./ts-D9W-U-KX.js";
1
+ import { a as removeControlCharacters, i as AgentContext, n as agentYes, r as config, t as CLIS_CONFIG } from "./ts-DPHRmiCs.js";
2
2
  import "./logger-CDIsZ-Pp.js";
3
- import "./versionChecker-CVnISin2.js";
3
+ import "./versionChecker-DKKMBlh1.js";
4
4
  import "./pidStore-fqXqTKkh.js";
5
5
  import "./globalPidIndex-DlmmJlO8.js";
6
6
 
@@ -1,9 +1,9 @@
1
- import "./ts-D9W-U-KX.js";
1
+ import "./ts-DPHRmiCs.js";
2
2
  import "./logger-CDIsZ-Pp.js";
3
- import "./versionChecker-CVnISin2.js";
3
+ import "./versionChecker-DKKMBlh1.js";
4
4
  import "./pidStore-fqXqTKkh.js";
5
5
  import "./globalPidIndex-DlmmJlO8.js";
6
- import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-BPesg_4L.js";
6
+ import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-CxjY-iC3.js";
7
7
  import { n as resolveSpawnCwd } from "./workspaceConfig-BCOqRBEW.js";
8
8
  import { createHash } from "node:crypto";
9
9
 
@@ -141,4 +141,4 @@ async function cmdSchedule(rest) {
141
141
 
142
142
  //#endregion
143
143
  export { cmdSchedule };
144
- //# sourceMappingURL=schedule-aNvMTdRy.js.map
144
+ //# sourceMappingURL=schedule-BU8Wz9Br.js.map
@@ -1,13 +1,13 @@
1
- import "./ts-D9W-U-KX.js";
1
+ import "./ts-DPHRmiCs.js";
2
2
  import "./logger-CDIsZ-Pp.js";
3
- import { r as getInstalledPackage } from "./versionChecker-CVnISin2.js";
3
+ import { r as getInstalledPackage } from "./versionChecker-DKKMBlh1.js";
4
4
  import "./pidStore-fqXqTKkh.js";
5
5
  import { a as updateGlobalPidStatus } from "./globalPidIndex-DlmmJlO8.js";
6
6
  import { t as pgidForWrapper } from "./reaper-C-eWAxIj.js";
7
7
  import "./configShared-C1C04bbq.js";
8
- import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-BPesg_4L.js";
8
+ import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-CxjY-iC3.js";
9
9
  import "./remotes-PKKjfTI1.js";
10
- import { d as listRecords, g as resolveOne, i as controlCodeFromName, m as renderRawLog, p as readNotes, s as extractTaskCounts, x as writeToIpc, y as snapshotStatus } from "./subcommands-M3r5XiOZ.js";
10
+ import { d as listRecords, g as resolveOne, i as controlCodeFromName, m as renderRawLog, p as readNotes, s as extractTaskCounts, x as writeToIpc, y as snapshotStatus } from "./subcommands-B6y__dNM.js";
11
11
  import yargs from "yargs";
12
12
  import { mkdir, open, readFile, stat, writeFile } from "fs/promises";
13
13
  import { homedir, hostname, userInfo } from "os";
@@ -1142,4 +1142,4 @@ Options:
1142
1142
 
1143
1143
  //#endregion
1144
1144
  export { cmdServe };
1145
- //# sourceMappingURL=serve-znyNiZVc.js.map
1145
+ //# sourceMappingURL=serve-Bn6vql66.js.map
@@ -32,7 +32,7 @@ async function cmdSetup(rest) {
32
32
  if (!existsSync(abs)) process.stderr.write(` note: that directory doesn't exist yet — create it, or agents spawned there will fail\n`);
33
33
  if (noShare) return 0;
34
34
  process.stdout.write(`\nsharing this machine to agent-yes.com…\n`);
35
- const { cmdServe } = await import("./serve-znyNiZVc.js");
35
+ const { cmdServe } = await import("./serve-Bn6vql66.js");
36
36
  return cmdServe([
37
37
  "install",
38
38
  "--share",
@@ -42,4 +42,4 @@ async function cmdSetup(rest) {
42
42
 
43
43
  //#endregion
44
44
  export { cmdSetup };
45
- //# sourceMappingURL=setup-BqEV-ogv.js.map
45
+ //# sourceMappingURL=setup-vCSioK7v.js.map
@@ -533,15 +533,15 @@ async function runSubcommand(argv) {
533
533
  case "restart": return await cmdRestart(rest);
534
534
  case "note": return await cmdNote(rest);
535
535
  case "serve": {
536
- const { cmdServe } = await import("./serve-znyNiZVc.js");
536
+ const { cmdServe } = await import("./serve-Bn6vql66.js");
537
537
  return cmdServe(rest);
538
538
  }
539
539
  case "setup": {
540
- const { cmdSetup } = await import("./setup-BqEV-ogv.js");
540
+ const { cmdSetup } = await import("./setup-vCSioK7v.js");
541
541
  return cmdSetup(rest);
542
542
  }
543
543
  case "schedule": {
544
- const { cmdSchedule } = await import("./schedule-aNvMTdRy.js");
544
+ const { cmdSchedule } = await import("./schedule-BU8Wz9Br.js");
545
545
  return cmdSchedule(rest);
546
546
  }
547
547
  case "remote": {
@@ -568,7 +568,10 @@ function cmdHelp(managerCommands = true) {
568
568
  function matchKeyword(record, keyword) {
569
569
  if (!keyword) return true;
570
570
  const kw = keyword.toLowerCase();
571
- if (/^\d+$/.test(keyword) && record.pid === Number(keyword)) return true;
571
+ if (/^\d+$/.test(keyword)) {
572
+ if (record.pid === Number(keyword)) return true;
573
+ return !!(record.agent_id && record.agent_id.toLowerCase().startsWith(kw));
574
+ }
572
575
  if (record.cwd.toLowerCase().includes(kw)) return true;
573
576
  if (record.cli.toLowerCase() === kw) return true;
574
577
  if (record.prompt && record.prompt.toLowerCase().includes(kw)) return true;
@@ -670,6 +673,13 @@ async function resolveOne(keyword, opts) {
670
673
  if (!keyword) throw new Error("keyword required (pid, cwd substring, cli name, or prompt substring)");
671
674
  const matches = await listRecords(keyword, opts);
672
675
  if (matches.length === 0) throw new Error(`no agent matched "${keyword}"`);
676
+ if (/^\d+$/.test(keyword)) {
677
+ const byPid = matches.filter((r) => r.pid === Number(keyword));
678
+ if (byPid.length === 1) return byPid[0];
679
+ }
680
+ const kw = keyword.toLowerCase();
681
+ const byAgentId = matches.filter((r) => r.agent_id && r.agent_id.toLowerCase() === kw);
682
+ if (byAgentId.length === 1) return byAgentId[0];
673
683
  if (matches.length === 1) return matches[0];
674
684
  if (opts.latest) return matches[0];
675
685
  if (process.stderr.isTTY && process.platform !== "win32") try {
@@ -2418,4 +2428,4 @@ async function cmdResultSet(rest) {
2418
2428
 
2419
2429
  //#endregion
2420
2430
  export { resolveReadWindow as _, cursorAbs as a, stopTipForCli as b, finalizedLines as c, listRecords as d, matchKeyword as f, resolveOne as g, renderRawLogLines as h, controlCodeFromName as i, isPidAlive as l, renderRawLog as m, READ_PAGE_DEFAULT as n, extractNeedsInput as o, readNotes as p, cmdHelp as r, extractTaskCounts as s, GRACEFUL_EXIT_COMMANDS as t, isSubcommand as u, runSubcommand as v, writeToIpc as x, snapshotStatus as y };
2421
- //# sourceMappingURL=subcommands-M3r5XiOZ.js.map
2431
+ //# sourceMappingURL=subcommands-B6y__dNM.js.map
@@ -2,6 +2,6 @@ import "./logger-CDIsZ-Pp.js";
2
2
  import "./globalPidIndex-DlmmJlO8.js";
3
3
  import "./configShared-C1C04bbq.js";
4
4
  import "./remotes-PKKjfTI1.js";
5
- import { _ as resolveReadWindow, a as cursorAbs, b as stopTipForCli, c as finalizedLines, d as listRecords, f as matchKeyword, g as resolveOne, h as renderRawLogLines, i as controlCodeFromName, l as isPidAlive, m as renderRawLog, n as READ_PAGE_DEFAULT, o as extractNeedsInput, p as readNotes, r as cmdHelp, s as extractTaskCounts, t as GRACEFUL_EXIT_COMMANDS, u as isSubcommand, v as runSubcommand, x as writeToIpc, y as snapshotStatus } from "./subcommands-M3r5XiOZ.js";
5
+ import { _ as resolveReadWindow, a as cursorAbs, b as stopTipForCli, c as finalizedLines, d as listRecords, f as matchKeyword, g as resolveOne, h as renderRawLogLines, i as controlCodeFromName, l as isPidAlive, m as renderRawLog, n as READ_PAGE_DEFAULT, o as extractNeedsInput, p as readNotes, r as cmdHelp, s as extractTaskCounts, t as GRACEFUL_EXIT_COMMANDS, u as isSubcommand, v as runSubcommand, x as writeToIpc, y as snapshotStatus } from "./subcommands-B6y__dNM.js";
6
6
 
7
7
  export { cmdHelp, isSubcommand, runSubcommand };
@@ -1,5 +1,5 @@
1
1
  import { n as logger, t as addTransport } from "./logger-CDIsZ-Pp.js";
2
- import { r as getInstalledPackage } from "./versionChecker-CVnISin2.js";
2
+ import { r as getInstalledPackage } from "./versionChecker-DKKMBlh1.js";
3
3
  import { t as agentYesHome } from "./agentYesHome-_eJa3DaX.js";
4
4
  import { i as shouldUseLock, r as releaseLock, t as acquireLock } from "./runningLock-V4qvXgAw.js";
5
5
  import { t as PidStore } from "./pidStore-fqXqTKkh.js";
@@ -1090,7 +1090,7 @@ const CLIS_CONFIG = config.clis;
1090
1090
  * });
1091
1091
  * ```
1092
1092
  */
1093
- async function agentYes({ cli, cliArgs = [], prompt, robust = true, cwd, env, exitOnIdle, logFile, removeControlCharactersFromStdout = false, verbose = false, queue = false, install = false, resume = false, useSkills = false, useStdinAppend = false, autoYes = true, idleAction, swarmHint = true }) {
1093
+ async function agentYes({ cli, cliArgs = [], skipPermissions = false, prompt, robust = true, cwd, env, exitOnIdle, logFile, removeControlCharactersFromStdout = false, verbose = false, queue = false, install = false, resume = false, useSkills = false, useStdinAppend = false, autoYes = true, idleAction, swarmHint = true }) {
1094
1094
  if (!cli) throw new Error(`cli is required`);
1095
1095
  const conf = CLIS_CONFIG[cli] || DIE(`Unsupported cli tool: ${cli}, current process.argv: ${process.argv.join(" ")}`);
1096
1096
  const workingDir = cwd ?? process.cwd();
@@ -1126,6 +1126,7 @@ async function agentYes({ cli, cliArgs = [], prompt, robust = true, cwd, env, ex
1126
1126
  if (!!process.env.CLAUDE_PPID) logger.info(`[${cli}-yes] Running as sub-agent (CLAUDE_PPID=${process.env.CLAUDE_PPID})`);
1127
1127
  const cliConf = CLIS_CONFIG[cli] || {};
1128
1128
  cliArgs = cliConf.defaultArgs ? [...cliConf.defaultArgs, ...cliArgs] : cliArgs;
1129
+ if (skipPermissions && cliConf.yesArgs?.length) cliArgs = [...cliArgs, ...cliConf.yesArgs];
1129
1130
  try {
1130
1131
  const workingDir = cwd ?? process.cwd();
1131
1132
  if (useSkills && cli !== "claude") {
@@ -1787,4 +1788,4 @@ function sleep(ms) {
1787
1788
 
1788
1789
  //#endregion
1789
1790
  export { removeControlCharacters as a, AgentContext as i, agentYes as n, config as r, CLIS_CONFIG as t };
1790
- //# sourceMappingURL=ts-D9W-U-KX.js.map
1791
+ //# sourceMappingURL=ts-DPHRmiCs.js.map
@@ -7,7 +7,7 @@ import { fileURLToPath } from "url";
7
7
 
8
8
  //#region package.json
9
9
  var name = "agent-yes";
10
- var version = "1.132.1";
10
+ var version = "1.132.3";
11
11
 
12
12
  //#endregion
13
13
  //#region ts/versionChecker.ts
@@ -215,4 +215,4 @@ async function displayVersion() {
215
215
 
216
216
  //#endregion
217
217
  export { versionString as i, displayVersion as n, getInstalledPackage as r, checkAndAutoUpdate as t };
218
- //# sourceMappingURL=versionChecker-CVnISin2.js.map
218
+ //# sourceMappingURL=versionChecker-DKKMBlh1.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-yes",
3
- "version": "1.132.1",
3
+ "version": "1.132.3",
4
4
  "description": "A wrapper tool that automates interactions with various AI CLI tools by automatically handling common prompts and responses.",
5
5
  "keywords": [
6
6
  "ai",
package/ts/index.ts CHANGED
@@ -44,6 +44,7 @@ export type AgentCliConfig = {
44
44
  version?: string; // hint user for version command to check if installed
45
45
  binary?: string; // actual binary name if different from cli, e.g. cursor -> cursor-agent
46
46
  defaultArgs?: string[]; // function to ensure certain args are present
47
+ yesArgs?: string[]; // appended when `-y`/--yes is passed: the per-CLI "yolo" flag (claude: --dangerously-skip-permissions; codex: --dangerously-bypass-approvals-and-sandbox)
47
48
  help?: string; // documentation/help URL for the CLI
48
49
  bunx?: boolean; // metadata for bunx-based launches
49
50
  systemPrompt?: string; // flag name for system prompt injection
@@ -115,6 +116,7 @@ export const CLIS_CONFIG = config.clis as Record<
115
116
  export default async function agentYes({
116
117
  cli,
117
118
  cliArgs = [],
119
+ skipPermissions = false,
118
120
  prompt,
119
121
  robust = true,
120
122
  cwd,
@@ -134,6 +136,7 @@ export default async function agentYes({
134
136
  }: {
135
137
  cli: keyof typeof CLIS_CONFIG;
136
138
  cliArgs?: string[];
139
+ skipPermissions?: boolean; // if true (`-y`/--yes), append the per-CLI yesArgs ("yolo" flag)
137
140
  prompt?: string;
138
141
  robust?: boolean;
139
142
  cwd?: string;
@@ -217,6 +220,14 @@ export default async function agentYes({
217
220
  const cliConf = (CLIS_CONFIG as Record<string, AgentCliConfig>)[cli] || {};
218
221
  cliArgs = cliConf.defaultArgs ? [...cliConf.defaultArgs, ...cliArgs] : cliArgs;
219
222
 
223
+ // `-y`/--yes appends the per-CLI "yolo" args. Each CLI declares its own:
224
+ // claude → --dangerously-skip-permissions; codex →
225
+ // --dangerously-bypass-approvals-and-sandbox (codex rejects the claude flag,
226
+ // and its bwrap sandbox can't init inside an already-sandboxed container).
227
+ if (skipPermissions && cliConf.yesArgs?.length) {
228
+ cliArgs = [...cliArgs, ...cliConf.yesArgs];
229
+ }
230
+
220
231
  // If enabled, read SKILL.md header and prepend to the prompt for non-Claude agents
221
232
  try {
222
233
  const workingDir = cwd ?? process.cwd();
@@ -115,7 +115,8 @@ export function parseCliArgs(argv: string[], supportedClis?: readonly string[])
115
115
  })
116
116
  .option("yes", {
117
117
  type: "boolean",
118
- description: "Pass --dangerously-skip-permissions to the CLI (claude shortcut)",
118
+ description:
119
+ "Pass the CLI's 'yolo' flag (claude: --dangerously-skip-permissions; codex: --dangerously-bypass-approvals-and-sandbox)",
119
120
  default: false,
120
121
  alias: "y",
121
122
  })
@@ -292,7 +293,10 @@ export function parseCliArgs(argv: string[], supportedClis?: readonly string[])
292
293
  (dashIndex !== 0
293
294
  ? parsedArgv._[0]?.toString()?.replace?.(/-yes$/, "")
294
295
  : undefined)) as string,
295
- cliArgs: [...cliArgsForSpawn, ...(parsedArgv.yes ? ["--dangerously-skip-permissions"] : [])],
296
+ cliArgs: cliArgsForSpawn,
297
+ // `-y`/--yes: the actual flag is per-CLI (see each CLI's `yesArgs` in
298
+ // default.config.yaml). agentYes() appends it once the CLI is resolved.
299
+ skipPermissions: parsedArgv.yes,
296
300
  prompt:
297
301
  [parsedArgv.prompt, positionalPrompt, dashPrompt].filter(Boolean).join(" ") || undefined,
298
302
  install: parsedArgv.install,
@@ -147,6 +147,23 @@ describe("subcommands.matchKeyword", () => {
147
147
  expect(matchKeyword(baseRecord, "9999")).toBe(false);
148
148
  });
149
149
 
150
+ it("treats a numeric keyword as an identity selector (pid or agent_id prefix, no cwd/prompt match)", async () => {
151
+ const { matchKeyword } = await loadModule();
152
+ // pid mentioned inside another agent's prompt/cwd must NOT match by number.
153
+ const r = {
154
+ ...baseRecord,
155
+ pid: 5678,
156
+ prompt: "investigating crash in pid 1234",
157
+ cwd: "/v1/code/proj-1234",
158
+ };
159
+ expect(matchKeyword(r, "1234")).toBe(false); // not this agent's pid, despite cwd/prompt mentions
160
+ expect(matchKeyword(r, "5678")).toBe(true); // its actual pid
161
+ // an all-digit agent_id prefix still resolves (ids are random hex).
162
+ const idr = { ...baseRecord, pid: 5678, agent_id: "206812abcdef" };
163
+ expect(matchKeyword(idr, "206812")).toBe(true); // agent_id prefix
164
+ expect(matchKeyword(idr, "5678")).toBe(true); // pid still wins too
165
+ });
166
+
150
167
  it("matches by cwd substring (case-insensitive)", async () => {
151
168
  const { matchKeyword } = await loadModule();
152
169
  expect(matchKeyword(baseRecord, "agent-yes")).toBe(true);
@@ -188,6 +205,85 @@ describe("subcommands.matchKeyword", () => {
188
205
  });
189
206
  });
190
207
 
208
+ describe("subcommands.resolveOne exact-identity precedence", () => {
209
+ const opts = { all: false, active: false, json: true, latest: true, cwdScope: null };
210
+
211
+ // Regression for the `/w/#room:206812` deep link rendering a sibling's terminal:
212
+ // sharing the URL pastes the pid into other agents' prompts, so a bare pid
213
+ // lookup fuzzily matched them too and the newest-first tiebreak won. Exact pid
214
+ // must beat prompt-substring collisions.
215
+ it("returns the agent whose pid IS the keyword over newer prompt-substring matches", async () => {
216
+ const { resolveOne } = await loadModule();
217
+ const { appendGlobalPid } = await import("./globalPidIndex.ts");
218
+ const now = Date.now();
219
+ const base = {
220
+ cwd: process.cwd(),
221
+ log_file: null,
222
+ status: "active" as const,
223
+ exit_code: null,
224
+ exit_reason: null,
225
+ };
226
+ // The real target — oldest.
227
+ await appendGlobalPid({
228
+ ...base,
229
+ pid: 206812,
230
+ cli: "codex",
231
+ prompt: "do the thing",
232
+ started_at: now - 60_000,
233
+ });
234
+ // Two newer claudes whose prompt embeds the share URL containing "206812".
235
+ await appendGlobalPid({
236
+ ...base,
237
+ pid: 265959,
238
+ cli: "claude",
239
+ prompt: "https://agent-yes.com/w/#r2d058f:206812 is codex agent but renders claude",
240
+ started_at: now - 2_000,
241
+ });
242
+ await appendGlobalPid({
243
+ ...base,
244
+ pid: 239973,
245
+ cli: "claude",
246
+ prompt: "look at https://agent-yes.com/w/#r2d058f:206812",
247
+ started_at: now - 6_000,
248
+ });
249
+
250
+ const record = await resolveOne("206812", opts);
251
+ expect(record.pid).toBe(206812);
252
+ expect(record.cli).toBe("codex");
253
+ });
254
+
255
+ it("returns the agent whose agent_id IS the keyword over prompt-substring matches", async () => {
256
+ const { resolveOne } = await loadModule();
257
+ const { appendGlobalPid } = await import("./globalPidIndex.ts");
258
+ const now = Date.now();
259
+ const base = {
260
+ cwd: process.cwd(),
261
+ log_file: null,
262
+ status: "active" as const,
263
+ exit_code: null,
264
+ exit_reason: null,
265
+ };
266
+ await appendGlobalPid({
267
+ ...base,
268
+ pid: 111,
269
+ cli: "codex",
270
+ prompt: "target",
271
+ agent_id: "a1b2c3d4e5f6",
272
+ started_at: now - 60_000,
273
+ });
274
+ await appendGlobalPid({
275
+ ...base,
276
+ pid: 222,
277
+ cli: "claude",
278
+ prompt: "mentions a1b2c3d4e5f6 in passing",
279
+ started_at: now - 1_000,
280
+ });
281
+
282
+ const record = await resolveOne("a1b2c3d4e5f6", opts);
283
+ expect(record.pid).toBe(111);
284
+ });
285
+ });
286
+
191
287
  describe("subcommands.runSubcommand routing", () => {
192
288
  it("returns null for unknown subcommands so cli.ts falls through", async () => {
193
289
  const { runSubcommand } = await loadModule();
package/ts/subcommands.ts CHANGED
Binary file
@@ -1,8 +0,0 @@
1
- import "./ts-D9W-U-KX.js";
2
- import "./logger-CDIsZ-Pp.js";
3
- import "./versionChecker-CVnISin2.js";
4
- import "./pidStore-fqXqTKkh.js";
5
- import "./globalPidIndex-DlmmJlO8.js";
6
- import { t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-BPesg_4L.js";
7
-
8
- export { SUPPORTED_CLIS };