@swarmvaultai/viewer 0.1.21 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/index-f8JPYMw_.js +330 -0
- package/dist/index.html +1 -1
- package/dist/lib.d.ts +52 -1
- package/dist/lib.js +23 -4
- package/package.json +1 -1
- package/dist/assets/index-DEETVhXx.js +0 -330
package/dist/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>SwarmVault Graph</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-f8JPYMw_.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-mRA-6D-Z.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
package/dist/lib.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ type ViewerGraphPage = {
|
|
|
38
38
|
title: string;
|
|
39
39
|
kind: string;
|
|
40
40
|
status: string;
|
|
41
|
+
sourceType?: string;
|
|
41
42
|
projectIds: string[];
|
|
42
43
|
content: string;
|
|
43
44
|
assets: ViewerOutputAsset[];
|
|
@@ -57,6 +58,7 @@ type ViewerGraphArtifact = {
|
|
|
57
58
|
title: string;
|
|
58
59
|
kind: string;
|
|
59
60
|
status: string;
|
|
61
|
+
sourceType?: string;
|
|
60
62
|
projectIds: string[];
|
|
61
63
|
nodeIds: string[];
|
|
62
64
|
backlinks: string[];
|
|
@@ -72,6 +74,7 @@ type ViewerSearchResult = {
|
|
|
72
74
|
kind?: string;
|
|
73
75
|
status?: string;
|
|
74
76
|
projectIds: string[];
|
|
77
|
+
sourceType?: string;
|
|
75
78
|
};
|
|
76
79
|
type ViewerPagePayload = {
|
|
77
80
|
path: string;
|
|
@@ -201,11 +204,57 @@ type ViewerWatchStatus = {
|
|
|
201
204
|
sourceKind?: string;
|
|
202
205
|
}>;
|
|
203
206
|
};
|
|
207
|
+
type ViewerGraphReport = {
|
|
208
|
+
generatedAt: string;
|
|
209
|
+
graphHash: string;
|
|
210
|
+
overview: {
|
|
211
|
+
nodes: number;
|
|
212
|
+
edges: number;
|
|
213
|
+
pages: number;
|
|
214
|
+
communities: number;
|
|
215
|
+
};
|
|
216
|
+
benchmark?: {
|
|
217
|
+
generatedAt: string;
|
|
218
|
+
stale: boolean;
|
|
219
|
+
summary: {
|
|
220
|
+
questionCount: number;
|
|
221
|
+
uniqueVisitedNodes: number;
|
|
222
|
+
finalContextTokens: number;
|
|
223
|
+
naiveCorpusTokens: number;
|
|
224
|
+
avgReduction: number;
|
|
225
|
+
reductionRatio: number;
|
|
226
|
+
};
|
|
227
|
+
questionCount: number;
|
|
228
|
+
};
|
|
229
|
+
surprisingConnections: Array<{
|
|
230
|
+
id: string;
|
|
231
|
+
sourceNodeId: string;
|
|
232
|
+
sourceLabel: string;
|
|
233
|
+
targetNodeId: string;
|
|
234
|
+
targetLabel: string;
|
|
235
|
+
relation: string;
|
|
236
|
+
evidenceClass: string;
|
|
237
|
+
confidence: number;
|
|
238
|
+
pathNodeIds: string[];
|
|
239
|
+
pathEdgeIds: string[];
|
|
240
|
+
pathSummary: string;
|
|
241
|
+
explanation: string;
|
|
242
|
+
}>;
|
|
243
|
+
suggestedQuestions: string[];
|
|
244
|
+
recentResearchSources: Array<{
|
|
245
|
+
pageId: string;
|
|
246
|
+
path: string;
|
|
247
|
+
title: string;
|
|
248
|
+
sourceType: string;
|
|
249
|
+
updatedAt: string;
|
|
250
|
+
}>;
|
|
251
|
+
};
|
|
204
252
|
declare global {
|
|
205
253
|
interface Window {
|
|
206
254
|
__SWARMVAULT_EMBEDDED_DATA__?: {
|
|
207
255
|
graph: ViewerGraphArtifact;
|
|
208
256
|
pages: ViewerGraphPage[];
|
|
257
|
+
report?: ViewerGraphReport;
|
|
209
258
|
};
|
|
210
259
|
}
|
|
211
260
|
}
|
|
@@ -214,6 +263,7 @@ type ViewerSearchOptions = {
|
|
|
214
263
|
kind?: string;
|
|
215
264
|
status?: string;
|
|
216
265
|
project?: string;
|
|
266
|
+
sourceType?: string;
|
|
217
267
|
};
|
|
218
268
|
declare function fetchGraphArtifact(input?: string, init?: RequestInit): Promise<ViewerGraphArtifact>;
|
|
219
269
|
declare function searchViewerPages(query: string, options?: ViewerSearchOptions): Promise<ViewerSearchResult[]>;
|
|
@@ -222,6 +272,7 @@ declare function fetchGraphQuery(question: string, options?: {
|
|
|
222
272
|
traversal?: "bfs" | "dfs";
|
|
223
273
|
budget?: number;
|
|
224
274
|
}): Promise<ViewerGraphQueryResult>;
|
|
275
|
+
declare function fetchGraphReport(): Promise<ViewerGraphReport | null>;
|
|
225
276
|
declare function fetchGraphPath(from: string, to: string): Promise<ViewerGraphPathResult>;
|
|
226
277
|
declare function fetchGraphExplain(target: string): Promise<ViewerGraphExplainResult>;
|
|
227
278
|
declare function fetchApprovals(): Promise<ViewerApprovalSummary[]>;
|
|
@@ -231,4 +282,4 @@ declare function fetchCandidates(): Promise<ViewerCandidateRecord[]>;
|
|
|
231
282
|
declare function applyCandidateAction(target: string, action: "promote" | "archive"): Promise<ViewerCandidateRecord>;
|
|
232
283
|
declare function fetchWatchStatus(): Promise<ViewerWatchStatus>;
|
|
233
284
|
|
|
234
|
-
export { type ViewerApprovalDetail, type ViewerApprovalEntry, type ViewerApprovalSummary, type ViewerCandidateRecord, type ViewerGraphArtifact, type ViewerGraphEdge, type ViewerGraphExplainResult, type ViewerGraphNode, type ViewerGraphPage, type ViewerGraphPathResult, type ViewerGraphQueryResult, type ViewerOutputAsset, type ViewerPagePayload, type ViewerReviewActionResult, type ViewerSearchOptions, type ViewerSearchResult, type ViewerWatchStatus, applyCandidateAction, applyReviewAction, fetchApprovalDetail, fetchApprovals, fetchCandidates, fetchGraphArtifact, fetchGraphExplain, fetchGraphPath, fetchGraphQuery, fetchViewerPage, fetchWatchStatus, searchViewerPages };
|
|
285
|
+
export { type ViewerApprovalDetail, type ViewerApprovalEntry, type ViewerApprovalSummary, type ViewerCandidateRecord, type ViewerGraphArtifact, type ViewerGraphEdge, type ViewerGraphExplainResult, type ViewerGraphNode, type ViewerGraphPage, type ViewerGraphPathResult, type ViewerGraphQueryResult, type ViewerGraphReport, type ViewerOutputAsset, type ViewerPagePayload, type ViewerReviewActionResult, type ViewerSearchOptions, type ViewerSearchResult, type ViewerWatchStatus, applyCandidateAction, applyReviewAction, fetchApprovalDetail, fetchApprovals, fetchCandidates, fetchGraphArtifact, fetchGraphExplain, fetchGraphPath, fetchGraphQuery, fetchGraphReport, fetchViewerPage, fetchWatchStatus, searchViewerPages };
|
package/dist/lib.js
CHANGED
|
@@ -32,6 +32,7 @@ async function searchViewerPages(query, options = {}) {
|
|
|
32
32
|
const kind = options.kind ?? "all";
|
|
33
33
|
const status = options.status ?? "all";
|
|
34
34
|
const project = options.project ?? "all";
|
|
35
|
+
const sourceType = options.sourceType ?? "all";
|
|
35
36
|
if (embedded) {
|
|
36
37
|
const normalizedQuery = query.trim().toLowerCase();
|
|
37
38
|
if (!normalizedQuery) {
|
|
@@ -39,7 +40,7 @@ async function searchViewerPages(query, options = {}) {
|
|
|
39
40
|
}
|
|
40
41
|
return embedded.pages.filter((page) => kind === "all" ? true : page.kind === kind).filter((page) => status === "all" ? true : page.status === status).filter(
|
|
41
42
|
(page) => project === "all" ? true : project === "unassigned" ? page.projectIds.length === 0 : page.projectIds.includes(project)
|
|
42
|
-
).map((page) => {
|
|
43
|
+
).filter((page) => sourceType === "all" ? true : (page.sourceType ?? "") === sourceType).map((page) => {
|
|
43
44
|
const haystack = `${page.title}
|
|
44
45
|
${page.content}`.toLowerCase();
|
|
45
46
|
const score = haystack.includes(normalizedQuery) ? haystack.indexOf(normalizedQuery) : Number.POSITIVE_INFINITY;
|
|
@@ -51,7 +52,8 @@ ${page.content}`.toLowerCase();
|
|
|
51
52
|
rank: score,
|
|
52
53
|
kind: page.kind,
|
|
53
54
|
status: page.status,
|
|
54
|
-
projectIds: page.projectIds
|
|
55
|
+
projectIds: page.projectIds,
|
|
56
|
+
sourceType: page.sourceType
|
|
55
57
|
};
|
|
56
58
|
}).filter((page) => Number.isFinite(page.rank)).sort((left, right) => left.rank - right.rank || left.title.localeCompare(right.title)).slice(0, limit);
|
|
57
59
|
}
|
|
@@ -60,7 +62,8 @@ ${page.content}`.toLowerCase();
|
|
|
60
62
|
limit: String(limit),
|
|
61
63
|
kind,
|
|
62
64
|
status,
|
|
63
|
-
project
|
|
65
|
+
project,
|
|
66
|
+
sourceType
|
|
64
67
|
});
|
|
65
68
|
const response = await fetch(`/api/search?${params.toString()}`);
|
|
66
69
|
if (!response.ok) {
|
|
@@ -82,7 +85,8 @@ async function fetchViewerPage(path) {
|
|
|
82
85
|
page_id: page.pageId,
|
|
83
86
|
kind: page.kind,
|
|
84
87
|
status: page.status,
|
|
85
|
-
project_ids: page.projectIds
|
|
88
|
+
project_ids: page.projectIds,
|
|
89
|
+
source_type: page.sourceType
|
|
86
90
|
},
|
|
87
91
|
content: page.content,
|
|
88
92
|
assets: page.assets ?? []
|
|
@@ -106,6 +110,20 @@ async function fetchGraphQuery(question, options = {}) {
|
|
|
106
110
|
}
|
|
107
111
|
return response.json();
|
|
108
112
|
}
|
|
113
|
+
async function fetchGraphReport() {
|
|
114
|
+
const embedded = embeddedData();
|
|
115
|
+
if (embedded) {
|
|
116
|
+
return embedded.report ?? null;
|
|
117
|
+
}
|
|
118
|
+
const response = await fetch("/api/graph-report");
|
|
119
|
+
if (response.status === 404) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
if (!response.ok) {
|
|
123
|
+
throw new Error(`Failed to load graph report: ${response.status} ${response.statusText}`);
|
|
124
|
+
}
|
|
125
|
+
return response.json();
|
|
126
|
+
}
|
|
109
127
|
async function fetchGraphPath(from, to) {
|
|
110
128
|
const params = new URLSearchParams({
|
|
111
129
|
from,
|
|
@@ -206,6 +224,7 @@ export {
|
|
|
206
224
|
fetchGraphExplain,
|
|
207
225
|
fetchGraphPath,
|
|
208
226
|
fetchGraphQuery,
|
|
227
|
+
fetchGraphReport,
|
|
209
228
|
fetchViewerPage,
|
|
210
229
|
fetchWatchStatus,
|
|
211
230
|
searchViewerPages
|