Skip to content

The platform for continuously improving AI agents.

4.8 KB
Raw Blame
syntax = "proto3";

package api.v1;
service GraphService {
  rpc GetGraph(GetGraphRequest) returns (GetGraphResponse);
  rpc ListPaths(ListPathsRequest) returns (ListPathsResponse);
  rpc GetPathDetail(GetPathDetailRequest) returns (GetPathDetailResponse);
  rpc RebuildGraph(RebuildGraphRequest) returns (RebuildGraphResponse);
}

message NodeCodeContext {
  repeated string filepaths = 1;
  repeated string functions = 2;
  repeated string namespaces = 3;
  repeated string capabilities = 4;
  repeated string models = 5;
  repeated string tools = 6;
  repeated string span_types = 7;
}

message GraphNode {
  string node_id = 1;
  string label = 2;
  string kind = 3;
  repeated string services = 4;
  uint64 span_count = 5;
  uint64 trace_count = 6;
  uint64 error_count = 7;
  double avg_duration_ms = 8;
  uint64 total_tokens = 9;
  double total_cost_usd = 10;
  bool is_entry = 11;
  bool is_exit = 12;
  bool has_self_loop = 13;
  NodeCodeContext code_context = 14;
}

message GraphEdge {
  string edge_id = 1;
  string from_node_id = 2;
  string to_node_id = 3;
  string kind = 4;
  uint64 transition_count = 5;
  uint64 trace_count = 6;
  bool is_loop = 7;
  double avg_gap_ms = 8;
}

message PathStep {
  uint32 step_index = 1;
  string node_id = 2;
  string label = 3;
  string kind = 4;
  uint32 depth = 5;
  bool is_loop_back = 6;
}

message GraphPath {
  string path_id = 1;
  string signature = 2;
  string collapsed_signature = 3;
  repeated PathStep steps = 4;
  repeated string node_ids = 5;
  repeated string edge_ids = 6;
  bool has_loops = 7;
  uint32 loop_count = 8;
  uint32 max_depth = 9;
  repeated string services = 10;
  uint64 trace_count = 11;
  uint64 error_count = 12;
  double avg_duration_ms = 13;
  double p95_duration_ms = 14;
  uint64 total_tokens = 15;
  double total_cost_usd = 16;
  uint64 llm_call_count = 17;
  uint64 tool_call_count = 18;
  uint64 eval_count = 19;
  optional double avg_eval_score = 20;
  int64 first_seen_ns = 21;
  int64 last_seen_ns = 22;
}

message CodebaseContext {
  repeated string services = 1;
  repeated string entrypoints = 2;
  repeated string exits = 3;
  repeated string models = 4;
  repeated string tools = 5;
  repeated string code_files = 6;
  repeated string code_functions = 7;
  repeated string capabilities = 8;
  repeated string loop_nodes = 9;
  uint64 total_traces = 10;
  uint64 total_spans = 11;
  uint64 total_paths = 12;
  uint64 revision = 13;
  int64 last_amended_at_ns = 14;
}

message PathLlmCallSummary {
  string node_id = 1;
  string label = 2;
  optional string model = 3;
  uint64 call_count = 4;
  uint64 error_count = 5;
  double avg_duration_ms = 6;
  optional double avg_input_tokens = 7;
  optional double avg_output_tokens = 8;
  double total_cost_usd = 9;
  repeated string finish_reasons = 10;
}

message PathToolCallSummary {
  string node_id = 1;
  string tool_name = 2;
  uint64 call_count = 3;
  uint64 error_count = 4;
  double avg_duration_ms = 5;
}

message PathEvalSummary {
  string name = 1;
  string kind = 2;
  uint64 count = 3;
  uint64 passed_count = 4;
  uint64 failed_count = 5;
  optional double avg_score = 6;
}

message PathCodeContext {
  repeated string services = 1;
  repeated string files = 2;
  repeated string functions = 3;
  repeated string capabilities = 4;
  repeated string models = 5;
  repeated string tools = 6;
}

message PathTraceEvalSummary {
  uint64 count = 1;
  uint64 passed_count = 2;
  uint64 failed_count = 3;
  optional double avg_score = 4;
}

message PathTraceRef {
  string trace_id = 1;
  string service_name = 2;
  string root_span_name = 3;
  int64 start_time_ns = 4;
  double duration_ms = 5;
  int32 status_code = 6;
  uint64 span_count = 7;
  uint64 llm_calls = 8;
  uint64 tool_calls = 9;
  uint64 total_tokens = 10;
  double cost_usd = 11;
  PathTraceEvalSummary eval_summary = 12;
  optional string output_label = 13;
}

message GetGraphRequest {
  string service_name = 1;
  uint32 limit_paths = 2;
}

message GetGraphResponse {
  repeated GraphNode nodes = 1;
  repeated GraphEdge edges = 2;
  repeated GraphPath paths = 3;
  CodebaseContext context = 4;
}

message ListPathsRequest {
  string service_name = 1;
  string node_id = 2;
  uint32 limit = 3;
}

message ListPathsResponse {
  repeated GraphPath paths = 1;
}

message GetPathDetailRequest {
  string path_id = 1;
  uint32 trace_limit = 2;
}

message GetPathDetailResponse {
  GraphPath path = 1;
  double share_of_traces = 2;
  repeated PathLlmCallSummary llm_calls = 3;
  repeated PathToolCallSummary tool_calls = 4;
  repeated PathEvalSummary evals = 5;
  PathCodeContext code_context = 6;
  repeated PathTraceRef traces = 7;
}

message RebuildGraphRequest {}

message RebuildGraphResponse {
  uint64 scanned_traces = 1;
  uint64 amended_traces = 2;
  uint64 skipped_traces = 3;
  uint64 total_nodes = 4;
  uint64 total_edges = 5;
  uint64 total_paths = 6;
  uint64 revision = 7;
}