Skip to main content

mars_agents/build/
bundle.rs

1use std::collections::BTreeMap;
2
3use serde::Serialize;
4
5pub const SLOT_PLACEHOLDER: &str = "###SLOT###";
6
7#[derive(Debug, Clone, Serialize)]
8pub struct LaunchBundle {
9    pub version: u32,
10    pub agent: Option<String>,
11    #[serde(skip_serializing_if = "Option::is_none")]
12    pub agent_body: Option<String>,
13    pub routing: Routing,
14    pub execution_policy: ExecutionPolicy,
15    pub prompt_surface: PromptSurface,
16    pub scaffold_slots: ScaffoldSlots,
17    pub tools: ToolsSpec,
18    pub skills_metadata: SkillsMetadata,
19    pub provenance: BTreeMap<String, String>,
20    pub warnings: Vec<String>,
21}
22
23#[derive(Debug, Clone, Serialize)]
24pub struct Routing {
25    pub model: String,
26    pub model_token: String,
27    pub harness: String,
28    pub selection_kind: String,
29    pub match_evidence: String,
30    pub harness_model: String,
31    pub harness_model_source: String,
32    pub harness_model_confidence: String,
33    pub route_trace: crate::routing::report::RouteDecisionReport,
34}
35
36#[derive(Debug, Clone, Serialize)]
37pub struct CodexRule {
38    pub name: String,
39    pub content: String,
40}
41
42#[derive(Debug, Clone, Serialize)]
43pub struct ExecutionPolicy {
44    pub effort: Option<String>,
45    pub approval: Option<String>,
46    pub sandbox: Option<String>,
47    pub autocompact: Option<u32>,
48    pub autocompact_pct: Option<u8>,
49    pub timeout: Option<u32>,
50    #[serde(skip_serializing_if = "Option::is_none")]
51    pub native_config: Option<serde_json::Map<String, serde_json::Value>>,
52    #[serde(skip_serializing_if = "Option::is_none")]
53    pub codex_rules: Option<Vec<CodexRule>>,
54}
55
56#[derive(Debug, Clone, Serialize)]
57pub struct PromptSurface {
58    pub system_instruction: String,
59    pub supplemental_documents: Vec<SupplementalDoc>,
60    pub inventory_prompt: String,
61}
62
63#[derive(Debug, Clone, Serialize)]
64pub struct ScaffoldSlots {
65    pub completion_contract: String,
66    pub context_prompt: String,
67    pub user_prompt_file: String,
68    pub context_files: String,
69    pub prior_session_context: String,
70    pub spawn_metadata: String,
71}
72
73impl ScaffoldSlots {
74    pub fn placeholders() -> Self {
75        Self {
76            completion_contract: SLOT_PLACEHOLDER.to_string(),
77            context_prompt: SLOT_PLACEHOLDER.to_string(),
78            user_prompt_file: SLOT_PLACEHOLDER.to_string(),
79            context_files: SLOT_PLACEHOLDER.to_string(),
80            prior_session_context: SLOT_PLACEHOLDER.to_string(),
81            spawn_metadata: SLOT_PLACEHOLDER.to_string(),
82        }
83    }
84}
85
86#[derive(Debug, Clone, Serialize)]
87pub struct SupplementalDoc {
88    pub kind: String,
89    pub name: String,
90    pub content: String,
91    pub skill_type: String,
92}
93
94#[derive(Debug, Clone, Serialize)]
95pub struct ToolsSpec {
96    pub allowed: Vec<String>,
97    pub disallowed: Vec<String>,
98    pub mcp: Vec<String>,
99}
100
101#[derive(Debug, Clone, Serialize)]
102pub struct SkillsMetadata {
103    pub loaded: Vec<String>,
104    pub missing: Vec<String>,
105}