1pub mod governance;
2pub mod harness;
3pub mod harness_loop;
4pub mod knowledge;
5pub mod memory;
6pub mod providers;
7pub mod run_event;
8pub mod runtime;
9pub mod safety;
10pub mod signals;
11pub mod tools;
12
13#[cfg(test)]
14mod tests;
15
16pub use deepstrike_core::context::renderer::RenderedContext;
17pub use deepstrike_core::governance::permission::PermissionAction;
18pub use deepstrike_core::governance::quota::ResourceQuota;
19pub use deepstrike_core::mm::memory::{
20 MemoryKind, MemoryMetadata, MemoryPolicy, MemoryQuery, MemoryRetrieval, MemoryWriteRequest,
21};
22pub use deepstrike_core::orchestration::workflow::{
23 ClassifyAndAct, WorkflowNode, WorkflowSpec, classify_and_act, fanout_synthesize,
24 generate_and_filter,
25};
26pub use deepstrike_core::orchestration::workflow::{JudgeMatch, WorkflowRun, WorkflowSpawnInfo};
27pub use governance::{Governance, GovernanceVerdict};
28pub use harness::{CriterionResult, Harness, HarnessEvent, HarnessOutcome, HarnessRequest, QualityGate};
29pub use harness_loop::{EvalLoopHarness, HarnessLoop, SinglePassHarness, VerdictCtx, VerdictFn};
30pub use knowledge::KnowledgeSource;
31pub use memory::{DreamResult, DreamStore, InMemoryDreamStore, WorkingMemory};
32pub use providers::RuntimePolicy;
33pub use providers::anthropic::AnthropicProvider;
34pub use providers::openai::{OpenAIProvider, deepseek, kimi, minimax, ollama, qwen};
35pub use providers::{LLMProvider, ProviderRunState, ProviderToolSpec, StreamEvent, TokenUsage};
36pub use run_event::RunEvent;
37pub use runtime::{
38 ChainedCredentialVault, CredentialVault, EnvCredentialVault, InMemoryCredentialVault,
39};
40pub use runtime::{ExecutionPlane, LocalExecutionPlane};
41pub use runtime::{FileSessionLog, InMemorySessionLog, SessionEntry, SessionLog};
42pub use runtime::replay_provider::{ReplayProvider, ReplayProviderOpts};
43pub use runtime::replay_fixture::{extract_recorded_messages, extract_recorded_messages_from_entries};
44pub use runtime::eval::{judge, build_eval_messages, parse_verdict, verdict_output_schema, Criterion, Verdict};
45pub use runtime::{McpProxyPlane, McpServerConfig};
46pub use runtime::{
47 AttentionPolicy, GovernancePolicy, MemoryWriteRateLimit, NativeOsProfile, OsProfile,
48 SchedulerBudget, assert_native_profile, default_native_governance_policy, os_profile,
49 DEFAULT_NATIVE_ATTENTION_POLICY,
50};
51pub use runtime::{
52 MilestoneEvaluationContext, MilestoneEvaluationHandler, MilestonePolicy, RuntimeOptions,
53 RuntimeRunner, collect_text,
54};
55pub use runtime::{
56 PermissionRequest, PermissionRequestHandler, PermissionResponse, RunContext,
57 ToolSuspendHandler, ToolSuspendRequest,
58};
59pub use runtime::{ProcessSandboxPlane, SandboxOptions};
60pub use runtime::{RemoteVpcOptions, RemoteVpcPlane};
61pub use safety::{Permission, PermissionDecision, PermissionManager, PermissionMode};
62pub use signals::{GatewayReceiver, RuntimeSignal, ScheduledPrompt, SignalGateway, SignalSource};
63pub use tools::{
64 RegisteredTool, SafeToolResult, TextToolSession, ToolChunk, ToolEnvelope, ToolEnvelopeFail,
65 ToolEnvelopeOk, ToolSession, ToolStep, execute_tools, fail, ok, read_file_tool, safe_tool,
66 tool_fail, validate_tool_arguments,
67};
68
69#[derive(Debug, thiserror::Error)]
70pub enum Error {
71 #[error("provider error: {0}")]
72 Provider(String),
73 #[error("tool error: {0}")]
74 Tool(String),
75 #[error("io error: {0}")]
76 Io(#[from] std::io::Error),
77 #[error("tool execution failed: {output}")]
78 ToolExecutionFailed {
79 output: String,
80 is_fatal: bool,
81 error_kind: Option<deepstrike_core::types::message::ToolErrorKind>,
82 },
83 #[error("{output}")]
88 ToolFail {
89 output: String,
90 code: Option<String>,
91 hint: Option<String>,
92 is_fatal: bool,
93 error_kind: Option<deepstrike_core::types::message::ToolErrorKind>,
94 },
95 #[error("{0}")]
96 Other(String),
97}
98
99pub fn format_tool_error(e: &Error) -> String {
108 match e {
109 Error::Tool(s) => s.clone(),
110 Error::ToolExecutionFailed { output, .. } => output.clone(),
111 Error::ToolFail { output, code, hint, .. } => {
112 if code.is_none() && hint.is_none() {
113 return output.clone();
114 }
115 let mut obj = serde_json::Map::with_capacity(3);
116 obj.insert("message".to_string(), serde_json::Value::String(output.clone()));
117 if let Some(c) = code {
118 obj.insert("code".to_string(), serde_json::Value::String(c.clone()));
119 }
120 if let Some(h) = hint {
121 obj.insert("hint".to_string(), serde_json::Value::String(h.clone()));
122 }
123 serde_json::to_string(&serde_json::Value::Object(obj)).unwrap_or_else(|_| output.clone())
124 }
125 _ => e.to_string(),
126 }
127}
128
129pub type Result<T> = std::result::Result<T, Error>;