-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapi-client.ts
More file actions
797 lines (711 loc) · 22.4 KB
/
Copy pathapi-client.ts
File metadata and controls
797 lines (711 loc) · 22.4 KB
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000';
// Types
export interface Repository {
id: string;
github_url: string;
github_owner: string;
github_name: string;
status: 'pending' | 'cloning' | 'parsing' | 'embedding' | 'completed' | 'failed';
description?: string;
primary_language?: string;
languages: string[];
total_files: number;
total_chunks: number;
last_indexed_at?: string;
created_at: string;
}
export interface ChatSession {
id: string;
repo_id: string;
title?: string;
created_at: string;
updated_at: string;
}
export interface ChatMessage {
id: string;
role: 'user' | 'assistant';
content: string;
retrieved_chunks?: Array<{ id: string; file: string }>;
retrieval_meta?: Record<string, unknown>;
created_at: string;
}
export interface StreamingChunk {
type: 'content' | 'sources' | 'meta' | 'done' | 'error';
content?: string;
sources?: Array<{
file: string;
content: string;
start_line: number;
end_line: number;
score: number;
}>;
meta?: {
intent?: string;
profile?: string;
grounding?: string;
latency_ms?: {
retrieval?: number;
rerank?: number;
};
debug?: Record<string, unknown>;
};
error?: string;
}
export interface SearchResult {
chunk_id: string;
file_path: string;
content: string;
chunk_type: string;
score: number;
start_line: number;
end_line: number;
}
// Learning Types
export interface Persona {
id: string;
name: string;
description: string;
icon: string;
}
export interface Lesson {
id: string;
title: string;
description: string;
type: 'concept' | 'code_tour' | 'quiz';
estimated_minutes: number;
}
export interface Module {
title: string;
description: string;
lessons: Lesson[];
}
export interface Syllabus {
repo_id: string;
persona: string;
title: string;
description: string;
modules: Module[];
quality_meta?: Record<string, unknown> | null;
cache_info?: CacheInfo | null;
}
export interface CodeReference {
file_path: string;
start_line: number;
end_line: number;
content?: string;
description: string;
}
export interface LessonContent {
id: string;
title: string;
content_markdown: string;
code_references: CodeReference[];
diagram_mermaid?: string;
persona?: string | null;
module_id?: string | null;
quality_meta?: Record<string, unknown> | null;
cache_info?: CacheInfo | null;
}
export interface CacheInfo {
source: string;
generated_at?: string | null;
expires_at?: string | null;
prompt_version?: string | null;
cache_hit?: boolean;
}
export interface CodeTour {
title: string;
steps: Array<{
file: string;
line: number;
description: string;
title?: string;
}>;
}
// API Client
// Quiz Types
export interface Question {
id: string;
text: string;
options: string[];
correct_option_index: number;
explanation: string;
}
export interface Quiz {
lesson_id: string;
questions: Question[];
}
// Gamification Types
export interface LevelInfo {
level: number;
title: string;
icon: string;
current_xp: number;
xp_for_next_level: number;
xp_progress: number;
}
export interface StreakInfo {
current: number;
longest: number;
active_today: boolean;
}
export interface UserStats {
total_xp: number;
level: LevelInfo;
streak: StreakInfo;
lessons_completed: number;
quizzes_passed: number;
challenges_completed: number;
perfect_quizzes: number;
}
export interface Achievement {
key: string;
name: string;
description: string;
icon: string;
category: string;
xp_reward: number;
requirement?: number;
unlocked: boolean;
}
export interface XPGain {
amount: number;
reason: string;
bonus?: number;
bonus_reason?: string;
}
export interface LessonCompleteResponse {
xp_gained: XPGain;
stats: UserStats;
}
export interface QuizResultResponse {
xp_gained: XPGain;
stats: UserStats;
is_pass: boolean;
is_perfect: boolean;
}
// Challenge Types
export type ChallengeType = 'bug_hunt' | 'code_trace' | 'fill_blank';
export interface BugHuntChallengeData {
description: string;
code_snippet: string;
bug_line: number;
bug_description: string;
hint: string;
}
export interface CodeTraceChallengeData {
description: string;
code_snippet: string;
question: string;
options: string[];
correct_index: number;
explanation: string;
}
export interface FillBlankChallengeData {
description: string;
code_with_blanks: string;
blanks: Array<{ id: string; answer: string; options: string[] }>;
}
export type ChallengeData = BugHuntChallengeData | CodeTraceChallengeData | FillBlankChallengeData;
export interface Challenge<TData extends ChallengeData = ChallengeData> {
id: string;
lesson_id: string;
challenge_type: ChallengeType;
data: TData;
completed: boolean;
used_hint: boolean;
}
export interface FillBlankValidationItem {
id: string;
correct: boolean;
correct_answer: string;
user_answer: string;
}
export interface ChallengeResult {
correct: boolean;
explanation?: string;
correct_answer?: string;
correct_line?: number;
correct_index?: number;
results?: FillBlankValidationItem[];
xp_earned?: number;
xp_gained?: XPGain;
stats?: UserStats;
}
export interface PlatformConfig {
demo_mode: boolean;
demo_repo_id?: string | null;
demo_repo_full_name: string;
demo_repo_url: string;
demo_banner_text: string;
allow_public_imports: boolean;
busy_mode: boolean;
}
export class ApiError extends Error {
status: number;
code?: string;
retryAfterSeconds?: number;
constructor(message: string, status: number, code?: string, retryAfterSeconds?: number) {
super(message);
this.name = 'ApiError';
this.status = status;
this.code = code;
this.retryAfterSeconds = retryAfterSeconds;
}
}
class ApiClient {
private baseUrl: string;
constructor() {
this.baseUrl = API_URL;
}
private async toApiError(res: Response, fallbackMessage: string): Promise<ApiError> {
const retryAfterHeader = res.headers.get('Retry-After');
const retryAfter = retryAfterHeader ? Number.parseInt(retryAfterHeader, 10) : undefined;
// Read the body exactly once. res.json() consumes the stream even when parsing
// fails, so a subsequent res.text() throws "body stream already read" -- which is
// why every non-JSON error body (an nginx 502 page, a plain-text 500) used to be
// silently replaced by the generic fallback.
let raw = '';
try {
raw = await res.text();
} catch {
return new ApiError(fallbackMessage, res.status, undefined, retryAfter);
}
let payload: unknown;
try {
payload = JSON.parse(raw);
} catch {
// Not JSON: surface the body itself, which is more useful than a generic string.
return new ApiError(raw.trim() || fallbackMessage, res.status, undefined, retryAfter);
}
const detail = (payload as { detail?: unknown } | null)?.detail;
if (typeof detail === 'string') {
return new ApiError(detail, res.status, undefined, retryAfter);
}
// FastAPI validation errors send `detail` as an *array* of {loc, msg, type}.
// typeof [] === 'object', so the object branch below used to swallow these and
// read .message off an array -- turning every 422 into the generic fallback.
if (Array.isArray(detail)) {
const messages = detail
.map((item) => {
const entry = item as { loc?: unknown[]; msg?: string } | null;
if (!entry?.msg) return null;
const field = Array.isArray(entry.loc)
? entry.loc.filter((p) => p !== 'body').join('.')
: '';
return field ? `${field}: ${entry.msg}` : entry.msg;
})
.filter((m): m is string => Boolean(m));
return new ApiError(messages.join('; ') || fallbackMessage, res.status, 'VALIDATION_ERROR', retryAfter);
}
if (detail && typeof detail === 'object') {
const obj = detail as { message?: string; code?: string; retry_after_seconds?: number };
return new ApiError(
obj.message || fallbackMessage,
res.status,
obj.code,
obj.retry_after_seconds ?? retryAfter,
);
}
return new ApiError(fallbackMessage, res.status, undefined, retryAfter);
}
private async ensureOk(res: Response, fallbackMessage: string): Promise<void> {
if (!res.ok) {
throw await this.toApiError(res, fallbackMessage);
}
}
// Repository endpoints
async createRepo(githubUrl: string, branch?: string): Promise<Repository> {
const res = await fetch(`${this.baseUrl}/api/repos/`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ github_url: githubUrl, branch }),
});
await this.ensureOk(res, 'Failed to import repository');
return res.json();
}
async listRepos(): Promise<{ repositories: Repository[]; total: number }> {
const res = await fetch(`${this.baseUrl}/api/repos/`);
await this.ensureOk(res, 'Failed to fetch repositories');
return res.json();
}
async getRepo(repoId: string): Promise<Repository> {
const res = await fetch(`${this.baseUrl}/api/repos/${repoId}`);
await this.ensureOk(res, 'Failed to fetch repository');
return res.json();
}
async getRepoFileContent(repoId: string, path: string): Promise<{ content: string }> {
// Sanitize path: remove leading @/ or similar aliases that LLMs might hallucinate
const sanitizedPath = path.replace(/^@\//, 'src/').replace(/^~\//, '');
const res = await fetch(`${this.baseUrl}/api/repos/${repoId}/files/content?path=${encodeURIComponent(sanitizedPath)}`);
await this.ensureOk(res, 'Failed to fetch file content');
return res.json();
}
async deleteRepo(repoId: string): Promise<void> {
const res = await fetch(`${this.baseUrl}/api/repos/${repoId}`, {
method: 'DELETE',
});
await this.ensureOk(res, 'Failed to delete repository');
}
async seedDemo(): Promise<{ status: string; repo_id: string; message: string }> {
const res = await fetch(`${this.baseUrl}/api/repos/demo/seed`, {
method: 'POST',
});
await this.ensureOk(res, 'Failed to seed demo repository');
return res.json();
}
async getPlatformConfig(): Promise<PlatformConfig> {
const res = await fetch(`${this.baseUrl}/api/platform/config`);
await this.ensureOk(res, 'Failed to load platform configuration');
return res.json();
}
// Chat endpoints
async createSession(repoId: string): Promise<{ id: string }> {
const res = await fetch(`${this.baseUrl}/api/chat/sessions`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ repo_id: repoId }),
});
await this.ensureOk(res, 'Failed to create chat session');
return res.json();
}
async getSession(sessionId: string): Promise<ChatSession> {
const res = await fetch(`${this.baseUrl}/api/chat/sessions/${sessionId}`);
await this.ensureOk(res, 'Failed to fetch chat session');
return res.json();
}
async *streamChat(sessionId: string, content: string): AsyncGenerator<StreamingChunk> {
const res = await fetch(`${this.baseUrl}/api/chat/sessions/${sessionId}/messages`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ content }),
});
await this.ensureOk(res, 'Failed to send chat message');
const reader = res.body?.getReader();
const decoder = new TextDecoder();
if (!reader) {
throw new Error('No response body');
}
let buffer = '';
while (true) {
const { done, value } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
const lines = buffer.split('\n');
buffer = lines.pop() || '';
for (const line of lines) {
if (line.startsWith('data: ')) {
try {
const data = JSON.parse(line.slice(6));
yield data as StreamingChunk;
} catch {
// Skip invalid JSON
}
}
}
}
}
// Search endpoint
async search(repoId: string, query: string, limit = 10): Promise<{ results: SearchResult[] }> {
const res = await fetch(`${this.baseUrl}/api/search/`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ repo_id: repoId, query, limit }),
});
await this.ensureOk(res, 'Search request failed');
return res.json();
}
// Learning endpoints
async getPersonas(): Promise<Persona[]> {
const res = await fetch(`${this.baseUrl}/api/learning/personas`);
await this.ensureOk(res, 'Failed to fetch personas');
return res.json();
}
async generateSyllabus(
repoId: string,
persona: string,
options?: { forceRegenerate?: boolean; includeQualityMeta?: boolean }
): Promise<Syllabus> {
const res = await fetch(`${this.baseUrl}/api/learning/${repoId}/curriculum`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
persona,
force_regenerate: options?.forceRegenerate ?? false,
include_quality_meta: options?.includeQualityMeta ?? false,
}),
});
await this.ensureOk(res, 'Failed to generate syllabus');
return res.json();
}
async getSyllabus(
repoId: string,
persona: string,
options?: { refresh?: boolean; includeQualityMeta?: boolean }
): Promise<Syllabus> {
const query = new URLSearchParams();
query.set('persona', persona);
if (options?.refresh) query.set('refresh', 'true');
if (options?.includeQualityMeta) query.set('include_quality_meta', 'true');
const res = await fetch(`${this.baseUrl}/api/learning/${repoId}/curriculum?${query.toString()}`);
await this.ensureOk(res, 'Failed to fetch syllabus');
return res.json();
}
async generateLesson(
repoId: string,
lessonId: string,
title: string,
options?: { persona?: string; moduleId?: string; forceRegenerate?: boolean }
): Promise<LessonContent> {
const res = await fetch(`${this.baseUrl}/api/learning/${repoId}/lessons/${lessonId}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
title,
persona: options?.persona,
module_id: options?.moduleId,
force_regenerate: options?.forceRegenerate ?? false,
}),
});
await this.ensureOk(res, 'Failed to generate lesson content');
return res.json();
}
async getLesson(
repoId: string,
lessonId: string,
persona: string,
options?: { refresh?: boolean; moduleId?: string }
): Promise<LessonContent> {
const query = new URLSearchParams();
query.set('persona', persona);
if (options?.refresh) query.set('refresh', 'true');
if (options?.moduleId) query.set('module_id', options.moduleId);
const res = await fetch(`${this.baseUrl}/api/learning/${repoId}/lessons/${lessonId}?${query.toString()}`);
await this.ensureOk(res, 'Failed to fetch lesson content');
return res.json();
}
async generateQuiz(repoId: string, lessonId: string, contextContent: string): Promise<Quiz> {
const res = await fetch(`${this.baseUrl}/api/learning/${repoId}/lessons/${lessonId}/quiz`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ context_content: contextContent }),
});
await this.ensureOk(res, 'Failed to generate quiz');
return res.json();
}
async getDependencyGraph(
repoId: string,
params?: {
granularity?: 'auto' | 'module' | 'file';
scope?: string;
focusNode?: string;
hops?: number;
}
): Promise<DependencyGraph> {
const query = new URLSearchParams();
if (params?.granularity) query.set('granularity', params.granularity);
if (params?.scope) query.set('scope', params.scope);
if (params?.focusNode) query.set('focus_node', params.focusNode);
if (typeof params?.hops === 'number') query.set('hops', String(params.hops));
const qs = query.toString();
const res = await fetch(`${this.baseUrl}/api/learning/${repoId}/graph${qs ? `?${qs}` : ''}`);
await this.ensureOk(res, 'Failed to generate graph');
return res.json();
}
// Gamification endpoints
async getUserStats(repoId: string): Promise<UserStats> {
const res = await fetch(`${this.baseUrl}/api/learning/${repoId}/stats`);
await this.ensureOk(res, 'Failed to fetch user stats');
return res.json();
}
async getAchievements(repoId: string): Promise<Achievement[]> {
const res = await fetch(`${this.baseUrl}/api/learning/${repoId}/achievements`);
await this.ensureOk(res, 'Failed to fetch achievements');
return res.json();
}
async getCompletedLessons(repoId: string, persona?: string): Promise<string[]> {
const query = new URLSearchParams();
if (persona) query.set('persona', persona);
const suffix = query.toString();
const res = await fetch(`${this.baseUrl}/api/learning/${repoId}/progress${suffix ? `?${suffix}` : ''}`);
await this.ensureOk(res, 'Failed to fetch lesson progress');
const data = await res.json();
return data.completed_lessons || [];
}
async completeLesson(
repoId: string,
lessonId: string,
timeSpentSeconds: number,
options?: { persona?: string; moduleId?: string }
): Promise<LessonCompleteResponse> {
const res = await fetch(`${this.baseUrl}/api/learning/${repoId}/lessons/${lessonId}/complete`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
time_spent_seconds: timeSpentSeconds,
persona: options?.persona,
module_id: options?.moduleId,
}),
});
await this.ensureOk(res, 'Failed to complete lesson');
return res.json();
}
async submitQuizResult(repoId: string, lessonId: string, score: number): Promise<QuizResultResponse> {
const res = await fetch(`${this.baseUrl}/api/learning/${repoId}/lessons/${lessonId}/quiz/result`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ score }),
});
await this.ensureOk(res, 'Failed to submit quiz result');
return res.json();
}
async recordGraphView(repoId: string): Promise<{ achievement_unlocked?: Achievement; already_viewed?: boolean }> {
const res = await fetch(`${this.baseUrl}/api/learning/${repoId}/graph/viewed`, {
method: 'POST',
});
await this.ensureOk(res, 'Failed to record graph view');
return res.json();
}
async recordGraphNodeViewed(
repoId: string,
nodeId: string
): Promise<{
unique_nodes_viewed: number;
new_view: boolean;
achievements_unlocked?: Array<{
key: string;
name: string;
description: string;
icon: string;
category: string;
xp_reward: number;
requirement?: number;
}>;
}> {
const res = await fetch(`${this.baseUrl}/api/learning/${repoId}/graph/nodes/viewed`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ node_id: nodeId }),
});
await this.ensureOk(res, 'Failed to record graph node interaction');
return res.json();
}
// Challenge endpoints
async generateChallenge(repoId: string, lessonId: string, challengeType: ChallengeType, context: string = ''): Promise<Challenge> {
const res = await fetch(`${this.baseUrl}/api/learning/${repoId}/lessons/${lessonId}/challenge`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ challenge_type: challengeType, context }),
});
await this.ensureOk(res, 'Failed to generate challenge');
return res.json();
}
async validateChallenge(
repoId: string,
challengeType: ChallengeType,
challenge: Challenge,
answer: number | string[],
usedHint = false
): Promise<ChallengeResult> {
const endpoint = `${this.baseUrl}/api/learning/${repoId}/challenges/validate/${challengeType}`;
const body = challengeType === 'bug_hunt'
? { challenge, selected_line: answer, used_hint: usedHint }
: challengeType === 'code_trace'
? { challenge, selected_index: answer, used_hint: usedHint }
: { challenge, answers: answer, used_hint: usedHint };
const res = await fetch(endpoint, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
});
await this.ensureOk(res, 'Failed to validate challenge');
return res.json();
}
async exportCodeTour(repoId: string, lessonId: string, options?: { persona?: string }): Promise<CodeTour> {
const query = new URLSearchParams();
if (options?.persona) query.set('persona', options.persona);
const suffix = query.toString();
const res = await fetch(
`${this.baseUrl}/api/learning/${repoId}/lessons/${lessonId}/export/codetour${suffix ? `?${suffix}` : ''}`
);
await this.ensureOk(res, 'Failed to export CodeTour');
return res.json();
}
async getUserActivity(repoId: string): Promise<Record<string, number>> {
const res = await fetch(`${this.baseUrl}/api/learning/${repoId}/activity`);
await this.ensureOk(res, 'Failed to load activity');
return res.json();
}
}
// Graph Types
export interface GraphNode {
id: string;
label: string;
type: string;
description: string;
entity?: 'file' | 'module';
group?: string;
importance?: number;
loc?: number;
exports?: string[];
module_key?: string;
member_count?: number;
loc_total?: number;
dominant_types?: string[];
top_files?: string[];
internal_edge_count?: number;
external_edge_count?: number;
internal_density?: number;
metrics?: {
in_degree: number;
out_degree: number;
degree: number;
centrality: number;
};
}
export interface GraphEdge {
source: string;
target: string;
label: string;
type?: string;
relation?: string;
weight?: number;
confidence?: number;
rank?: number;
aggregated_count?: number;
}
export interface DependencyGraphMeta {
generated_at: string;
source: 'deterministic' | 'hybrid';
truncated: boolean;
view?: 'file' | 'module';
scope?: string;
recommended_entry?: 'file' | 'module';
entry_reason?: string;
cross_module_ratio?: number;
internal_edges_summarized?: number;
raw_stats?: {
nodes: number;
edges: number;
clusters: number;
density: number;
};
edge_budget?: {
per_node?: number;
max_edges?: number;
hops?: number;
focus?: boolean;
};
stats: {
nodes: number;
edges: number;
clusters: number;
density: number;
};
}
export interface DependencyGraph {
nodes: GraphNode[];
edges: GraphEdge[];
meta?: DependencyGraphMeta;
}
export const api = new ApiClient();