feat: expose retained Bash streams through common WIP file contracts
This commit is contained in:
@@ -172,6 +172,10 @@ async fn command_page(
|
||||
}
|
||||
|
||||
impl BashTool {
|
||||
pub fn input_schema() -> serde_json::Value {
|
||||
serde_json::to_value(schemars::schema_for!(BashParams)).expect("Bash schema serialization")
|
||||
}
|
||||
|
||||
pub fn new(router: Arc<WorkdirSessionRouter>, output: BashOutputView) -> Self {
|
||||
Self {
|
||||
router,
|
||||
@@ -499,10 +503,9 @@ pub(crate) fn routed_bash_tool(
|
||||
output: BashOutputView,
|
||||
) -> ToolDefinition {
|
||||
Arc::new(move || {
|
||||
let schema = schemars::schema_for!(BashParams);
|
||||
let meta = ToolMeta::new("Bash")
|
||||
.description("Execute a shell command in one selected Workdir. Workdir owns launch, lossless bounded byte transport, timeout and cancel; Bash owns preview, quota-limited ephemeral output and read-only virtual references. This is not a sandbox.")
|
||||
.input_schema(serde_json::to_value(schema).expect("Bash schema serialization"));
|
||||
.input_schema(BashTool::input_schema());
|
||||
let tool: Arc<dyn Tool> = Arc::new(BashTool::new(router.clone(), output.clone()));
|
||||
(meta, tool)
|
||||
})
|
||||
|
||||
@@ -183,6 +183,9 @@ impl BashOutputView {
|
||||
// happens inside the runtime, so idle expiry must start here as well.
|
||||
self.start_reaper();
|
||||
let mut store = self.store.lock().unwrap();
|
||||
if !self.is_active() {
|
||||
return Err("Bash output authority revoked".into());
|
||||
}
|
||||
store.expire(Instant::now());
|
||||
while store.records.len() >= STORE_COUNT || store.reserved + COMMAND_BYTES > STORE_BYTES {
|
||||
let Some(index) = store
|
||||
@@ -220,6 +223,9 @@ impl BashOutputView {
|
||||
return None;
|
||||
}
|
||||
let mut store = self.store.lock().unwrap();
|
||||
if !self.is_active() {
|
||||
return None;
|
||||
}
|
||||
store.expire(Instant::now());
|
||||
store
|
||||
.records
|
||||
|
||||
Reference in New Issue
Block a user