mirror of
https://github.com/open-jarvis/OpenJarvis.git
synced 2026-07-31 03:12:16 +00:00
The Rust workspace fails to build on stable 1.86/1.87 with cryptic E0658 errors deep in dependencies: rig-core uses let-chains and openjarvis-skills uses `is_multiple_of`, both stabilized in 1.88 (#252). Add a rust-toolchain.toml pinning channel 1.88 (rustup then auto-selects a working toolchain instead of erroring mid-build) and declare rust-version = "1.88" in [workspace.package] to self-document it. Because the toolchain pin makes CI's `cargo clippy -D warnings` run under 1.88 — whose clippy enables `uninlined_format_args` — also apply the mechanical `format!("{}", x)` -> `format!("{x}")` rewrites across the workspace (via `clippy --fix`; string output is identical, no logic change). Verified clippy + fmt + `cargo test --workspace` clean on BOTH 1.88 and current stable. Verified locally: cargo +1.86 and +1.87 fail (E0658), +1.88 builds and tests cleanly. Supporting true 1.86 is infeasible without downgrading rig-core below the versions exposing the token-usage symbols we use — deferred. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
62 lines
1.9 KiB
Rust
62 lines
1.9 KiB
Rust
//! PyO3 bindings for task scheduler.
|
|
|
|
use pyo3::prelude::*;
|
|
|
|
#[pyclass(name = "SchedulerStore", unsendable)]
|
|
pub struct PySchedulerStore {
|
|
inner: openjarvis_scheduler::SchedulerStore,
|
|
}
|
|
|
|
#[pymethods]
|
|
impl PySchedulerStore {
|
|
#[new]
|
|
#[pyo3(signature = (db_path=":memory:"))]
|
|
fn new(db_path: &str) -> Self {
|
|
Self {
|
|
inner: openjarvis_scheduler::SchedulerStore::new(db_path),
|
|
}
|
|
}
|
|
|
|
fn create_task(&self, name: &str, schedule_type: &str, schedule_value: &str) -> PyResult<String> {
|
|
let st = openjarvis_scheduler::ScheduleType::parse(schedule_type).ok_or_else(|| {
|
|
PyErr::new::<pyo3::exceptions::PyValueError, _>(format!(
|
|
"invalid schedule_type '{schedule_type}', expected cron/interval/once"
|
|
))
|
|
})?;
|
|
let task = self.inner.create_task(name, st, schedule_value);
|
|
Ok(serde_json::to_string(&task).unwrap_or_default())
|
|
}
|
|
|
|
fn get_task(&self, id: &str) -> Option<String> {
|
|
self.inner
|
|
.get_task(id)
|
|
.map(|t| serde_json::to_string(&t).unwrap_or_default())
|
|
}
|
|
|
|
fn list_tasks(&self) -> String {
|
|
serde_json::to_string(&self.inner.list_tasks()).unwrap_or_default()
|
|
}
|
|
|
|
fn update_status(&self, id: &str, status: &str) -> PyResult<bool> {
|
|
let s = openjarvis_scheduler::TaskStatus::parse(status).ok_or_else(|| {
|
|
PyErr::new::<pyo3::exceptions::PyValueError, _>(format!(
|
|
"invalid status '{status}', expected active/paused/cancelled/completed"
|
|
))
|
|
})?;
|
|
Ok(self.inner.update_status(id, s))
|
|
}
|
|
|
|
fn record_run(&self, id: &str, timestamp: f64) -> bool {
|
|
self.inner.record_run(id, timestamp)
|
|
}
|
|
|
|
fn delete_task(&self, id: &str) -> bool {
|
|
self.inner.delete_task(id)
|
|
}
|
|
}
|
|
|
|
#[pyfunction]
|
|
pub fn parse_cron_next(expr: &str, after: f64) -> Option<f64> {
|
|
openjarvis_scheduler::parse_cron_next(expr, after)
|
|
}
|