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, ConflictInfo, DependencyRef, SubmitError, SymbolRef,
4    SymbolResult, VerifyStepResult, WatchEvent,
5};
6
7/// A high-level representation of a code change that the SDK translates into
8/// the proto `Change` message before sending to the server.
9#[derive(Debug, Clone)]
10pub enum Change {
11    Add { path: String, content: String },
12    Modify { path: String, content: String },
13    Delete { path: String },
14}
15
16impl Change {
17    /// Convenience constructor for an add change.
18    pub fn add(path: impl Into<String>, content: impl Into<String>) -> Self {
19        Change::Add {
20            path: path.into(),
21            content: content.into(),
22        }
23    }
24
25    /// Convenience constructor for a modify change.
26    pub fn modify(path: impl Into<String>, content: impl Into<String>) -> Self {
27        Change::Modify {
28            path: path.into(),
29            content: content.into(),
30        }
31    }
32
33    /// Convenience constructor for a delete change.
34    pub fn delete(path: impl Into<String>) -> Self {
35        Change::Delete { path: path.into() }
36    }
37}
38
39/// Depth of context retrieval.
40#[derive(Debug, Clone, Copy)]
41pub enum Depth {
42    Signatures,
43    Full,
44    CallGraph,
45}
46
47/// Filter for watch events.
48#[derive(Debug, Clone)]
49pub enum Filter {
50    All,
51    Symbols,
52    Files,
53}
54
55/// Result of a successful CONNECT handshake.
56#[derive(Debug)]
57pub struct ConnectResult {
58    pub session_id: String,
59    pub changeset_id: String,
60    pub codebase_version: String,
61    pub summary: Option<CodebaseSummary>,
62}
63
64/// Result of a CONTEXT query.
65#[derive(Debug)]
66pub struct ContextResult {
67    pub symbols: Vec<SymbolResult>,
68    pub call_graph: Vec<CallEdgeRef>,
69    pub dependencies: Vec<DependencyRef>,
70    pub estimated_tokens: u32,
71}
72
73/// Result of a SUBMIT operation.
74#[derive(Debug)]
75pub struct SubmitResult {
76    pub changeset_id: String,
77    pub status: String,
78    pub errors: Vec<SubmitError>,
79}
80
81/// Result of a MERGE operation.
82#[derive(Debug)]
83pub struct MergeResult {
84    pub commit_hash: String,
85    pub merged_version: String,
86    pub conflicts: Vec<ConflictInfo>,
87}