Expand description
Mirrors packages/agent/src/harness (tools + env + session + compaction).
M4 scope: ExecutionEnv trait + OsExecutionEnv + InMemoryExecutionEnv +
file-mutation-queue + read/write/edit/bash tools + edit-diff + utils
(truncate, shell-output, image, path-utils). Session/compaction arrive in M5
(these live in pi-harness, not here).
Workspace dep chain: pi-telemetry → pi-ai → pi-agent → pi-tools → pi-harness → pi-cli. pi-tools depends on pi-agent (for the AgentTool
trait) and pi-ai (for Tool/content types).
Re-exports§
pub use tools::create_bash_tool;pub use tools::create_edit_tool;pub use tools::create_find_tool;pub use tools::create_grep_tool;pub use tools::create_ls_tool;pub use tools::create_powershell_tool;pub use tools::create_read_tool;pub use tools::create_write_tool;pub use tools::BashExecution;pub use tools::BashPrepare;pub use tools::BashToolOptions;pub use tools::ExecutionToolContext;pub use tools::ProcessedImage;pub use tools::ReadImageProcessor;pub use tools::ReadToolOptions;pub use env::ExecutionEnv;pub use env::FileContent;pub use env::FileInfo;pub use env::FileKind;pub use env::FileSystem;pub use env::Shell;pub use env::ShellExecOptions;pub use env::ShellOutput;pub use error::io_to_file_code;pub use error::io_to_file_error;pub use error::ExecutionError;pub use error::ExecutionErrorCode;pub use error::FileError;pub use error::FileErrorCode;pub use file_mutation_queue::get_mutation_queue_key;pub use file_mutation_queue::with_file_mutation_queue;pub use file_mutation_queue::MutatingEnv;pub use file_mutation_queue::MutationQueueRegistry;pub use image::detect_supported_image_mime_type;pub use image::encode_base64;pub use in_memory::InMemoryExecutionEnv;pub use in_memory::ShellScript;pub use os_env::is_host_private_env;pub use os_env::OsExecutionEnv;pub use os_env::HOST_PRIVATE_ENV;pub use path_utils::normalize_tool_path;pub use path_utils::resolve_read_tool_path;pub use path_utils::resolve_tool_path;pub use truncate::format_size;pub use truncate::split_lines_for_counting;pub use truncate::truncate_head;pub use truncate::truncate_line;pub use truncate::truncate_tail;pub use truncate::TruncateLineOutput;pub use truncate::TruncationLimit;pub use truncate::TruncationOptions;pub use truncate::TruncationResult;pub use truncate::DEFAULT_MAX_BYTES;pub use truncate::DEFAULT_MAX_LINES;pub use truncate::GREP_MAX_LINE_LENGTH;
Modules§
- env
- Mirrors
packages/agent/src/harness/types.ts::ExecutionEnv— the trait every tool and test-double implements.ExecutionEnv = FileSystem + Shell. - error
- Mirrors
packages/agent/src/harness/types.ts— theFileError/ExecutionErrorshapes + their stable code enums used by theExecutionEnvtrait. Drops the TSok/err/getOrThrowhelpers (Rust has these natively) and theCompactionError/BranchSummaryError(those live inpi-harness). - file_
mutation_ queue - Mirrors
packages/agent/src/harness/tools/file-mutation-queue.ts— serializes file-mutating operations per canonical path so concurrent edits to the same path (or a symlink + its target) don’t interleave. - image
- Mirrors
packages/agent/src/harness/tools/image.ts— image MIME detection from byte signatures and base64 encoding. - image_
processing - Image processing utilities — resize, convert, and transform images.
- in_
memory InMemoryExecutionEnv— an in-memoryExecutionEnvfor tests. NOT a direct mirror of a single TS file (the TS harness has no in-memory env; it tests againstNodeExecutionEnv+ tempdirs). This is the Rust port’s primary test double, modeled to satisfy the sameFileSystem+Shellcontract so the conformance suite can run identical assertions against bothInMemoryandOs.- os_env
- Mirrors
packages/agent/src/harness/env/nodejs.ts—NodeExecutionEnv→OsExecutionEnv. Real-filesystem + real-process backend viatokio::fs+tokio::process. - path_
utils - Mirrors
packages/agent/src/harness/tools/path-utils.ts— tool-path normalization + resolution, including the read tool’s fuzzy-existence lookup of typographic variants the model commonly emits. - shell_
output - Mirrors
packages/agent/src/harness/utils/shell-output.ts— the bash tool’s output-capture layer wrappingShell::exec. - tools
- Mirrors
packages/agent/src/harness/tools/*— the built-inread/write/edit/bashAgentToolimpls + the read-onlygrep/find/lsports (port ofpackages/coding-agent/src/core/tools/{grep,find,ls}.ts) + their shared helpers. - truncate
- Mirrors
packages/agent/src/harness/utils/truncate.ts— head/tail line+byte truncation with structured metadata. Used by thereadtool (head) and thebashtool’sexecute_shell_with_capture(tail). - utils