MCPcopy Index your code
hub / github.com/AI45Lab/Code / program

Method program

sdk/python/src/lib.rs:2022–2044  ·  view source on GitHub ↗

Run a bounded JavaScript script through the embedded QuickJS `program` tool.

(
        &self,
        py: Python<'_>,
        options: &Bound<'_, pyo3::types::PyDict>,
    )

Source from the content-addressed store, hash-verified

2020
2021 /// Run a bounded JavaScript script through the embedded QuickJS `program` tool.
2022 fn program(
2023 &self,
2024 py: Python<'_>,
2025 options: &Bound<'_, pyo3::types::PyDict>,
2026 ) -> PyResult<PyToolResult> {
2027 let args = normalize_program_script_options(options)?;
2028
2029 let session = self.inner.clone();
2030 let result = py
2031 .allow_threads(move || get_runtime().block_on(session.tool("program", args)))
2032 .map_err(|e| PyRuntimeError::new_err(format!("Program execution failed: {e}")))?;
2033
2034 Ok(PyToolResult {
2035 name: result.name,
2036 output: result.output,
2037 exit_code: result.exit_code,
2038 metadata_json: result.metadata.as_ref().map(serde_json::Value::to_string),
2039 error_kind_json: result
2040 .error_kind
2041 .as_ref()
2042 .and_then(|k| serde_json::to_string(k).ok()),
2043 })
2044 }
2045
2046 /// Read a file from the workspace.
2047 fn read_file(&self, py: Python<'_>, path: String) -> PyResult<String> {

Callers 1

Calls 5

block_onMethod · 0.80
get_runtimeFunction · 0.70
cloneMethod · 0.45
toolMethod · 0.45

Tested by

no test coverage detected