File size: 4,932 Bytes
30cc31a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
export interface StreamEvent {
  type:
    | "text_delta"
    | "tool_use"
    | "tool_result"
    | "done"
    | "error"
    // ---- v2 events ----
    | "kb_lookup"      // best-practice retrieval, with timing
    | "plan"           // structured plan with tool chips per step
    | "trace"          // execution trace entry
    | "artifact"       // file produced by the agent
    | "citation"       // inline source citation chip for the previous text run
    | "step_status";   // live status pulse for a plan step (Biomni-style todo)
  text?: string;
  tool?: string;
  input?: Record<string, unknown>;
  result?: unknown;
  response?: string;
  error?: string;
  // ---- v2 fields ----
  kb?: { name: string; ms: number };
  plan?: PlanProposal;
  trace?: TraceEntry;
  artifact?: Artifact;
  citation?: Citation;
  step?: { index: number; status: StepStatus };
}

export interface ChatMessage {
  id: string;
  role: "user" | "assistant";
  content: string;
  toolCalls?: ToolCall[];
  kbLookups?: KBLookup[];
  trace?: TraceEntry[];
  plan?: PlanProposal;
  artifacts?: Artifact[];
  citations?: Citation[];
  /** Per-step live status, parallel-indexed with `plan.steps`. */
  stepStatus?: StepStatus[];
  isStreaming?: boolean;
}

export interface ToolCall {
  tool: string;
  input: Record<string, unknown>;
  result?: unknown;
  status: "running" | "completed" | "error";
}

// ---- v2 types ----

export interface KBLookup {
  name: string;
  ms: number;
}

export interface PlanStepProto {
  label: string;
  tools: string[];
}

export interface PlanProposal {
  title: string;
  steps: PlanStepProto[];
}

export interface TraceEntry {
  ts: number;          // ms epoch
  kind: "thought" | "tool_call" | "tool_result" | "text";
  label: string;       // short human-readable summary
  detail?: string;     // optional verbose body
}

export interface Artifact {
  id: string;          // stable id
  name: string;        // user-visible filename
  bytes: number;       // size in bytes
  mime: string;        // MIME type
  url: string;         // download URL (relative)
  createdAt: number;   // ms epoch
  hubOutputData?: Record<string, unknown>; // Hub job output_data (scores, PDB, sequences, etc.)
}

export interface Citation {
  label: string;       // chip text e.g. "clinicaltrials.gov/data-api"
  url?: string;        // optional href
}

// ---- Task persistence ----

export interface TaskRecord {
  id: string;          // sess_xxxxxxxx
  projectId: string;   // proj_xxxxxxxx
  title: string;
  createdAt: number;
  updatedAt: number;
  messages: ChatMessage[];
  artifacts: Artifact[];
}

export interface ProjectRecord {
  id: string;          // proj_xxxxxxxx
  name: string;
  createdAt: number;
}

export interface Benchmark {
  source: string;
  paper_title: string;
  paper_url: string;
  paper_date: string;
  avg_hit_rate_vhh: number | null;
  avg_hit_rate_mab: number | null;
  target_coverage: number | null;
  best_affinity_pM: number | null;
  total_designs_tested: number;
  code_available: boolean;
  weights_available: boolean;
  developability: { overall_pass_rate: number | null } | null;
  targets: { name: string; target_class: string }[];
  binding_results: {
    target: string;
    antibody_format: string;
    hit_rate: number | null;
    best_affinity_nM: number | null;
    assay: string;
    notes: string;
  }[];
  notes: string;
}

export interface Skill {
  id: string;
  name: string;
  description: string;
  version: string;
  author: string;
  inputs: Record<string, unknown>;
  outputs: Record<string, unknown>;
  // ---- Optional fields populated from the Hub registry passthrough ----
  category?: string;
  tier?: string;
  gpu?: boolean;
  gpuType?: string;
  minRamGb?: number;
  typicalRuntimeSeconds?: number;
}

// ---- Dataset connector types ----

export interface DatasetSearchResult {
  id: string;
  source: "sabdab" | "oas" | "imgt" | "fc";
  title: string;
  summary: string;
  organism?: string;
  data_type: "structure" | "sequence" | "gene";
}

export interface DatasetSearchResponse {
  results: Record<string, DatasetSearchResult[]>;
  errors: Record<string, string>;
  query: Record<string, unknown>;
}

export interface SyncStatusEntry {
  source: string;
  last_synced: string | null;
  entry_count: number;
  size_bytes: number;
  status: "synced" | "syncing" | "error" | "not_synced" | "not_configured";
}

export type ResourceKind = "target" | "benchmark" | "model" | "skill" | "sabdab" | "imgt" | "oas";

export interface ResourceRef {
  type: ResourceKind;
  id: string;
  label: string;
  sublabel?: string;
}

export interface ModelEntry {
  name: string;
  version: string;
  source: string;
  capabilities: string[];
  repo_url: string | null;
  license: string | null;
  gpu_required: boolean;
  min_vram_gb: number;
  antibody_formats: string[];
  notes: string;
}

export type StepStatus = "pending" | "running" | "done" | "error";