Skip to main content

dk_agent_sdk/
types.rs

1// Re-export proto types that SDK consumers will use directly.
2pub use dk_protocol::{
3    CallEdgeRef, CodebaseSummary, ConflictDetail, DependencyRef, MergeConflict, MergeSuccess,
4    RecentOverwriteWarning, SubmitError, SymbolOverwrite, SymbolRef, SymbolResult,
5    VerifyStepResult, WatchEvent,
6};
7
8/// A high-level representation of a code change that the SDK translates into
9/// the proto `Change` message before sending to the server.
10#[derive(Debug, Clone)]
11pub enum Change {
12    Add { path: String, content: String },
13    Modify { path: String, content: String },
14    Delete { path: String },
15}
16
17impl Change {
18    /// Convenience constructor for an add change.
19    pub fn add(path: impl Into<String>, content: impl Into<String>) -> Self {
20        Change::Add {
21            path: path.into(),
22            content: content.into(),
23        }
24    }
25
26    /// Convenience constructor for a modify change.
27    pub fn modify(path: impl Into<String>, content: impl Into<String>) -> Self {
28        Change::Modify {
29            path: path.into(),
30            content: content.into(),
31        }
32    }
33
34    /// Convenience constructor for a delete change.
35    pub fn delete(path: impl Into<String>) -> Self {
36        Change::Delete { path: path.into() }
37    }
38}
39
40/// Depth of context retrieval.
41#[derive(Debug, Clone, Copy)]
42pub enum Depth {
43    Signatures,
44    Full,
45    CallGraph,
46}
47
48/// Filter for watch events.
49#[derive(Debug, Clone)]
50pub enum Filter {
51    All,
52    Symbols,
53    Files,
54}
55
56/// Result of a successful CONNECT handshake.
57#[derive(Debug)]
58pub struct ConnectResult {
59    pub session_id: String,
60    pub changeset_id: String,
61    pub codebase_version: String,
62    pub summary: Option<CodebaseSummary>,
63}
64
65/// Result of a CONTEXT query.
66#[derive(Debug)]
67pub struct ContextResult {
68    pub symbols: Vec<SymbolResult>,
69    pub call_graph: Vec<CallEdgeRef>,
70    pub dependencies: Vec<DependencyRef>,
71    pub estimated_tokens: u32,
72}
73
74/// Result of a SUBMIT operation.
75#[derive(Debug)]
76pub struct SubmitResult {
77    pub changeset_id: String,
78    pub status: String,
79    pub errors: Vec<SubmitError>,
80}
81
82/// Result of a MERGE operation.
83#[derive(Debug)]
84pub enum MergeResult {
85    /// Merge succeeded — changeset is now a Git commit.
86    Success(MergeSuccess),
87    /// Merge blocked by conflicts — agent must resolve.
88    Conflict(MergeConflict),
89    /// Merge blocked by recent overwrite — agent must force or abort.
90    OverwriteWarning(RecentOverwriteWarning),
91}