Show only commands in Codex shell tool calls (#2029)
* fix(codex): hide shell launchers from command summaries Codex only unwrapped POSIX shells from /bin. Commands launched through /usr/bin/zsh therefore exposed the wrapper in the tool-call row. * test(codex): preserve shell wrapper path coverage
This commit is contained in:
@@ -51,23 +51,26 @@ describe("codex tool-call mapper", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("unwraps shell wrapper strings for commandExecution", () => {
|
it.each(['/bin/zsh -lc "echo hello"', '/usr/bin/zsh -lc "echo hello"'])(
|
||||||
const item = expectMapped(
|
"unwraps zsh wrapper strings for commandExecution: %s",
|
||||||
mapCodexToolCallFromThreadItem({
|
(command) => {
|
||||||
type: "commandExecution",
|
const item = expectMapped(
|
||||||
id: "codex-call-wrapper-string",
|
mapCodexToolCallFromThreadItem({
|
||||||
status: "running",
|
type: "commandExecution",
|
||||||
command: '/bin/zsh -lc "echo hello"',
|
id: "codex-call-wrapper-string",
|
||||||
cwd: "/tmp/repo",
|
status: "running",
|
||||||
}),
|
command,
|
||||||
);
|
cwd: "/tmp/repo",
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
expect(item.detail).toEqual({
|
expect(item.detail).toEqual({
|
||||||
type: "shell",
|
type: "shell",
|
||||||
command: "echo hello",
|
command: "echo hello",
|
||||||
cwd: "/tmp/repo",
|
cwd: "/tmp/repo",
|
||||||
});
|
});
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
it("unwraps pwsh wrapper strings for commandExecution on Windows", () => {
|
it("unwraps pwsh wrapper strings for commandExecution on Windows", () => {
|
||||||
const item = expectMapped(
|
const item = expectMapped(
|
||||||
|
|||||||
@@ -221,7 +221,9 @@ const CodexThreadItemSchema = z.discriminatedUnion("type", [
|
|||||||
|
|
||||||
function maybeUnwrapShellWrapperCommand(command: string): string {
|
function maybeUnwrapShellWrapperCommand(command: string): string {
|
||||||
const trimmed = command.trim();
|
const trimmed = command.trim();
|
||||||
const unixWrapperMatch = trimmed.match(/^(?:\/bin\/)?(?:zsh|bash|sh)\s+-(?:lc|c)\s+([\s\S]+)$/);
|
const unixWrapperMatch = trimmed.match(
|
||||||
|
/^(?:(?:\/[^/\s]+)*\/)?(?:zsh|bash|sh)\s+-(?:lc|c)\s+([\s\S]+)$/,
|
||||||
|
);
|
||||||
if (unixWrapperMatch) {
|
if (unixWrapperMatch) {
|
||||||
const candidate = unixWrapperMatch[1]?.trim() ?? "";
|
const candidate = unixWrapperMatch[1]?.trim() ?? "";
|
||||||
if (!candidate) {
|
if (!candidate) {
|
||||||
|
|||||||
Reference in New Issue
Block a user