- 1096
let (sink, _rx) = SandboxEventSink::new_with_id("test-cwd-escape".into()); - 1097
let ctx = ToolContext::new(workspace.path().to_path_buf()).with_sandbox_sink(sink); - 1098
let out = super::BashTool - 1099
.execute( - 1100
&serde_json::json!({ - 1101
"command": "pwd", - 1102
"cwd": ".." - 1103
}), - 1104
&ctx, - 1105
) - 1106
.await; - 1107
assert!(out.is_error); - 1108
assert!(out.content.contains("inside the workspace")); - 1109
} - 1110
- 1111
#[tokio::test] - 1112
async fn temp_files_are_scoped_to_the_agent() { - 1113
use crate::{Tool, ToolContext, sandbox_events::SandboxEventSink}; - 1114
let workspace = tempfile::tempdir().unwrap(); - 1115
let (sink, _events) = SandboxEventSink::new_with_id("test-agent-scratch".into()); - 1116
let ctx = ToolContext::new(workspace.path().to_path_buf()) - 1117
.with_agent_id("researcher-99") - 1118
.with_sandbox_sink(sink); - 1119
- 1120
let out = super::BashTool - 1121
.execute(&serde_json::json!({"command": "echo \"$TMPDIR\""}), &ctx) - 1122
.await; - 1123
assert!(!out.is_error, "stdout/stderr: {}", out.content); - 1124
assert!( - 1125
out.content - 1126
.contains(".vak/scratch/researcher-99/test-agent-scratch/tmp"), - 1127
"{}", - 1128
out.content - 1129
); - 1130
} - 1131
- 1132
#[tokio::test] - 1133
async fn workspace_command_promotes_user_visible_result() { - 1134
use crate::{Tool, ToolContext, sandbox_events::SandboxEventSink}; - 1135
let workspace = tempfile::tempdir().unwrap(); - 1136
let (sink, mut events) = SandboxEventSink::new_with_id("test-workspace-result".into()); - 1137
let ctx = ToolContext::new(workspace.path().to_path_buf()).with_sandbox_sink(sink); - 1138
- 1139
let out = super::BashTool - 1140
.execute( - 1141
&serde_json::json!({ - 1142
"command": "printf '<h1>India market</h1>\\n' > index.html", - 1143
"cwd": "." - 1144
}), - 1145
&ctx, - 1146
) - 1147
.await; - 1148
assert!(!out.is_error, "stdout/stderr: {}", out.content); - 1149
assert!(workspace.path().join("index.html").is_file()); - 1150
let mut saw_result = false; - 1151
while let Ok(event) = events.try_recv() { - 1152
if let crate::SandboxEvent::ArtifactGenerated { path, .. } = event { - 1153
saw_result |= path == "index.html"; - 1154
} - 1155
} - 1156
assert!( - 1157
saw_result, - 1158
"workspace result should be emitted as an artifact" - 1159
); - 1160
} - 1161
} - 1162
Indexing the workspace…
Vakyartha documentation is discovering safe artifacts, anchors, and source references.