codex: pass cwd through sandboxed fs ops

This commit is contained in:
starr-openai
2026-04-06 16:40:53 -07:00
parent 3aa46997c0
commit fc86503a4e
30 changed files with 1169 additions and 56 deletions
@@ -663,6 +663,17 @@
"FsCopyParams": {
"description": "Copy a file or directory tree on the host filesystem.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"destinationPath": {
"allOf": [
{
@@ -693,6 +704,17 @@
"FsCreateDirectoryParams": {
"description": "Create a directory on the host filesystem.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"path": {
"allOf": [
{
@@ -717,6 +739,17 @@
"FsGetMetadataParams": {
"description": "Request metadata for an absolute path.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"path": {
"allOf": [
{
@@ -734,6 +767,17 @@
"FsReadDirectoryParams": {
"description": "List direct child names for a directory.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"path": {
"allOf": [
{
@@ -751,6 +795,17 @@
"FsReadFileParams": {
"description": "Read a file from the host filesystem.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"path": {
"allOf": [
{
@@ -768,6 +823,17 @@
"FsRemoveParams": {
"description": "Remove a file or directory tree from the host filesystem.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"force": {
"description": "Whether missing paths should be ignored. Defaults to `true`.",
"type": [
@@ -829,6 +895,17 @@
"FsWriteFileParams": {
"description": "Write a file on the host filesystem.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"dataBase64": {
"description": "File contents encoded as base64.",
"type": "string"
@@ -7502,6 +7502,17 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Copy a file or directory tree on the host filesystem.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/v2/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"destinationPath": {
"allOf": [
{
@@ -7540,6 +7551,17 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Create a directory on the host filesystem.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/v2/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"path": {
"allOf": [
{
@@ -7572,6 +7594,17 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Request metadata for an absolute path.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/v2/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"path": {
"allOf": [
{
@@ -7646,6 +7679,17 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "List direct child names for a directory.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/v2/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"path": {
"allOf": [
{
@@ -7683,6 +7727,17 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Read a file from the host filesystem.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/v2/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"path": {
"allOf": [
{
@@ -7717,6 +7772,17 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Remove a file or directory tree from the host filesystem.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/v2/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"force": {
"description": "Whether missing paths should be ignored. Defaults to `true`.",
"type": [
@@ -7820,6 +7886,17 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Write a file on the host filesystem.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/v2/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"dataBase64": {
"description": "File contents encoded as base64.",
"type": "string"
@@ -4170,6 +4170,17 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Copy a file or directory tree on the host filesystem.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"destinationPath": {
"allOf": [
{
@@ -4208,6 +4219,17 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Create a directory on the host filesystem.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"path": {
"allOf": [
{
@@ -4240,6 +4262,17 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Request metadata for an absolute path.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"path": {
"allOf": [
{
@@ -4314,6 +4347,17 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "List direct child names for a directory.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"path": {
"allOf": [
{
@@ -4351,6 +4395,17 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Read a file from the host filesystem.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"path": {
"allOf": [
{
@@ -4385,6 +4440,17 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Remove a file or directory tree from the host filesystem.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"force": {
"description": "Whether missing paths should be ignored. Defaults to `true`.",
"type": [
@@ -4488,6 +4554,17 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Write a file on the host filesystem.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"dataBase64": {
"description": "File contents encoded as base64.",
"type": "string"
@@ -8,6 +8,17 @@
},
"description": "Copy a file or directory tree on the host filesystem.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"destinationPath": {
"allOf": [
{
@@ -8,6 +8,17 @@
},
"description": "Create a directory on the host filesystem.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"path": {
"allOf": [
{
@@ -8,6 +8,17 @@
},
"description": "Request metadata for an absolute path.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"path": {
"allOf": [
{
@@ -8,6 +8,17 @@
},
"description": "List direct child names for a directory.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"path": {
"allOf": [
{
@@ -8,6 +8,17 @@
},
"description": "Read a file from the host filesystem.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"path": {
"allOf": [
{
@@ -8,6 +8,17 @@
},
"description": "Remove a file or directory tree from the host filesystem.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"force": {
"description": "Whether missing paths should be ignored. Defaults to `true`.",
"type": [
@@ -8,6 +8,17 @@
},
"description": "Write a file on the host filesystem.",
"properties": {
"cwd": {
"anyOf": [
{
"$ref": "#/definitions/AbsolutePathBuf"
},
{
"type": "null"
}
],
"description": "Optional cwd to resolve legacy sandbox workspace roots against."
},
"dataBase64": {
"description": "File contents encoded as base64.",
"type": "string"
@@ -2,20 +2,29 @@
// 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 { SandboxPolicy } from "./SandboxPolicy";
/**
* Copy a file or directory tree on the host filesystem.
*/
export type FsCopyParams = {
export type FsCopyParams = {
/**
* Absolute source path.
*/
sourcePath: AbsolutePathBuf,
sourcePath: AbsolutePathBuf,
/**
* Absolute destination path.
*/
destinationPath: AbsolutePathBuf,
destinationPath: AbsolutePathBuf,
/**
* Required for directory copies; ignored for file copies.
*/
recursive?: boolean, };
recursive?: boolean,
/**
* Optional sandbox policy for this filesystem copy.
*/
sandboxPolicy?: SandboxPolicy | null,
/**
* Optional cwd to resolve legacy sandbox workspace roots against.
*/
cwd?: AbsolutePathBuf | null, };
@@ -2,16 +2,25 @@
// 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 { SandboxPolicy } from "./SandboxPolicy";
/**
* Create a directory on the host filesystem.
*/
export type FsCreateDirectoryParams = {
export type FsCreateDirectoryParams = {
/**
* Absolute directory path to create.
*/
path: AbsolutePathBuf,
path: AbsolutePathBuf,
/**
* Whether parent directories should also be created. Defaults to `true`.
*/
recursive?: boolean | null, };
recursive?: boolean | null,
/**
* Optional sandbox policy for this filesystem mutation.
*/
sandboxPolicy?: SandboxPolicy | null,
/**
* Optional cwd to resolve legacy sandbox workspace roots against.
*/
cwd?: AbsolutePathBuf | null, };
@@ -2,12 +2,21 @@
// 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 { SandboxPolicy } from "./SandboxPolicy";
/**
* Request metadata for an absolute path.
*/
export type FsGetMetadataParams = {
export type FsGetMetadataParams = {
/**
* Absolute path to inspect.
*/
path: AbsolutePathBuf, };
path: AbsolutePathBuf,
/**
* Optional sandbox policy for this filesystem metadata lookup.
*/
sandboxPolicy?: SandboxPolicy | null,
/**
* Optional cwd to resolve legacy sandbox workspace roots against.
*/
cwd?: AbsolutePathBuf | null, };
@@ -2,12 +2,21 @@
// 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 { SandboxPolicy } from "./SandboxPolicy";
/**
* List direct child names for a directory.
*/
export type FsReadDirectoryParams = {
export type FsReadDirectoryParams = {
/**
* Absolute directory path to read.
*/
path: AbsolutePathBuf, };
path: AbsolutePathBuf,
/**
* Optional sandbox policy for this directory read.
*/
sandboxPolicy?: SandboxPolicy | null,
/**
* Optional cwd to resolve legacy sandbox workspace roots against.
*/
cwd?: AbsolutePathBuf | null, };
@@ -2,12 +2,21 @@
// 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 { SandboxPolicy } from "./SandboxPolicy";
/**
* Read a file from the host filesystem.
*/
export type FsReadFileParams = {
export type FsReadFileParams = {
/**
* Absolute path to read.
*/
path: AbsolutePathBuf, };
path: AbsolutePathBuf,
/**
* Optional sandbox policy for this filesystem read.
*/
sandboxPolicy?: SandboxPolicy | null,
/**
* Optional cwd to resolve legacy sandbox workspace roots against.
*/
cwd?: AbsolutePathBuf | null, };
@@ -2,20 +2,29 @@
// 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 { SandboxPolicy } from "./SandboxPolicy";
/**
* Remove a file or directory tree from the host filesystem.
*/
export type FsRemoveParams = {
export type FsRemoveParams = {
/**
* Absolute path to remove.
*/
path: AbsolutePathBuf,
path: AbsolutePathBuf,
/**
* Whether directory removal should recurse. Defaults to `true`.
*/
recursive?: boolean | null,
recursive?: boolean | null,
/**
* Whether missing paths should be ignored. Defaults to `true`.
*/
force?: boolean | null, };
force?: boolean | null,
/**
* Optional sandbox policy for this filesystem mutation.
*/
sandboxPolicy?: SandboxPolicy | null,
/**
* Optional cwd to resolve legacy sandbox workspace roots against.
*/
cwd?: AbsolutePathBuf | null, };
@@ -2,16 +2,25 @@
// 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 { SandboxPolicy } from "./SandboxPolicy";
/**
* Write a file on the host filesystem.
*/
export type FsWriteFileParams = {
export type FsWriteFileParams = {
/**
* Absolute path to write.
*/
path: AbsolutePathBuf,
path: AbsolutePathBuf,
/**
* File contents encoded as base64.
*/
dataBase64: string, };
dataBase64: string,
/**
* Optional sandbox policy for this filesystem write.
*/
sandboxPolicy?: SandboxPolicy | null,
/**
* Optional cwd to resolve legacy sandbox workspace roots against.
*/
cwd?: AbsolutePathBuf | null, };
@@ -1610,14 +1610,18 @@ mod tests {
request_id: RequestId::Integer(9),
params: v2::FsGetMetadataParams {
path: absolute_path("tmp/example"),
sandbox_policy: None,
cwd: None,
},
};
assert_eq!(
json!({
"method": "fs/getMetadata",
"id": 9,
"params": {
"path": absolute_path_string("tmp/example")
"params": {
"path": absolute_path_string("tmp/example"),
"sandboxPolicy": null,
"cwd": null
}
}),
serde_json::to_value(&request)?,
@@ -2170,6 +2170,12 @@ pub struct FeedbackUploadResponse {
pub struct FsReadFileParams {
/// Absolute path to read.
pub path: AbsolutePathBuf,
/// Optional sandbox policy for this filesystem read.
#[ts(optional = nullable)]
pub sandbox_policy: Option<SandboxPolicy>,
/// Optional cwd to resolve legacy sandbox workspace roots against.
#[ts(optional = nullable)]
pub cwd: Option<AbsolutePathBuf>,
}
/// Base64-encoded file contents returned by `fs/readFile`.
@@ -2190,6 +2196,12 @@ pub struct FsWriteFileParams {
pub path: AbsolutePathBuf,
/// File contents encoded as base64.
pub data_base64: String,
/// Optional sandbox policy for this filesystem write.
#[ts(optional = nullable)]
pub sandbox_policy: Option<SandboxPolicy>,
/// Optional cwd to resolve legacy sandbox workspace roots against.
#[ts(optional = nullable)]
pub cwd: Option<AbsolutePathBuf>,
}
/// Successful response for `fs/writeFile`.
@@ -2208,6 +2220,12 @@ pub struct FsCreateDirectoryParams {
/// Whether parent directories should also be created. Defaults to `true`.
#[ts(optional = nullable)]
pub recursive: Option<bool>,
/// Optional sandbox policy for this filesystem mutation.
#[ts(optional = nullable)]
pub sandbox_policy: Option<SandboxPolicy>,
/// Optional cwd to resolve legacy sandbox workspace roots against.
#[ts(optional = nullable)]
pub cwd: Option<AbsolutePathBuf>,
}
/// Successful response for `fs/createDirectory`.
@@ -2223,6 +2241,12 @@ pub struct FsCreateDirectoryResponse {}
pub struct FsGetMetadataParams {
/// Absolute path to inspect.
pub path: AbsolutePathBuf,
/// Optional sandbox policy for this filesystem metadata lookup.
#[ts(optional = nullable)]
pub sandbox_policy: Option<SandboxPolicy>,
/// Optional cwd to resolve legacy sandbox workspace roots against.
#[ts(optional = nullable)]
pub cwd: Option<AbsolutePathBuf>,
}
/// Metadata returned by `fs/getMetadata`.
@@ -2249,6 +2273,12 @@ pub struct FsGetMetadataResponse {
pub struct FsReadDirectoryParams {
/// Absolute directory path to read.
pub path: AbsolutePathBuf,
/// Optional sandbox policy for this directory read.
#[ts(optional = nullable)]
pub sandbox_policy: Option<SandboxPolicy>,
/// Optional cwd to resolve legacy sandbox workspace roots against.
#[ts(optional = nullable)]
pub cwd: Option<AbsolutePathBuf>,
}
/// A directory entry returned by `fs/readDirectory`.
@@ -2286,6 +2316,12 @@ pub struct FsRemoveParams {
/// Whether missing paths should be ignored. Defaults to `true`.
#[ts(optional = nullable)]
pub force: Option<bool>,
/// Optional sandbox policy for this filesystem mutation.
#[ts(optional = nullable)]
pub sandbox_policy: Option<SandboxPolicy>,
/// Optional cwd to resolve legacy sandbox workspace roots against.
#[ts(optional = nullable)]
pub cwd: Option<AbsolutePathBuf>,
}
/// Successful response for `fs/remove`.
@@ -2306,6 +2342,12 @@ pub struct FsCopyParams {
/// Required for directory copies; ignored for file copies.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub recursive: bool,
/// Optional sandbox policy for this filesystem copy.
#[ts(optional = nullable)]
pub sandbox_policy: Option<SandboxPolicy>,
/// Optional cwd to resolve legacy sandbox workspace roots against.
#[ts(optional = nullable)]
pub cwd: Option<AbsolutePathBuf>,
}
/// Successful response for `fs/copy`.
@@ -6528,6 +6570,8 @@ mod tests {
fn fs_read_file_params_round_trip() {
let params = FsReadFileParams {
path: absolute_path("tmp/example.txt"),
sandbox_policy: None,
cwd: None,
};
let value = serde_json::to_value(&params).expect("serialize fs/readFile params");
@@ -6535,6 +6579,8 @@ mod tests {
value,
json!({
"path": absolute_path_string("tmp/example.txt"),
"sandboxPolicy": null,
"cwd": null,
})
);
@@ -6548,6 +6594,8 @@ mod tests {
let params = FsCreateDirectoryParams {
path: absolute_path("tmp/example"),
recursive: None,
sandbox_policy: None,
cwd: None,
};
let value = serde_json::to_value(&params).expect("serialize fs/createDirectory params");
@@ -6556,6 +6604,8 @@ mod tests {
json!({
"path": absolute_path_string("tmp/example"),
"recursive": null,
"sandboxPolicy": null,
"cwd": null,
})
);
@@ -6569,6 +6619,8 @@ mod tests {
let params = FsWriteFileParams {
path: absolute_path("tmp/example.bin"),
data_base64: "AAE=".to_string(),
sandbox_policy: None,
cwd: None,
};
let value = serde_json::to_value(&params).expect("serialize fs/writeFile params");
@@ -6577,6 +6629,8 @@ mod tests {
json!({
"path": absolute_path_string("tmp/example.bin"),
"dataBase64": "AAE=",
"sandboxPolicy": null,
"cwd": null,
})
);
@@ -6591,6 +6645,8 @@ mod tests {
source_path: absolute_path("tmp/source"),
destination_path: absolute_path("tmp/destination"),
recursive: true,
sandbox_policy: None,
cwd: None,
};
let value = serde_json::to_value(&params).expect("serialize fs/copy params");
@@ -6600,6 +6656,8 @@ mod tests {
"sourcePath": absolute_path_string("tmp/source"),
"destinationPath": absolute_path_string("tmp/destination"),
"recursive": true,
"sandboxPolicy": null,
"cwd": null,
})
);