text
stringlengths
14
100k
source
stringclasses
1 value
repo
stringclasses
810 values
language
stringclasses
13 values
<|fim_prefix|>//! IAM-aware policy enforcement for Nevis role-to-permission mapping. //! //! Evaluates tool and workspace access based on Nevis roles using a //! deny-by-default policy model. All policy decisions are audit-logged. use super::nevis::NevisIdentity; use anyhow::{Result, bail}; use serde::{Deserialize, Se...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! Landlock sandbox (Linux kernel 5.13+ LSM) //! //! Landlock provides unprivileged sandboxing through the Linux kernel. //! This module uses the pure-Rust `landlock` crate for filesystem access control. #[cfg(all(feature = "sandbox-landlock", target_os = "linux"))] use landlock::{AccessFs, PathBeneath,...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! Credential leak detection for outbound content. //! //! Scans outbound messages for potential credential leaks before they are sent, //! preventing accidental exfiltration of API keys, tokens, passwords, and other //! sensitive values. //! //! Contributed from RustyClaw (MIT licensed). use regex::Reg...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! Security subsystem for policy enforcement, sandboxing, and secret management. //! //! This module provides the security infrastructure for ZeroClaw. The core type //! [`Securit<|fim_suffix|>cfg(target_os = "macos")] pub mod seatbelt; pub mod secrets; pub mod traits; pub mod vulnerability; #[cfg(featur...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>/auth/realms/{}/protocol/openid-connect/userinfo", self.instance_url.trim_end_matches('/'), self.realm, ); let resp = self .http_client .get(&session_url) .bearer_auth(session_token) .send() .await ...
fim
zeroclaw-labs/zeroclaw
rust
use crate::security::secrets::SecretStore; use anyhow::{Context, Result}; use parking_lot::Mutex; use ring::hmac; use std::collections::HashMap; use std::fs; use std::path::{Path, PathBuf}; use std::time::{SystemTime, UNIX_EPOCH}; use zeroclaw_config::schema::OtpConfig; const OTP_SECRET_FILE: &str = "otp-secret"; cons...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>pub use zeroclaw_config:<|fim_suffix|><|fim_middle|>:pairing::*; <|endoftext|>
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|><|fim_suffix|> fn load_playbooks_merges_custom_and_builtin() { let dir = tempfile::tempdir().unwrap(); let custom = Playbook { name: "custom_playbook".into(), description: "A custom playbook".into(), steps: vec![PlaybookStep { action: ...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|><|fim_prefix|>pub use zeroclaw_config::po<|fim_middle|>licy::*; <|endoftext|>
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>0.9; } } 0.0 } /// Check for tool call JSON injection. fn check_tool_injection(&self, content: &str, patterns: &mut Vec<String>) -> f64 { // Look for attempts to inject tool calls or malformed JSON if content.contains("tool_calls") || content.contai...
fim
zeroclaw-labs/zeroclaw
rust
//! macOS sandbox-exec (Seatbelt) sandbox backend. //! //! Uses Apple's built-in `sandbox-exec` tool to enforce per-session Seatbelt //! profiles that restrict network access, filesystem writes, and process //! spawning. Policy files are generated in `.sb` format and written to a //! temporary directory that is cleaned...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>pub use zeroclaw_con<|fim_suffix|>:*; <|fim_middle|>fig::secrets:<|endoftext|>
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! S<|fim_suffix|>k when no /// platform-specific sandbox backend is detected, or in development /// environments where isolation is not required. Security in this mode /// relies entirely on application-layer controls. #[derive(Debug, Clone, Default)] pub struct NoopSandbox; impl Sandbox for NoopSandbo...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|> finding.cvss_score, priority, context, finding.affected_asset, finding.description ); if !finding.remediation.is_empty() { let _ = writeln!(summary, " Remediation: {}", finding.remediation); } summary.pu...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|> 65 bytes, it's already uncompressed P-256 if cose.len() >= 65 && cose[0] == 0x04 { return Ok(cose[..65].to_vec()); } anyhow::bail!( "Unsupported COSE key format (expected uncompressed P-256, got {} bytes starting with 0x{:02x})", cose.len(), cose.first().copie...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>use anyhow::{Context, Result, bail}; use std::fs; use std::path::{Path, PathBuf}; use std::process::Command; use std::str::FromStr; use zeroclaw_config::schema::Config; const SERVICE_LABEL: &str = "com.zeroclaw.daemon"; const WINDOWS_TASK_NAME: &str = "ZeroClaw Daemon"; /// Supported init systems for se...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|> assert!(res.total_score >= 0.7, "score: {}", res.total_score); assert_eq!(res.recommendation, Recommendation::Auto); } #[test] fn low_star_no_license_gets_manual_or_skip() { let eval = Evaluator::new(0.7); let c = make_candidate(1, None, false); let re...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! Integrator β€” generates ZeroClaw-standard SKILL.toml + SKILL.md from scout results. use std::fs; use std::path::PathBuf; use anyhow::{Context, Result, bail}; use chrono::Utc; use super::scout::ScoutResult; // --------------------------------------------------------------------------- // Integrator ...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! SkillForge β€” Skill auto-discovery, evaluation, and integration engine. //! //! Pipeline: Scout β†’ Evaluate β†’ Integrate //! Discovers skills from external sources, scores them, and generates //! ZeroClaw-compatible manifests for qualified candidates. pub mod evaluate; pub mod integrate; pub mod scout; ...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>ool-skill", "html_url": "https://github.com/user/cool-skill", "description": "A cool skill", "stargazers_count": 42, "language": "Rust", "updated_at": "2026-01-15T10:00:00Z", "owner": { ...
fim
zeroclaw-labs/zeroclaw
rust
use anyhow::{Context, Result, bail}; use regex::Regex; use std::fs; use std::path::{Component, Path, PathBuf}; use std::sync::OnceLock; use super::constants::{SKILL_DEPRECATED_MANIFESTS, SKILL_MANIFEST_FILENAME}; const MAX_TEXT_FILE_BYTES: u64 = 512 * 1024; #[derive(Debug, Clone, Copy, Default)] pub struct SkillAudi...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>ays /// single-sourced. pub fn summary( config: &Config, install_root: &Path, alias: &str, ) -> Result<BundleSummary, BundleError> { let bundle = config .skill_bundles .get(alias) .ok_or_else(|| BundleError::UnknownBundle(alias.to_string()))?; Ok(BundleSummary {...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! Canonical filenames + scaffold subdirs for the Agent Skills spec. //! //! Every literal that names a skill-file or scaffold-subdir lives here. Any //! grep hit for `"SKILL.md"`, `"scripts"`, `"references"`, `"assets"` outside //! this module is drift. /// Canonical manifest filename per the open Agen...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>d").and_then(toml::Value::as_str), Some("cargo build") ); } #[test] fn toml_generation_escapes_quotes() { let calls = vec![ToolCallRecord { name: "shell".into(), args: serde_json::json!({"command": "echo \"hello\""}), }]; let...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! Parse and serialize canonical `SKILL.md` files. //! //! A [`SkillDocument`] is the on-disk pair of frontmatter and body. The //! splitter [`split_frontmatter`] is shared with the legacy `parse_skill_markdown` //! path in `super` so both readers see the same delimiter rules. use std::fmt::Write as _; ...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>. pub fn prop_fields() -> Vec<PropFieldInfo> { vec![ field( "name", "String", true, "Skill identifier (lowercase, hyphens only).", ), field( "description", "Strin...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>() { let content = r#"[skill] name = "test" description = "A skill" version = "0.1.0" [[tools]] name = "action" kind = "shell" command = "echo hello" "#; let result = append_improvement_metadata(content, "2026-01-01T00:00:00Z", "Improved"); assert!(result.contains("[[tools]]")); ...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>alified_resolves_in_multi_bundle_config() { let cfg = cfg_with_bundles(&["alpha", "beta"]); let r = resolve(&cfg, "code-review", Some("beta")).unwrap(); assert_eq!(r.bundle(), "beta"); assert_eq!(r.name(), "code-review"); } } <|fim_prefix|>//! Skill identity + the disam...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! Scaffold a new skill on disk: write `SKILL.md` + create optional //! `scripts/`, `references/`, `assets/` subdirs per the canonical layout. use std::path::{Path, PathBuf}; use super::bundle::{self, BundleError}; use super::constants::{SKILL_MANIFEST_FILENAME, SKILL_SCAFFOLD_SUBDIRS}; use super::docu...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! Public service surface every consumer (CLI, gateway, future TUI) uses //! to read and mutate skills + skill bundles. There is no second //! implementation β€” drift is closed by construction. use std::path::{Path, PathBuf}; use super::bundle::{self, BundleSummary}; use super::constants::{ SKILL_AR...
fim
zeroclaw-labs/zeroclaw
rust
pub use crate::tools::skill_http::*; <|endoftext|>
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>pub use <|fim_suffix|>ate::tools::skill_tool::*; <|fim_middle|>cr<|endoftext|>
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>use super::Skill; use serde::Deserialize; use std::collections::HashSet; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; /// Server-side, post-submit install suggestions for cached skill registry metadata. /// /// This layer intentionally runs before the normal LLM turn and onl...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>); let empty_skills_path = skills_dir(&empty_workspace); assert_eq!(empty_skills_path, empty_workspace.join("skills")); assert!(!empty_skills_path.exists()); } #[tokio::test] async fn test_skills_symlink_permissions_and_safety() { let tmp = TempDir::new().unwra...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>use anyhow::{Context, Result}; use regex::Regex; use std::path::{Path, PathBuf}; use std::process::Command; const TEST_FILE_NAME: &str = "TEST.sh"; /// Result of running all tests for a single skill. #[derive(Debug, Clone)] pub struct SkillTestResult { pub skill_name: String, pub tests_run: usiz...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>use std::sync::Arc; use anyhow::Result; use super::types::{SopRun, SopStepResult}; use zeroclaw_memory::traits::{Memory, MemoryCategory}; const SOP_CATEGORY: &str = "sop"; /// Persists SOP execution runs and step results to the Memory backend. /// /// Storage keys: /// - `sop_run_{run_id}` β€” full `Sop...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>s, Op::Lte => lhs.as_str() <= rhs, } } fn value_as_f64(v: &Value) -> Option<f64> { match v { Value::Number(n) => n.as_f64(), Value::String(s) => s.parse().ok(), _ => None, } } fn value_as_string(v: &Value) -> String { match v { Value::String(s) => ...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>SopTriggerSource::Mqtt, topic: Some("alert".into()), payload: None, timestamp: now_iso8601(), }; let results = dispatch_sop_event(&engine, &audit, event).await; assert_eq!(results.len(), 1); match &results[0] { DispatchResult...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>use std::collections::HashMap; use std::fmt::Write as _; use std::path::{Path, PathBuf}; use anyhow::{Result, bail}; use super::condition::evaluate_condition; use super::load_sops; use super::types::{ DeterministicRunState, DeterministicSavings, Sop, SopEvent, SopExecutionMode, SopPriority, SopR...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>use std::collections::{HashMap, VecDeque}; use std::sync::RwLock; use std::time::Instant; use chrono::{DateTime, NaiveDateTime, Utc}; use serde_json::json; use super::types::{SopRun, SopRunStatus, SopStepStatus}; use zeroclaw_memory::traits::{Memory, MemoryCategory}; /// Maximum recent runs kept in eac...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>pub mod audit; pub mod condition; pub mod dispatch; pub mod engine; pub mod metrics; pub mod types; pub use audit::SopAuditLogger; pub use engine::SopEngine; pub use metrics::SopMetricsCollector; #[allow(unused_imports)] pub use types::{ DeterministicRunState, DeterministicSavings, Sop, SopEvent, Sop...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>yBased.to_string(), "priority_based" ); } #[test] fn trigger_display() { let mqtt = SopTrigger::Mqtt { topic: "sensors/temp".into(), condition: Some("$.value > 85".into()), }; assert_eq!(mqtt.to_string(), "mqtt:sensors/temp")...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|> assert_eq!( ctx.policy.workspace_dir, session_cwd, "session cwd must survive the spawn; regression for issue #7263" ); } /// `for_agent` (the cron-style entry point) must continue to /// resolve the workspace from config so scheduled jobs β€” which //...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>ol, ToolKind::Plugin); tool_attribution!(SopAdvanceTool, ToolKind::SopAdvance); tool_attribution!(SopApproveTool, ToolKind::SopApprove); tool_attribution!(SopExecuteTool, ToolKind::SopExecute); tool_attribution!(SopListTool, ToolKind::SopList); tool_attribution!(SopStatusTool, ToolKind::SopStatus); tool_a...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>ror); let jobs = cron::list_jobs(&cfg).unwrap(); assert_eq!(jobs.len(), 1); assert_eq!( jobs[0].allowed_tools, Some(vec!["file_read".into(), "web_search".into()]) ); } #[tokio::test] async fn empty_allowed_tools_stored_as_none() { ...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>use crate::cron::{CronJob, CronJobPatch, Schedule, deserialize_maybe_stringified}; use chrono::DateTime; use serde_json::{Value, json}; use std::str::FromStr; pub(crate) const CRON_TZ_DESCRIPTION: &str = "Optional explicit IANA timezone name, e.g. 'America/New_York'. If omitted, the schedule uses the run...
fim
zeroclaw-labs/zeroclaw
rust
use super::cron_common::cron_job_output; use crate::cron; use async_trait::async_trait; use serde_json::json; use std::sync::Arc; use zeroclaw_api::tool::{Tool, ToolResult}; use zeroclaw_config::schema::Config; pub struct CronListTool { config: Arc<Config>, } impl CronListTool { pub fn new(config: Arc<Config>...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|> let cfg = Arc::new(config); let job = cron::add_job(&cfg, TEST_AGENT, "*/5 * * * *", "echo ok").unwrap(); let tool = CronRemoveTool::new(cfg.clone(), test_security(&cfg)); let result = tool.execute(json!({"job_id": job.id})).await.unwrap(); assert!(!result.success); ...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|> config .risk_profiles .entry(TEST_AGENT.to_string()) .or_default(); config .runtime_profiles .entry(TEST_AGENT.to_string()) .or_default(); config .providers .models .ensure("op...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>use crate::cron; use async_trait::async_trait; use serde::Serialize; use serde_json::json; use std::sync::Arc; use zeroclaw_api::tool::{Tool, ToolResult}; use zeroclaw_config::schema::Config; const MAX_RUN_OUTPUT_CHARS: usize = 500; pub struct CronRunsTool { config: Arc<Config>, } impl CronRunsTool...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>clone(&security), TEST_AGENT, ); let update_tool = CronUpdateTool::new(cfg, security, TEST_AGENT); let add_schema = add_tool.parameters_schema(); let update_schema = update_tool.parameters_schema(); let add_channels: Vec<&str> = add_schema["properties"]...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>use crate::security::SecurityPolicy; use async_trait::async_trait; use serde_json::json; use std::sync::Arc; use zeroclaw_api::tool::{Tool, ToolResult, with_ephemeral_workspace_warning}; const MAX_FILE_SIZE_BYTES: u64 = 10 * 1024 * 1024; /// Read file contents with workspace sandboxing. pub struct FileR...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! Tool subsystem for agent-callable capabilities. //! //! This module implements the tool execution surface exposed to the LLM during //! agentic loops. Each tool implements the [`Tool`] trait defined in the //! `traits` submodule, which requires a name, description, JSON parameter //! schema, and an as...
fim
zeroclaw-labs/zeroclaw
rust
use crate::agent::loop_::get_model_switch_state; use crate::security::SecurityPolicy; use crate::security::policy::ToolOperation; use async_trait::async_trait; use serde_json::json; use std::sync::Arc; use zeroclaw_api::tool::{Tool, ToolResult}; use zeroclaw_config::schema::Config; fn configured_model_provider_profile...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>; assert!(result.output.contains("# Weather")); assert!(result.output.contains("forecast lookups")); } #[tokio::test] async fn reads_toml_skill_manifest_by_name() { let tmp = TempDir::new().unwrap(); let skill_dir = tmp.path().join("workspace/skills/deploy"); ...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>use crate::cron; use crate::security::SecurityPolicy; use anyhow::Result; use async_trait::async_trait; use chrono::{DateTime, Utc}; use serde_json::json; use std::sync::Arc; use zeroclaw_api::tool::{Tool, ToolResult}; use zeroclaw_config::schema::Config; /// Tool that lets the agent manage recurring and...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! Security operations tool for managed cybersecurity service (MCSS) workflows. //! //! Provides alert triage, incident response playbook execution, vulnerability //! scan parsing, and security report generation. All actions that modify state //! enforce human approval gates unless explicitly configured ...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! Agent-loop tool that sends a message to a configured peer on a //! shared channel. //! //! Validates the target against [`crate::peers::ResolvedPeers`] for //! the calling agent on the requested channel: peers must mutually //! opt in via a `[peer_groups.<name>]` block whose `agents` lists //! both, O...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>use crate::platform::RuntimeAdapter; use crate::security::SecurityPolicy; use crate::security::traits::Sandbox; use async_trait::async_trait; use serde_json::json; use std::collections::{HashMap, HashSet}; use std::sync::Arc; use std::time::Duration; use zeroclaw_api::tool::{Tool, ToolResult, with_ephemer...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! HTTP-based tool derived from a skill's `[[tools]]` section. //! //! Each `SkillTool` with `kind = "http"` is converted into a `SkillHttpTool` //! that implements the `Tool` trait. The command field is used as the URL //! template and args are substituted as query parameters or path segments. use asyn...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>: String, } impl ::zeroclaw_api::attribution::Attributable for EchoArgsTool { fn role(&self) -> ::zeroclaw_api::attribution::Role { ::zeroclaw_api::attribution::Role::Tool(::zeroclaw_api::attribution::ToolKind::Plugin) } fn alias(&self) -> &str { &se...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>use std::sync::{Arc, Mutex}; use async_trait::async_trait; use serde_json::json; use crate::sop::types::{SopRunAction, SopStepResult, SopStepStatus}; use crate::sop::{SopAuditLogger, SopEngine, SopMetricsCollector}; use zeroclaw_api::tool::{Tool, ToolResult}; /// Report a step result and advance an SOP...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|> .collect(); assert!( !approval_keys.is_empty(), "approval audit should be written on approve" ); } #[tokio::test] async fn approve_failure_does_not_write_audit() { let engine = Arc::new(Mutex::new(SopEngine::new(SopConfig::default())));...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>use std::sync::{Arc, Mutex}; use async_trait::async_trait; use serde_json::json; use crate::sop::types::{SopEvent, SopRunAction, SopTriggerSource}; use crate::sop::{SopAuditLogger, SopEngine}; use zeroclaw_api::tool::{Tool, ToolResult}; /// Manually trigger an SOP by name. Returns the run ID and first ...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|><Sop>) -> Arc<Mutex<SopEngine>> { let mut engine = SopEngine::new(SopConfig::default()); engine.set_sops_for_test(sops); Arc::new(Mutex::new(engine)) } #[tokio::test] async fn list_all_sops() { let engine = engine_with_sops(vec![ test_sop("pump-shut...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>use std::fmt::Write; use std::sync::{Arc, Mutex}; use async_trait::async_trait; use serde_json::json; use crate::sop::{SopEngine, SopMetricsCollector}; use zeroclaw_api::tool::{Tool, ToolResult}; /// Query SOP execution status β€” active runs, finished runs, or a specific run by ID. pub struct SopStatusT...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! Agent-loop tool that spawns an ephemeral SubAgent inheriting the //! parent's identity, security policy, and memory allowlist, runs a //! focused prompt, and returns the response. Cron's `JobType::Agent` //! dispatch is the other SubAgent spawn site; both funnel through //! [`crate::subagent::SubAgent...
fim
zeroclaw-labs/zeroclaw
rust
//! Verifiable Intent tool β€” exposes VI verification and constraint evaluation //! to the agent orchestration loop. use async_trait::async_trait; use serde_json::json; use std::sync::Arc; use crate::security::SecurityPolicy; use crate::security::policy::ToolOperation; use crate::verifiable_intent::error::ViError; use...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>d tests; <|fim_prefix|>pub mod types; pub use types::*; #[cfg(test<|fim_middle|>)] mo<|endoftext|>
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>use super::*; use chrono::{Duration, Utc}; // ── TrustConfig Tests ────────────────────────────────────────── #[test] fn trust_config_defaults() { let config = TrustConfig::default(); assert_eq!(config.initial_score, 0.8); assert_eq!(config.decay_half_life_days, 30.0); assert_eq!(config....
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; pub use zeroclaw_config::scattered_types::TrustConfig; /// Per-domain trust score #[derive(Debug, Clone, Serialize, Deseria<|fim_suffix|> .iter() .filter(|e| e.domain == domain) .c...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>use super::{SharedProcess, Tunnel, TunnelProcess, kill_shared, new_shared_process}; use anyhow::{Result, bail}; use tokio::io::AsyncBufReadExt; use tokio::process::Command; /// Try to extract a real tunnel URL from a cloudflared log line. /// /// Returns `Some(url)` when the line contains a genuine tunne...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>er.next_line()) .await; match line { Ok(Ok(Some(l))) => { ::zeroclaw_log::record!( DEBUG, ::zeroclaw_log::Event::new( module_path!(),...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>.openvpn]"); } #[test] fn factory_openvpn_with_config_ok() { let cfg = TunnelConfig { tunnel_provider: "openvpn".into(), openvpn: Some(OpenVpnTunnelConfig { config_file: "client.ovpn".into(), auth_file: None, adve...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>use super::{SharedProcess, Tunnel, TunnelProcess, kill_shared, new_shared_process}; use anyhow::{Result, bail}; use tokio::io::AsyncBufReadExt; use tokio::process::Command; /// ngrok Tunnel β€” wraps the `ngrok` binary. /// /// Requires `ngrok` installed. Optionally set a custom domain /// (requires ngrok ...
fim
zeroclaw-labs/zeroclaw
rust
use super::Tunnel; use anyhow::Result; /// No-op tunnel β€” direct local access, no external exposure. pub struct NoneTunnel; #[async_trait::async_trait] impl Tunnel for NoneTunnel { fn name(&self) -> &str { "none" } async fn start(&self, local_host: &str, local_port: u16) -> Result<String> { ...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|> let tunnel = OpenVpnTunnel::new("client.ovpn".into(), None, None, 30, vec![]); assert!(tunnel.public_url().is_none()); } #[tokio::test] async fn health_check_is_false_before_start() { let tunnel = OpenVpnTunnel::new("client.ovpn".into(), None, None, 30, vec![]); ...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>t mut guard = self.proc.lock().await; *guard = Some(TunnelProcess { child, public_url: public_url.clone(), }); Ok(public_url) } async fn stop(&self) -> Result<()> { kill_shared(&self.proc).await } async fn health_check(&self) -> bo...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|> child, public_url: public_url.clone(), }); Ok(public_url) } async fn stop(&self) -> Result<()> { // Also reset the tailscale serve/funnel let subcommand = if self.funnel { "funnel" } else { "serve" }; Command::new("tailscale") .a...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! Utility functions for `ZeroClaw`. //! //! This module contains reusable helper functions used across the codebase. /// Allowed serial device path prefixes β€” reject arbitrary paths for security. /// Used by hardware serial transport and peripherals. const SERIAL_ALLOWED_PATH_PREFIXES: &[&str] = &[ ...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|> result } /// Parse a serialized SD-JWT into (issuer_jwt, disclosures, optional_kb_jwt). pub fn parse_sd_jwt(serialized: &str) -> Result<(&str, Vec<&str>, Option<&str>), ViError> { let parts: Vec<&str> = serialized.split('~').collect(); if parts.len() < 2 { return Err(ViError::new( ...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! Machine-readable error taxonomy for Verifiable Intent operations. //! //! Every VI error carries a [`ViErrorKind`] discriminant so policy engines and //! tool gates can branch deterministically on failure reason without parsing //! human-readable messages. use std::fmt; /// Discriminant for VI error...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|> payment_amount: PaymentAmount { currency: "USD".into(), amount: 27999, }, payee: Entity { id: None, name: "Test Store".into(), website: "https://store.example.com".into(), }, ...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>, binding integrity. //! - [`issuance`] β€” L2/L3 credential construction. //! - [`error`] β€” Machine-readable error taxonomy for policy decisions. //! //! # Extension //! //! This module is an internal subsystem. Integration into the tool execution //! surface is handled by the tool layer (see `src/tools/`)...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! Core data models for the Verifiable Intent credential chain. //! //! These types mirror the normative specification (credential-format.md, //! constraints.md) while staying idiomatic Rust. Monetary amounts use integer //! minor-units (cents) per ISO 4217 throughout to eliminate decimal ambiguity. us...
fim
zeroclaw-labs/zeroclaw
rust
//! Chain verification, constraint checking, and binding integrity validation. //! //! Implements the normative verification algorithms from the VI specification: //! - Full credential chain verification (L1 β†’ L2 β†’ L3) //! - Per-constraint validation against fulfillment data //! - Cross-reference and hash binding integ...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! Integration test for #5415 (follow-up to #5456). //! //! Reproduces the chat β†’ scheduled-task leak at the agent-loop level. The //! daemon heartbeat path (`crates/zeroclaw-runtime/src/daemon/mod.rs`) calls //! `agent::run(..., interactive=false, session_state_file=None, ...)`. With //! no session_stat...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>nts ); } } <|fim_prefix|>//! `zeroclaw-spawn` β€” the sanctioned interface against `tokio::spawn` for //! the ZeroClaw workspace. //! //! Every call site that needs to fan out a background task must go //! through [`spawn!`] instead of reaching for `tokio::spawn` directly. //! Doing so buys two ...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>t_secs": 5 })) .await .unwrap(); assert!(result.success, "error: {:?}", result.error); assert_eq!(result.output, "2"); } #[tokio::test] async fn channel_map_handle_allows_late_binding() { let handle = Arc::new(RwLock::new(HashMap::ne...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! Centralized `Attributable` impls for every concrete `Tool` in this //! crate. Each invocation surfaces `Role::Tool(ToolKind::*)` and uses //! the tool's `name()` as its alias so log emissions can attribute //! tool activity with the same `<kind>.<alias>` composite the rest of //! the runtime uses for ...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>use async_trait::async_trait; use serde_json::json; use sha2::{Digest, Sha256}; use std::collections::HashMap; use std::path::{Path, PathBuf}; use tokio::fs;<|fim_suffix|> let file_count = checksums.len(); let manifest = serde_json::to_string_pretty(&checksums)?; fs::write(backup_dir...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>hes("sub.example.com", "example.com")); } #[test] fn domain_matches_case_insensitive() { assert!(domain_matches("Example.COM", "example.com")); } #[test] fn domain_does_not_match_partial() { assert!(!domain_matches("notexample.com", "example.com")); } // ...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|> .unwrap(); assert!(!result.success); assert!(result.error.unwrap().contains("read-only")); } #[tokio::test] async fn execute_blocks_when_rate_limited() { let security = Arc::new(SecurityPolicy { max_actions_per_hour: 0, ..SecurityPolicy::de...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>ng, String> { let values = extract_values(args, 1)?; let Some(min_val) = values.iter().copied().reduce(f64::min) else { return Err("Cannot compute min of an empty array".to_string()); }; Ok(format_num(min_val)) } fn calc_max(args: &serde_json::Value) -> Result<String, String> { ...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>llable tool for the Live Canvas (A2UI) system. pub struct CanvasTool { store: CanvasStore, } impl CanvasTool { pub fn new(store: CanvasStore) -> Self { Self { store } } } #[async_trait] impl Tool for CanvasTool { fn name(&self) -> &str { "canvas" } fn description...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>mand::new(claude_bin); cmd.arg("-p").arg(prompt); cmd.arg("--output-format").arg("json"); if !allowed_tools.is_empty() { for tool in &allowed_tools { cmd.arg("--allowedTools").arg(tool); } } if let Some(ref sp) = system_prom...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_suffix|>), ..SecurityPolicy::default() }); let tool = ClaudeCodeRunnerTool::new(security, test_config(), "http://localhost:3000".into()); let result = tool .execute(json!({"prompt": "hello"})) .await .expect("rate-limited should r...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! CLI tool auto-discovery β€” scans PATH for known CLI tools. //! Zero external dependencies (uses `std::process::Command` + `std::env`). use std::path::PathBuf; /// Category of a discovered CLI tool. #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize)] pub enum CliCategory { VersionControl, ...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! Cloud operations advisory tool for cloud transformation analysis. //! //! Provides read-only analysis capabilities: IaC review, migration assessment, //! cost analysis, and Well-Architected Framework architecture review. //! This tool does NOT create, modify, or delete cloud resources. use crate::uti...
fim
zeroclaw-labs/zeroclaw
rust
<|fim_prefix|>//! Cloud pattern library for recommending cloud-native architectural patterns. //! //! Provides a built-in set of cloud migration and modernization patterns, //! with pattern matching against workload descriptions. use crate::util_helpers::truncate_with_ellipsis; use async_trait::async_trait; use serde:...
fim
zeroclaw-labs/zeroclaw
rust