mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-09-14 11:37:31 +08:00
Covers 15 upstream commits (private mirror → public): Multi-provider failover (RFC-009): - PR-0: extract ChatModelBuilder strategy seam - PR-1a: AvailableProviderPool data structure - PR-1b: startup provider liveness probe + 4 protocol strategies - PR-1c: wire AvailableProviderPool into runtime chat-model selection - PR-1d: provider pool REST endpoint + UI badges - PR-1e: manual reprobe trigger + auto-reprobe on provider config change - PR-3: per-agent provider preferences (agents can override the org-wide fallback chain) Wiki subsystem (RFC-029~033): - Relation model, resilient background jobs, light-weight processing path, retrieval enhancement, frontend redesign (single landing commit) - Follow-up fixes: null guards + stats query + i18n polish, move WikiProcessingJobMapper to repository/ for @MapperScan, align implementation with RFC-029~031 spec - Copy pass: replace "富化 / enrich" wording with clearer "链接 / link" - Style: switch enrich/repair buttons to @element-plus/icons-vue
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import { ref, onMounted, onUnmounted, type Ref } from 'vue'
|
|
import { wikiApi } from '@/api/index'
|
|
|
|
export interface WikiProcessingJob {
|
|
id: number
|
|
kbId: number
|
|
rawId: number
|
|
jobType: string
|
|
stage: string
|
|
status: string
|
|
primaryModelId: number | null
|
|
currentModelId: number | null
|
|
currentModelName?: string
|
|
errorCode: string | null
|
|
errorMessage: string | null
|
|
retryCount: number
|
|
startedAt: string | null
|
|
finishedAt: string | null
|
|
done?: number
|
|
total?: number
|
|
}
|
|
|
|
/**
|
|
* RFC-033: Polls the latest processing job for a given raw material.
|
|
* Stops polling when the job reaches a terminal status.
|
|
*/
|
|
export function useWikiJobPoller(kbId: Ref<number | null>, rawId: Ref<number | null>) {
|
|
const job = ref<WikiProcessingJob | null>(null)
|
|
let timer: ReturnType<typeof setTimeout> | null = null
|
|
|
|
const poll = async () => {
|
|
if (!kbId.value || !rawId.value) return
|
|
try {
|
|
const jobs: any = await wikiApi.getWikiJobs(kbId.value, rawId.value)
|
|
const list = jobs.data || jobs || []
|
|
job.value = list[0] ?? null
|
|
if (job.value && (job.value.status === 'running' || job.value.status === 'queued')) {
|
|
timer = setTimeout(poll, 3000)
|
|
}
|
|
} catch {
|
|
job.value = null
|
|
}
|
|
}
|
|
|
|
onMounted(poll)
|
|
onUnmounted(() => {
|
|
if (timer) clearTimeout(timer)
|
|
})
|
|
|
|
return { job, refresh: poll }
|
|
}
|