Create a directory tree under the workspace.
(
path: Annotated[str, ParamMeta(description="Workspace-relative folder path")],
*,
parents: Annotated[bool, ParamMeta(description="Create missing parent directories")]
= True,
exist_ok: Annotated[bool, ParamMeta(description="Do not raise if folder already exists")]
= True,
_context: Dict[str, Any] | None = None,
)
| 236 | |
| 237 | |
| 238 | def create_folder( |
| 239 | path: Annotated[str, ParamMeta(description="Workspace-relative folder path")], |
| 240 | *, |
| 241 | parents: Annotated[bool, ParamMeta(description="Create missing parent directories")] |
| 242 | = True, |
| 243 | exist_ok: Annotated[bool, ParamMeta(description="Do not raise if folder already exists")] |
| 244 | = True, |
| 245 | _context: Dict[str, Any] | None = None, |
| 246 | ) -> Dict[str, Any]: |
| 247 | """Create a directory tree under the workspace.""" |
| 248 | |
| 249 | if not path: |
| 250 | raise ValueError("path must be provided") |
| 251 | _check_attachments_not_modified(path) |
| 252 | |
| 253 | ctx = FileToolContext(_context) |
| 254 | target = ctx.resolve_under_workspace(path) |
| 255 | |
| 256 | if target.exists() and not target.is_dir(): |
| 257 | raise ValueError("Target exists and is not a directory") |
| 258 | |
| 259 | previously_exists = target.exists() |
| 260 | target.mkdir(parents=parents, exist_ok=exist_ok) |
| 261 | |
| 262 | return { |
| 263 | "path": ctx.to_workspace_relative(target), |
| 264 | "absolute_path": str(target), |
| 265 | "created": not previously_exists, |
| 266 | } |
| 267 | |
| 268 | |
| 269 | def delete_path( |
nothing calls this directly
no test coverage detected