codex: fix CI failure on PR #32000

This commit is contained in:
Adam Perry
2026-07-10 03:34:27 +00:00
parent f6801b5a15
commit 96cfb15695
37 changed files with 228 additions and 179 deletions
+10 -6
View File
@@ -1855,11 +1855,15 @@
]
},
"cwd": {
"description": "Optional working directory to resolve project config layers.",
"type": [
"string",
"null"
]
"anyOf": [
{
"$ref": "#/definitions/LegacyAppPathString"
},
{
"type": "null"
}
],
"description": "Optional working directory to resolve project config layers."
},
"limit": {
"description": "Optional page size; defaults to the full result set.",
@@ -3375,7 +3379,7 @@
"writableRoots": {
"default": [],
"items": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": "array"
}
@@ -1,10 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"AbsolutePathBuf": {
"description": "A path that is guaranteed to be absolute and normalized (though it is not guaranteed to be canonicalized or exist on the filesystem).\n\nIMPORTANT: When deserializing an `AbsolutePathBuf`, a base path must be set using [AbsolutePathBufGuard::new]. If no base path is set, the deserialization will fail unless the path being deserialized is already absolute.",
"type": "string"
},
"AdditionalFileSystemPermissions": {
"properties": {
"entries": {
@@ -95,7 +91,7 @@
"type": "string"
},
"path": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": {
"enum": [
@@ -1,10 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"AbsolutePathBuf": {
"description": "A path that is guaranteed to be absolute and normalized (though it is not guaranteed to be canonicalized or exist on the filesystem).\n\nIMPORTANT: When deserializing an `AbsolutePathBuf`, a base path must be set using [AbsolutePathBufGuard::new]. If no base path is set, the deserialization will fail unless the path being deserialized is already absolute.",
"type": "string"
},
"AdditionalFileSystemPermissions": {
"properties": {
"entries": {
@@ -294,7 +290,7 @@
},
"properties": {
"cwd": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"environmentId": {
"default": null,
@@ -804,7 +804,7 @@
"type": "string"
},
"path": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": {
"enum": [
@@ -1748,7 +1748,7 @@
"type": "string"
},
"cwd": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"source": {
"$ref": "#/definitions/GuardianCommandSource"
@@ -1779,7 +1779,7 @@
"type": "array"
},
"cwd": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"program": {
"type": "string"
@@ -1808,11 +1808,11 @@
{
"properties": {
"cwd": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"files": {
"items": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": "array"
},
@@ -3364,7 +3364,7 @@
"writableRoots": {
"default": [],
"items": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": "array"
}
+2 -6
View File
@@ -1,10 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"AbsolutePathBuf": {
"description": "A path that is guaranteed to be absolute and normalized (though it is not guaranteed to be canonicalized or exist on the filesystem).\n\nIMPORTANT: When deserializing an `AbsolutePathBuf`, a base path must be set using [AbsolutePathBufGuard::new]. If no base path is set, the deserialization will fail unless the path being deserialized is already absolute.",
"type": "string"
},
"AdditionalFileSystemPermissions": {
"properties": {
"entries": {
@@ -164,7 +160,7 @@
"type": "string"
},
"path": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": {
"enum": [
@@ -1628,7 +1624,7 @@
"PermissionsRequestApprovalParams": {
"properties": {
"cwd": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"environmentId": {
"default": null,
@@ -3931,7 +3931,7 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"cwd": {
"$ref": "#/definitions/v2/AbsolutePathBuf"
"$ref": "#/definitions/v2/LegacyAppPathString"
},
"environmentId": {
"default": null,
@@ -7347,7 +7347,7 @@
"type": "string"
},
"path": {
"$ref": "#/definitions/v2/AbsolutePathBuf"
"$ref": "#/definitions/v2/LegacyAppPathString"
},
"type": {
"enum": [
@@ -10523,7 +10523,7 @@
"type": "string"
},
"cwd": {
"$ref": "#/definitions/v2/AbsolutePathBuf"
"$ref": "#/definitions/v2/LegacyAppPathString"
},
"source": {
"$ref": "#/definitions/v2/GuardianCommandSource"
@@ -10554,7 +10554,7 @@
"type": "array"
},
"cwd": {
"$ref": "#/definitions/v2/AbsolutePathBuf"
"$ref": "#/definitions/v2/LegacyAppPathString"
},
"program": {
"type": "string"
@@ -10583,11 +10583,11 @@
{
"properties": {
"cwd": {
"$ref": "#/definitions/v2/AbsolutePathBuf"
"$ref": "#/definitions/v2/LegacyAppPathString"
},
"files": {
"items": {
"$ref": "#/definitions/v2/AbsolutePathBuf"
"$ref": "#/definitions/v2/LegacyAppPathString"
},
"type": "array"
},
@@ -13195,11 +13195,15 @@
]
},
"cwd": {
"description": "Optional working directory to resolve project config layers.",
"type": [
"string",
"null"
]
"anyOf": [
{
"$ref": "#/definitions/v2/LegacyAppPathString"
},
{
"type": "null"
}
],
"description": "Optional working directory to resolve project config layers."
},
"limit": {
"description": "Optional page size; defaults to the full result set.",
@@ -16337,7 +16341,7 @@
"writableRoots": {
"default": [],
"items": {
"$ref": "#/definitions/v2/AbsolutePathBuf"
"$ref": "#/definitions/v2/LegacyAppPathString"
},
"type": "array"
}
@@ -3587,7 +3587,7 @@
"type": "string"
},
"path": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": {
"enum": [
@@ -6874,7 +6874,7 @@
"type": "string"
},
"cwd": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"source": {
"$ref": "#/definitions/GuardianCommandSource"
@@ -6905,7 +6905,7 @@
"type": "array"
},
"cwd": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"program": {
"type": "string"
@@ -6934,11 +6934,11 @@
{
"properties": {
"cwd": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"files": {
"items": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": "array"
},
@@ -9599,11 +9599,15 @@
]
},
"cwd": {
"description": "Optional working directory to resolve project config layers.",
"type": [
"string",
"null"
]
"anyOf": [
{
"$ref": "#/definitions/LegacyAppPathString"
},
{
"type": "null"
}
],
"description": "Optional working directory to resolve project config layers."
},
"limit": {
"description": "Optional page size; defaults to the full result set.",
@@ -12741,7 +12745,7 @@
"writableRoots": {
"default": [],
"items": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": "array"
}
@@ -1,10 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"AbsolutePathBuf": {
"description": "A path that is guaranteed to be absolute and normalized (though it is not guaranteed to be canonicalized or exist on the filesystem).\n\nIMPORTANT: When deserializing an `AbsolutePathBuf`, a base path must be set using [AbsolutePathBufGuard::new]. If no base path is set, the deserialization will fail unless the path being deserialized is already absolute.",
"type": "string"
},
"CommandExecTerminalSize": {
"description": "PTY size in character cells for `command/exec` PTY sessions.",
"properties": {
@@ -27,6 +23,9 @@
],
"type": "object"
},
"LegacyAppPathString": {
"type": "string"
},
"NetworkAccess": {
"enum": [
"restricted",
@@ -120,7 +119,7 @@
"writableRoots": {
"default": [],
"items": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": "array"
}
@@ -82,7 +82,7 @@
"type": "string"
},
"path": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": {
"enum": [
@@ -1,10 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"AbsolutePathBuf": {
"description": "A path that is guaranteed to be absolute and normalized (though it is not guaranteed to be canonicalized or exist on the filesystem).\n\nIMPORTANT: When deserializing an `AbsolutePathBuf`, a base path must be set using [AbsolutePathBufGuard::new]. If no base path is set, the deserialization will fail unless the path being deserialized is already absolute.",
"type": "string"
},
"AdditionalFileSystemPermissions": {
"properties": {
"entries": {
@@ -315,7 +311,7 @@
"type": "string"
},
"cwd": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"source": {
"$ref": "#/definitions/GuardianCommandSource"
@@ -346,7 +342,7 @@
"type": "array"
},
"cwd": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"program": {
"type": "string"
@@ -375,11 +371,11 @@
{
"properties": {
"cwd": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"files": {
"items": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": "array"
},
@@ -1,10 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"AbsolutePathBuf": {
"description": "A path that is guaranteed to be absolute and normalized (though it is not guaranteed to be canonicalized or exist on the filesystem).\n\nIMPORTANT: When deserializing an `AbsolutePathBuf`, a base path must be set using [AbsolutePathBufGuard::new]. If no base path is set, the deserialization will fail unless the path being deserialized is already absolute.",
"type": "string"
},
"AdditionalFileSystemPermissions": {
"properties": {
"entries": {
@@ -308,7 +304,7 @@
"type": "string"
},
"cwd": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"source": {
"$ref": "#/definitions/GuardianCommandSource"
@@ -339,7 +335,7 @@
"type": "array"
},
"cwd": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"program": {
"type": "string"
@@ -368,11 +364,11 @@
{
"properties": {
"cwd": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"files": {
"items": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": "array"
},
@@ -82,7 +82,7 @@
"type": "string"
},
"path": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": {
"enum": [
@@ -1,5 +1,10 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"LegacyAppPathString": {
"type": "string"
}
},
"properties": {
"cursor": {
"description": "Opaque pagination cursor returned by a previous call.",
@@ -9,11 +14,15 @@
]
},
"cwd": {
"description": "Optional working directory to resolve project config layers.",
"type": [
"string",
"null"
]
"anyOf": [
{
"$ref": "#/definitions/LegacyAppPathString"
},
{
"type": "null"
}
],
"description": "Optional working directory to resolve project config layers."
},
"limit": {
"description": "Optional page size; defaults to the full result set.",
@@ -220,7 +220,7 @@
"type": "string"
},
"path": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": {
"enum": [
@@ -301,7 +301,7 @@
"type": "string"
},
"path": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": {
"enum": [
@@ -877,7 +877,7 @@
"writableRoots": {
"default": [],
"items": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": "array"
}
@@ -223,7 +223,7 @@
"type": "string"
},
"path": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": {
"enum": [
@@ -223,7 +223,7 @@
"type": "string"
},
"path": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": {
"enum": [
@@ -223,7 +223,7 @@
"type": "string"
},
"path": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": {
"enum": [
@@ -301,7 +301,7 @@
"type": "string"
},
"path": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": {
"enum": [
@@ -877,7 +877,7 @@
"writableRoots": {
"default": [],
"items": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": "array"
}
@@ -223,7 +223,7 @@
"type": "string"
},
"path": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": {
"enum": [
@@ -99,6 +99,9 @@
],
"type": "object"
},
"LegacyAppPathString": {
"type": "string"
},
"ModeKind": {
"description": "Initial collaboration mode to use when the TUI starts.",
"enum": [
@@ -258,7 +261,7 @@
"writableRoots": {
"default": [],
"items": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": "array"
}
@@ -301,7 +301,7 @@
"type": "string"
},
"path": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": {
"enum": [
@@ -877,7 +877,7 @@
"writableRoots": {
"default": [],
"items": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": "array"
}
@@ -223,7 +223,7 @@
"type": "string"
},
"path": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": {
"enum": [
@@ -223,7 +223,7 @@
"type": "string"
},
"path": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": {
"enum": [
@@ -220,7 +220,7 @@
"type": "string"
},
"path": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": {
"enum": [
@@ -291,7 +291,7 @@
"writableRoots": {
"default": [],
"items": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": "array"
}
@@ -220,7 +220,7 @@
"type": "string"
},
"path": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": {
"enum": [
@@ -220,7 +220,7 @@
"type": "string"
},
"path": {
"$ref": "#/definitions/AbsolutePathBuf"
"$ref": "#/definitions/LegacyAppPathString"
},
"type": {
"enum": [
@@ -1,6 +1,6 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { AbsolutePathBuf } from "../AbsolutePathBuf";
import type { LegacyAppPathString } from "../LegacyAppPathString";
export type CommandAction = { "type": "read", command: string, name: string, path: AbsolutePathBuf, } | { "type": "listFiles", command: string, path: string | null, } | { "type": "search", command: string, query: string | null, path: string | null, } | { "type": "unknown", command: string, };
export type CommandAction = { "type": "read", command: string, name: string, path: LegacyAppPathString, } | { "type": "listFiles", command: string, path: string | null, } | { "type": "search", command: string, query: string | null, path: string | null, } | { "type": "unknown", command: string, };
@@ -1,9 +1,9 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { AbsolutePathBuf } from "../AbsolutePathBuf";
import type { LegacyAppPathString } from "../LegacyAppPathString";
import type { GuardianCommandSource } from "./GuardianCommandSource";
import type { NetworkApprovalProtocol } from "./NetworkApprovalProtocol";
import type { RequestPermissionProfile } from "./RequestPermissionProfile";
export type GuardianApprovalReviewAction = { "type": "command", source: GuardianCommandSource, command: string, cwd: AbsolutePathBuf, } | { "type": "execve", source: GuardianCommandSource, program: string, argv: Array<string>, cwd: AbsolutePathBuf, } | { "type": "applyPatch", cwd: AbsolutePathBuf, files: Array<AbsolutePathBuf>, } | { "type": "networkAccess", target: string, host: string, protocol: NetworkApprovalProtocol, port: number, } | { "type": "mcpToolCall", server: string, toolName: string, connectorId: string | null, connectorName: string | null, toolTitle: string | null, } | { "type": "requestPermissions", reason: string | null, permissions: RequestPermissionProfile, };
export type GuardianApprovalReviewAction = { "type": "command", source: GuardianCommandSource, command: string, cwd: LegacyAppPathString, } | { "type": "execve", source: GuardianCommandSource, program: string, argv: Array<string>, cwd: LegacyAppPathString, } | { "type": "applyPatch", cwd: LegacyAppPathString, files: Array<LegacyAppPathString>, } | { "type": "networkAccess", target: string, host: string, protocol: NetworkApprovalProtocol, port: number, } | { "type": "mcpToolCall", server: string, toolName: string, connectorId: string | null, connectorName: string | null, toolTitle: string | null, } | { "type": "requestPermissions", reason: string | null, permissions: RequestPermissionProfile, };
@@ -1,6 +1,7 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { LegacyAppPathString } from "../LegacyAppPathString";
export type PermissionProfileListParams = {
/**
@@ -14,4 +15,4 @@ limit?: number | null,
/**
* Optional working directory to resolve project config layers.
*/
cwd?: string | null, };
cwd?: LegacyAppPathString | null, };
@@ -1,11 +1,11 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { AbsolutePathBuf } from "../AbsolutePathBuf";
import type { LegacyAppPathString } from "../LegacyAppPathString";
import type { RequestPermissionProfile } from "./RequestPermissionProfile";
export type PermissionsRequestApprovalParams = { threadId: string, turnId: string, itemId: string, environmentId: string | null,
/**
* Unix timestamp (in milliseconds) when this approval request started.
*/
startedAtMs: number, cwd: AbsolutePathBuf, reason: string | null, permissions: RequestPermissionProfile, };
startedAtMs: number, cwd: LegacyAppPathString, reason: string | null, permissions: RequestPermissionProfile, };
@@ -1,7 +1,7 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { AbsolutePathBuf } from "../AbsolutePathBuf";
import type { LegacyAppPathString } from "../LegacyAppPathString";
import type { NetworkAccess } from "./NetworkAccess";
export type SandboxPolicy = { "type": "dangerFullAccess" } | { "type": "readOnly", networkAccess: boolean, } | { "type": "externalSandbox", networkAccess: NetworkAccess, } | { "type": "workspaceWrite", writableRoots: Array<AbsolutePathBuf>, networkAccess: boolean, excludeTmpdirEnvVar: boolean, excludeSlashTmp: boolean, };
export type SandboxPolicy = { "type": "dangerFullAccess" } | { "type": "readOnly", networkAccess: boolean, } | { "type": "externalSandbox", networkAccess: NetworkAccess, } | { "type": "workspaceWrite", writableRoots: Array<LegacyAppPathString>, networkAccess: boolean, excludeTmpdirEnvVar: boolean, excludeSlashTmp: boolean, };
@@ -141,33 +141,40 @@ pub(crate) fn command_actions_for_path_uri(
parsed_cmd: &[ParsedCommand],
cwd: &PathUri,
) -> Vec<CommandAction> {
// TODO(anp): Carry PathUri into CommandAction so foreign Read actions retain resolved paths.
// Until then, omit those actions rather than project a foreign cwd onto the host.
let native_cwd = if cwd.infer_path_convention() == Some(PathConvention::native()) {
cwd.to_abs_path().ok()
} else {
None
};
parsed_cmd
.iter()
.cloned()
.filter_map(|parsed| match parsed {
ParsedCommand::Read { cmd, name, path } => match native_cwd.as_ref() {
Some(native_cwd) => Some(CommandAction::Read {
command: cmd,
name,
path: native_cwd.join(path),
}),
None => {
warn!(
command = cmd,
%cwd,
"omitting read command action whose path cannot be resolved against a foreign cwd"
);
None
ParsedCommand::Read { cmd, name, path } => {
let path = path.to_string_lossy();
let target_convention = cwd.infer_path_convention();
let is_home_relative = path == "~"
|| path.starts_with("~/")
|| (target_convention == Some(PathConvention::Windows)
&& path.starts_with(r"~\"));
let resolved = if is_home_relative {
Err("the target home directory is unavailable from a path URI".to_string())
} else {
cwd.join(path.as_ref()).map_err(|err| err.to_string())
};
match resolved {
Ok(path) => Some(CommandAction::Read {
command: cmd,
name,
path: path.into(),
}),
Err(err) => {
warn!(
command = cmd,
path = %path,
%cwd,
%err,
"omitting read command action whose path cannot be resolved against cwd"
);
None
}
}
},
}
ParsedCommand::ListFiles { cmd, path } => {
Some(CommandAction::ListFiles { command: cmd, path })
}
@@ -227,10 +234,7 @@ pub fn build_item_from_guardian_event(
command: command.clone(),
}]
} else {
parsed_cmd
.into_iter()
.map(|parsed| CommandAction::from_core_with_cwd(parsed, cwd))
.collect()
command_actions_for_path_uri(&parsed_cmd, cwd)
};
Some(ThreadItem::CommandExecution {
id: id.clone(),
@@ -2,17 +2,26 @@ use super::*;
use pretty_assertions::assert_eq;
#[test]
fn foreign_read_is_omitted_without_dropping_other_command_actions() {
fn foreign_read_is_retained_with_other_command_actions() {
#[cfg(windows)]
let cwd = PathUri::parse("file:///usr/local/src").expect("valid foreign POSIX cwd");
#[cfg(not(windows))]
let cwd = PathUri::parse("file:///C:/src").expect("valid foreign Windows cwd");
#[cfg(windows)]
let home_relative_path = "~/secret";
#[cfg(not(windows))]
let home_relative_path = r"~\secret";
let parsed_cmd = vec![
ParsedCommand::Read {
cmd: "cat file.txt".to_string(),
name: "file.txt".to_string(),
path: PathBuf::from("file.txt"),
},
ParsedCommand::Read {
cmd: format!("cat {home_relative_path}"),
name: "secret".to_string(),
path: PathBuf::from(home_relative_path),
},
ParsedCommand::ListFiles {
cmd: "ls".to_string(),
path: Some("subdir".to_string()),
@@ -23,10 +32,18 @@ fn foreign_read_is_omitted_without_dropping_other_command_actions() {
path: Some("src".to_string()),
},
];
let read_path = cwd
.join("file.txt")
.expect("relative path should resolve against foreign cwd");
assert_eq!(
command_actions_for_path_uri(&parsed_cmd, &cwd),
vec![
CommandAction::Read {
command: "cat file.txt".to_string(),
name: "file.txt".to_string(),
path: read_path.into(),
},
CommandAction::ListFiles {
command: "ls".to_string(),
path: Some("subdir".to_string()),
@@ -41,8 +41,8 @@ use codex_protocol::protocol::PatchApplyStatus as CorePatchApplyStatus;
use codex_protocol::protocol::ReviewDecision as CoreReviewDecision;
use codex_protocol::protocol::SubAgentActivityKind as CoreSubAgentActivityKind;
use codex_shell_command::parse_command::shlex_join;
use codex_utils_absolute_path::AbsolutePathBuf;
use codex_utils_path_uri::LegacyAppPathString;
use codex_utils_path_uri::PathUri;
use schemars::JsonSchema;
use serde::Deserialize;
use serde::Serialize;
@@ -121,7 +121,7 @@ pub enum CommandAction {
Read {
command: String,
name: String,
path: AbsolutePathBuf,
path: LegacyAppPathString,
},
ListFiles {
command: String,
@@ -185,7 +185,7 @@ impl CommandAction {
} => CoreParsedCommand::Read {
cmd,
name,
path: path.into_path_buf(),
path: PathBuf::from(path.into_string()),
},
CommandAction::ListFiles { command: cmd, path } => {
CoreParsedCommand::ListFiles { cmd, path }
@@ -199,12 +199,15 @@ impl CommandAction {
}
}
pub fn from_core_with_cwd(value: CoreParsedCommand, cwd: &AbsolutePathBuf) -> Self {
pub fn from_core_with_cwd(value: CoreParsedCommand, cwd: &PathUri) -> Self {
match value {
CoreParsedCommand::Read { cmd, name, path } => CommandAction::Read {
command: cmd,
name,
path: cwd.join(path),
path: cwd
.join(path.to_string_lossy().as_ref())
.map(LegacyAppPathString::from)
.unwrap_or_else(|_| LegacyAppPathString::from_path(&path)),
},
CoreParsedCommand::ListFiles { cmd, path } => {
CommandAction::ListFiles { command: cmd, path }
@@ -558,7 +561,7 @@ impl From<GuardianCommandSource> for CoreGuardianCommandSource {
pub struct GuardianCommandReviewAction {
pub source: GuardianCommandSource,
pub command: String,
pub cwd: AbsolutePathBuf,
pub cwd: LegacyAppPathString,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
@@ -568,15 +571,15 @@ pub struct GuardianExecveReviewAction {
pub source: GuardianCommandSource,
pub program: String,
pub argv: Vec<String>,
pub cwd: AbsolutePathBuf,
pub cwd: LegacyAppPathString,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct GuardianApplyPatchReviewAction {
pub cwd: AbsolutePathBuf,
pub files: Vec<AbsolutePathBuf>,
pub cwd: LegacyAppPathString,
pub files: Vec<LegacyAppPathString>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
@@ -618,7 +621,7 @@ pub enum GuardianApprovalReviewAction {
Command {
source: GuardianCommandSource,
command: String,
cwd: AbsolutePathBuf,
cwd: LegacyAppPathString,
},
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
@@ -626,13 +629,13 @@ pub enum GuardianApprovalReviewAction {
source: GuardianCommandSource,
program: String,
argv: Vec<String>,
cwd: AbsolutePathBuf,
cwd: LegacyAppPathString,
},
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
ApplyPatch {
cwd: AbsolutePathBuf,
files: Vec<AbsolutePathBuf>,
cwd: LegacyAppPathString,
files: Vec<LegacyAppPathString>,
},
#[serde(rename_all = "camelCase")]
#[ts(rename_all = "camelCase")]
@@ -669,7 +672,7 @@ impl From<CoreGuardianAssessmentAction> for GuardianApprovalReviewAction {
} => Self::Command {
source: source.into(),
command,
cwd,
cwd: cwd.into(),
},
CoreGuardianAssessmentAction::Execve {
source,
@@ -680,11 +683,12 @@ impl From<CoreGuardianAssessmentAction> for GuardianApprovalReviewAction {
source: source.into(),
program,
argv,
cwd,
cwd: cwd.into(),
},
CoreGuardianAssessmentAction::ApplyPatch { cwd, files } => Self::ApplyPatch {
cwd: cwd.into(),
files: files.into_iter().map(Into::into).collect(),
},
CoreGuardianAssessmentAction::ApplyPatch { cwd, files } => {
Self::ApplyPatch { cwd, files }
}
CoreGuardianAssessmentAction::NetworkAccess {
target,
host,
@@ -732,7 +736,9 @@ impl TryFrom<GuardianApprovalReviewAction> for CoreGuardianAssessmentAction {
} => Self::Command {
source: source.into(),
command,
cwd,
cwd: cwd
.try_into()
.map_err(|err| io::Error::new(io::ErrorKind::InvalidInput, err))?,
},
GuardianApprovalReviewAction::Execve {
source,
@@ -743,11 +749,22 @@ impl TryFrom<GuardianApprovalReviewAction> for CoreGuardianAssessmentAction {
source: source.into(),
program,
argv,
cwd,
cwd: cwd
.try_into()
.map_err(|err| io::Error::new(io::ErrorKind::InvalidInput, err))?,
},
GuardianApprovalReviewAction::ApplyPatch { cwd, files } => Self::ApplyPatch {
cwd: cwd
.try_into()
.map_err(|err| io::Error::new(io::ErrorKind::InvalidInput, err))?,
files: files
.into_iter()
.map(|path| {
path.try_into()
.map_err(|err| io::Error::new(io::ErrorKind::InvalidInput, err))
})
.collect::<io::Result<_>>()?,
},
GuardianApprovalReviewAction::ApplyPatch { cwd, files } => {
Self::ApplyPatch { cwd, files }
}
GuardianApprovalReviewAction::NetworkAccess {
target,
host,
@@ -488,7 +488,7 @@ fn permissions_request_approval_uses_request_permission_profile() {
}))
.expect("permissions request should deserialize");
assert_eq!(params.cwd, absolute_path("repo"));
assert_eq!(params.cwd, absolute_path("repo").into());
assert_eq!(params.environment_id.as_deref(), Some("remote"));
assert_eq!(
params.permissions,
@@ -519,14 +519,14 @@ fn permissions_request_approval_uses_request_permission_profile() {
enabled: Some(true),
}),
file_system: Some(CoreFileSystemPermissions::from_read_write_roots(
Some(vec![
AbsolutePathBuf::try_from(PathBuf::from(read_only_path))
Some(vec![PathUri::from_abs_path(
&AbsolutePathBuf::try_from(PathBuf::from(read_only_path))
.expect("path must be absolute"),
]),
Some(vec![
AbsolutePathBuf::try_from(PathBuf::from(read_write_path))
)]),
Some(vec![PathUri::from_abs_path(
&AbsolutePathBuf::try_from(PathBuf::from(read_write_path))
.expect("path must be absolute"),
]),
)]),
)),
}
);
@@ -565,7 +565,7 @@ fn permissions_request_approval_rejects_macos_permissions() {
#[test]
fn additional_file_system_permissions_preserves_canonical_entries() {
let core_permissions = CoreFileSystemPermissions {
let core_permissions: CoreFileSystemPermissions<PathUri> = CoreFileSystemPermissions {
entries: vec![
CoreFileSystemSandboxEntry {
path: CoreFileSystemPath::Special {
@@ -617,10 +617,11 @@ fn additional_file_system_permissions_preserves_canonical_entries() {
fn additional_file_system_permissions_populates_entries_for_legacy_roots() {
let read_only_path = absolute_path("read-only");
let read_write_path = absolute_path("read-write");
let core_permissions = CoreFileSystemPermissions::from_read_write_roots(
Some(vec![read_only_path.clone()]),
Some(vec![read_write_path.clone()]),
);
let core_permissions: CoreFileSystemPermissions<PathUri> =
CoreFileSystemPermissions::from_read_write_roots(
Some(vec![PathUri::from_abs_path(&read_only_path)]),
Some(vec![PathUri::from_abs_path(&read_write_path)]),
);
let permissions = AdditionalFileSystemPermissions::from(core_permissions.clone());
let read_only_api_path = LegacyAppPathString::from_abs_path(&read_only_path);
@@ -740,14 +741,14 @@ fn permissions_request_approval_response_uses_granted_permission_profile_without
enabled: Some(true),
}),
file_system: Some(CoreFileSystemPermissions::from_read_write_roots(
Some(vec![
AbsolutePathBuf::try_from(PathBuf::from(read_only_path))
Some(vec![PathUri::from_abs_path(
&AbsolutePathBuf::try_from(PathBuf::from(read_only_path))
.expect("path must be absolute"),
]),
Some(vec![
AbsolutePathBuf::try_from(PathBuf::from(read_write_path))
)]),
Some(vec![PathUri::from_abs_path(
&AbsolutePathBuf::try_from(PathBuf::from(read_write_path))
.expect("path must be absolute"),
]),
)]),
)),
}
);
@@ -1593,7 +1594,9 @@ fn sandbox_policy_round_trips_external_sandbox_network_access() {
network_access: NetworkAccess::Enabled,
};
let core_policy = v2_policy.to_core();
let core_policy = v2_policy
.try_to_core()
.expect("convert external sandbox policy to core");
assert_eq!(
core_policy,
codex_protocol::protocol::SandboxPolicy::ExternalSandbox {
@@ -1611,7 +1614,9 @@ fn sandbox_policy_round_trips_read_only_network_access() {
network_access: true,
};
let core_policy = v2_policy.to_core();
let core_policy = v2_policy
.try_to_core()
.expect("convert read-only sandbox policy to core");
assert_eq!(
core_policy,
codex_protocol::protocol::SandboxPolicy::ReadOnly {
@@ -2286,7 +2291,9 @@ fn sandbox_policy_round_trips_workspace_write_access() {
exclude_slash_tmp: false,
};
let core_policy = v2_policy.to_core();
let core_policy = v2_policy
.try_to_core()
.expect("convert workspace-write sandbox policy to core");
assert_eq!(
core_policy,
codex_protocol::protocol::SandboxPolicy::WorkspaceWrite {
@@ -2336,7 +2343,7 @@ fn sandbox_policy_deserializes_legacy_workspace_write_full_access_field() {
assert_eq!(
policy,
SandboxPolicy::WorkspaceWrite {
writable_roots: vec![absolute_path("/workspace")],
writable_roots: vec![absolute_path("/workspace").into()],
network_access: true,
exclude_tmpdir_env_var: true,
exclude_slash_tmp: true,
@@ -2412,7 +2419,7 @@ fn guardian_approval_review_action_round_trips_command_shape() {
GuardianApprovalReviewAction::Command {
source: GuardianCommandSource::Shell,
command: "rm -rf /tmp/example.sqlite".to_string(),
cwd: absolute_path("tmp"),
cwd: absolute_path("tmp").into(),
}
);
assert_eq!(