arkaos 2.87.0 → 2.88.0
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/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.88.0
|
|
Binary file
|
|
@@ -324,6 +324,90 @@ async function handleSearch() {
|
|
|
324
324
|
function formatScore(score: number): string {
|
|
325
325
|
return `${(score * 100).toFixed(0)}%`
|
|
326
326
|
}
|
|
327
|
+
|
|
328
|
+
// PR71 v2.88.0 — delete all chunks from a given source.
|
|
329
|
+
|
|
330
|
+
const deletingSource = ref<string | null>(null)
|
|
331
|
+
|
|
332
|
+
async function askDeleteSource(source: string) {
|
|
333
|
+
if (!source) return
|
|
334
|
+
if (typeof window === 'undefined') return
|
|
335
|
+
const ok = window.confirm(
|
|
336
|
+
`Delete every indexed chunk from this source?\n\n${source}\n\n`
|
|
337
|
+
+ 'This removes the source from search results but does not delete the original file. '
|
|
338
|
+
+ 'You can re-ingest the source later if needed.',
|
|
339
|
+
)
|
|
340
|
+
if (!ok) return
|
|
341
|
+
await deleteSource(source)
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
async function deleteSource(source: string) {
|
|
345
|
+
deletingSource.value = source
|
|
346
|
+
try {
|
|
347
|
+
const res = await $fetch<{ deleted?: number, source?: string, error?: string }>(
|
|
348
|
+
`${apiBase}/api/knowledge/sources`,
|
|
349
|
+
{ method: 'DELETE', query: { source } },
|
|
350
|
+
)
|
|
351
|
+
if (res.error) {
|
|
352
|
+
toast.add({
|
|
353
|
+
title: 'Delete failed',
|
|
354
|
+
description: res.error,
|
|
355
|
+
color: 'error',
|
|
356
|
+
})
|
|
357
|
+
return
|
|
358
|
+
}
|
|
359
|
+
const deleted = res.deleted ?? 0
|
|
360
|
+
// Drop the matching rows from the in-memory list without a full re-fetch.
|
|
361
|
+
searchResults.value = searchResults.value.filter((r) => r.source !== source)
|
|
362
|
+
searchTotal.value = searchResults.value.length
|
|
363
|
+
// Refresh stats so the chunk count in the header updates.
|
|
364
|
+
if (typeof refresh === 'function') {
|
|
365
|
+
await refresh()
|
|
366
|
+
}
|
|
367
|
+
toast.add({
|
|
368
|
+
title: deleted > 0
|
|
369
|
+
? `Deleted ${deleted} chunk${deleted === 1 ? '' : 's'}`
|
|
370
|
+
: 'Nothing to delete',
|
|
371
|
+
description: source,
|
|
372
|
+
color: 'success',
|
|
373
|
+
})
|
|
374
|
+
} catch (err) {
|
|
375
|
+
toast.add({
|
|
376
|
+
title: 'Delete failed',
|
|
377
|
+
description: err instanceof Error ? err.message : 'unknown error',
|
|
378
|
+
color: 'error',
|
|
379
|
+
})
|
|
380
|
+
} finally {
|
|
381
|
+
deletingSource.value = null
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// PR71 — highlight the search query in the preview text.
|
|
386
|
+
// Tolerates malformed regex (escapes special characters) and HTML-
|
|
387
|
+
// escapes the input so v-html'd output is safe from XSS via DB rows.
|
|
388
|
+
function highlightMatches(text: string, query: string): string {
|
|
389
|
+
const safe = escapeHtml(text || '')
|
|
390
|
+
const q = (query || '').trim()
|
|
391
|
+
if (!q) return safe
|
|
392
|
+
const pattern = new RegExp(`(${escapeRegex(q)})`, 'gi')
|
|
393
|
+
return safe.replace(
|
|
394
|
+
pattern,
|
|
395
|
+
'<mark class="bg-primary/20 text-primary rounded px-0.5">$1</mark>',
|
|
396
|
+
)
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function escapeHtml(value: string): string {
|
|
400
|
+
return value
|
|
401
|
+
.replace(/&/g, '&')
|
|
402
|
+
.replace(/</g, '<')
|
|
403
|
+
.replace(/>/g, '>')
|
|
404
|
+
.replace(/"/g, '"')
|
|
405
|
+
.replace(/'/g, ''')
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
function escapeRegex(value: string): string {
|
|
409
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
410
|
+
}
|
|
327
411
|
</script>
|
|
328
412
|
|
|
329
413
|
<template>
|
|
@@ -771,17 +855,30 @@ function formatScore(score: number): string {
|
|
|
771
855
|
{{ result.heading }}
|
|
772
856
|
</span>
|
|
773
857
|
</div>
|
|
774
|
-
<
|
|
775
|
-
|
|
776
|
-
|
|
858
|
+
<div class="flex items-center gap-2 shrink-0">
|
|
859
|
+
<span class="text-xs text-muted whitespace-nowrap">
|
|
860
|
+
Score: {{ formatScore(result.score) }}
|
|
861
|
+
</span>
|
|
862
|
+
<UButton
|
|
863
|
+
v-if="result.source"
|
|
864
|
+
:icon="deletingSource === result.source
|
|
865
|
+
? 'i-lucide-loader-2'
|
|
866
|
+
: 'i-lucide-trash-2'"
|
|
867
|
+
:loading="deletingSource === result.source"
|
|
868
|
+
variant="ghost"
|
|
869
|
+
color="error"
|
|
870
|
+
size="xs"
|
|
871
|
+
aria-label="Delete all chunks from this source"
|
|
872
|
+
@click.stop="askDeleteSource(result.source)"
|
|
873
|
+
/>
|
|
874
|
+
</div>
|
|
777
875
|
</div>
|
|
778
876
|
<p v-if="result.source" class="text-xs text-muted mb-1 truncate">
|
|
779
877
|
<UIcon name="i-lucide-file-text" class="size-3 inline-block mr-1" />
|
|
780
878
|
{{ result.source }}
|
|
781
879
|
</p>
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
</p>
|
|
880
|
+
<!-- PR71 v2.88.0 — highlight query matches in the preview -->
|
|
881
|
+
<p class="text-sm text-muted line-clamp-3" v-html="highlightMatches(result.text || result.content, searchQuery)" />
|
|
785
882
|
</div>
|
|
786
883
|
</div>
|
|
787
884
|
|
package/package.json
CHANGED
package/pyproject.toml
CHANGED
|
Binary file
|
package/scripts/dashboard-api.py
CHANGED
|
@@ -612,6 +612,32 @@ def knowledge_search(q: str = Query(...), top_k: int = Query(5)):
|
|
|
612
612
|
return {"results": results, "query": q, "total": len(results)}
|
|
613
613
|
|
|
614
614
|
|
|
615
|
+
@app.delete("/api/knowledge/sources")
|
|
616
|
+
def knowledge_delete_source(source: str = Query(...)):
|
|
617
|
+
"""PR71 v2.88.0 — remove all chunks from a given source.
|
|
618
|
+
|
|
619
|
+
Operators sometimes ingest a noisy / wrong source and want to nuke
|
|
620
|
+
every chunk that came from it without rebuilding the whole vector
|
|
621
|
+
DB. The vector store already exposes `remove_file(source)` —
|
|
622
|
+
this endpoint just exposes it on the wire.
|
|
623
|
+
|
|
624
|
+
Returns ``{deleted: N, source: "..."}``. Refuses empty source
|
|
625
|
+
paths so a runaway client doesn't accidentally request "delete
|
|
626
|
+
everything that has no source".
|
|
627
|
+
"""
|
|
628
|
+
clean = (source or "").strip()
|
|
629
|
+
if not clean:
|
|
630
|
+
return {"error": "source query param is required"}
|
|
631
|
+
store = _get_vector_store()
|
|
632
|
+
if not store:
|
|
633
|
+
return {"error": "vector store unavailable", "deleted": 0}
|
|
634
|
+
try:
|
|
635
|
+
deleted = store.remove_file(clean)
|
|
636
|
+
except Exception as exc: # noqa: BLE001 — surface as 200+error
|
|
637
|
+
return {"error": f"delete failed: {exc}", "deleted": 0}
|
|
638
|
+
return {"deleted": int(deleted), "source": clean}
|
|
639
|
+
|
|
640
|
+
|
|
615
641
|
@app.get("/api/health")
|
|
616
642
|
def health():
|
|
617
643
|
"""PR70 v2.87.0 — per-check severity + response timestamp.
|