Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | import { GenerationModelInfo } from "@/objects/AgentSetup";
import { GenerationStatus } from "@/objects/History";
import {
Knowledge,
KnowledgeCategoryKey,
KnowledgeRepository,
WebCrawlScope,
WebRefreshCadence,
} from "@/objects/Knowledge";
/** Types for the generative knowledge flow: POST /app/knowledge/generate
* starts a background run, GET /app/knowledge/generate/{id} says where it
* is and, once proposed, what it proposes, and
* /app/knowledge/create-from-config creates what the person kept.
*
* The run searches the web and checks what it found; a proposed website
* source comes with the pages it would crawl, and a file source with the
* documents it would import — every one an address the search found and
* svc-core checked, never one a model wrote. A database or an API source
* stays a stub: its connection details are the person's to supply. The
* repository is optional, so the same flow serves both the Repositories
* tab (grouped) and the Sources tab (loose). */
export interface GenerateKnowledgeRequest {
/** What the knowledge is for; optional with `from_turns`, whose questions
* describe it (anything written here is added to them). */
problem_description: string;
/** The caller's own answers whose questions the knowledge is for: a
* recommendation's "Generate knowledge from these questions". */
from_turns?: string[];
ai_model_id?: string | null;
/** False asks for sources alone, with no repository grouping them. */
want_repository?: boolean;
/** What kind of knowledge to find: what discovery looks for, and the
* repository's kind. Domain when left out. */
category?: KnowledgeCategoryKey;
}
/** Where a background generation is, in order. */
export type GenerationStage =
| "queued"
| "planning"
| "searching"
| "checking"
| "designing"
| "done"
| "failed";
export interface KnowledgeGenerationStarted {
generation_id: string;
status: GenerationStatus;
stage: GenerationStage;
}
/** Counts a running generation has reported so far. */
export interface GenerationProgress {
searches?: number;
found?: number;
usable?: number;
updated_at?: string;
}
export interface KnowledgeGenerationStatus {
generation_id: string;
status: GenerationStatus;
stage?: GenerationStage | null;
progress: GenerationProgress;
/** Set once the run is proposed (or applied). */
proposal?: KnowledgeGenerationProposal | null;
/** Set once the run failed: why, safe to show. */
error?: string | null;
}
/** What a search found and svc-core checked. */
export type CandidateKind = "page" | "feed" | "document";
export interface Candidate {
kind: CandidateKind;
url: string;
title: string;
host: string;
snippet: string;
published?: string | null;
publisher?: string | null;
content_type?: string | null;
size_bytes?: number | null;
}
/** A new source the run designed. */
export interface ProposedKnowledge {
name: string;
description: string;
source_type: string;
/** A website source's pages and feeds. */
pages: Candidate[];
/** A file source's documents. */
documents: Candidate[];
/** A website source's crawl scope and cadence; null for the defaults. */
scope?: WebCrawlScope | null;
refresh?: WebRefreshCadence | null;
}
/** The proposal a run lands on, for review. */
export interface KnowledgeGenerationProposal {
/** Empty when the caller asked for sources without a repository. */
repository_name: string;
repository_description: string;
/** The kind of knowledge it was asked for. Absent from an older server. */
category?: KnowledgeCategoryKey;
icon: string;
accent: string;
reasoning: string;
selected_knowledge: Knowledge[];
proposed_knowledge: ProposedKnowledge[];
/** Everything the run found and checked — the review offers what no
* source took. */
candidates: Candidate[];
warnings: string[];
model: GenerationModelInfo;
/** Echoed back on create so the resources resolve to this invocation. */
generation_id: string;
}
/** A document a file source imports from its link. */
export interface DocumentImportInput {
url: string;
title?: string;
publisher?: string;
}
export interface NewKnowledgeInput {
name: string;
description: string;
source_type: string;
/** A website source's URLs to crawl. */
urls?: string[];
scope?: WebCrawlScope | null;
refresh?: WebRefreshCadence | null;
/** A file source's documents to import. */
documents?: DocumentImportInput[];
}
export interface CreateKnowledgeFromConfigRequest {
/** Empty creates the sources without grouping them. */
repository_name: string;
repository_description: string;
/** The repository's kind; its new website sources are set up for it. */
repository_category?: KnowledgeCategoryKey;
icon: string;
accent: string;
existing_knowledge_ids: string[];
new_knowledge: NewKnowledgeInput[];
generation_id?: string | null;
}
export interface CreateKnowledgeFromConfigResponse {
/** Null when the request created loose sources with no repository. */
repository: KnowledgeRepository | null;
created_knowledge_ids: string[];
/** The website sources whose first crawl started. */
crawls_started: string[];
/** How many documents are being imported into the file sources. */
imports_queued: number;
}
// ─── Finding sources for knowledge that exists or was proposed ───────────────
/** A source to find material for: the agent wizard's proposed website and
* file sources (POST /app/knowledge/discover). */
export interface SourceToFill {
/** The caller's own name for it, echoed on the result. */
key: string;
name: string;
description: string;
source_type: "web" | "file";
}
export interface FindSourcesRequest {
sources: SourceToFill[];
context?: string;
/** The agent generation whose proposed sources these are. */
for_generation_id?: string | null;
ai_model_id?: string | null;
}
/** A source with what the search found for it. */
export interface FoundSource {
key: string;
name: string;
source_type: string;
pages: Candidate[];
documents: Candidate[];
scope?: WebCrawlScope | null;
refresh?: WebRefreshCadence | null;
}
export interface FoundSources {
sources: FoundSource[];
candidates: Candidate[];
warnings: string[];
model: GenerationModelInfo;
generation_id: string;
}
export interface FindSourcesStatus {
generation_id: string;
status: GenerationStatus;
stage?: GenerationStage | null;
progress: GenerationProgress;
proposal?: FoundSources | null;
error?: string | null;
}
/** The links kept for an existing source. */
export interface ApplyFoundSourcesRequest {
urls?: string[];
scope?: WebCrawlScope | null;
refresh?: WebRefreshCadence | null;
documents?: DocumentImportInput[];
}
export interface ApplyFoundSourcesResponse {
crawl_started: boolean;
imports_queued: number;
skipped: { url: string; reason: string }[];
}
/** What POST /knowledge/{id}/documents/from-url answers. */
export interface ImportDocumentsResponse {
document_ids: string[];
skipped: { url: string; reason: string }[];
}
|