import { z } from "zod"; import { type IsoDateTime } from "./ids.js"; import { type Principal } from "./principal.js"; /** Knowledge design v2 (2026-07-22) R1 — the doc-hash manifest version tag. */ export declare const VENDO_KNOWLEDGE_HASH_FORMAT: "vendo/knowledge-hash@1"; /** Knowledge design v2 (2026-07-22) R1 — the two content shapes that must not be flattened: prose (`docs`) for semantic retrieval; structured facts (`glossary`, `api`) for exact lookup. */ export type KnowledgeKind = "docs" | "glossary" | "api"; export declare const knowledgeKindSchema: z.ZodEnum<["docs", "glossary", "api"]>; /** Knowledge design v2 (2026-07-22) R5 — a NEW, knowledge-only label; no general per-document visibility system exists elsewhere. */ export type KnowledgeVisibility = "public" | "internal"; export declare const knowledgeVisibilitySchema: z.ZodEnum<["public", "internal"]>; /** Knowledge design v2 (2026-07-22) R1 — the unit adapters ingest. Upsert is DOCUMENT-level: chunking belongs to the engine behind the contract, so a doc carries normalized text, never chunks. */ export interface KnowledgeDoc { /** Stable host-side id — the upsert/remove key and the citation anchor. */ id: string; kind: KnowledgeKind; visibility: KnowledgeVisibility; title: string; /** Parsed, normalized text. Engines own chunking/embedding/indexing. */ text: string; /** Source identity, e.g. a repo-relative path or connector URI. */ source: string; metadata?: Record; updatedAt?: IsoDateTime; } export declare const knowledgeDocSchema: z.ZodObject<{ id: z.ZodString; kind: z.ZodEnum<["docs", "glossary", "api"]>; visibility: z.ZodEnum<["public", "internal"]>; title: z.ZodString; text: z.ZodString; source: z.ZodString; metadata: z.ZodOptional>; updatedAt: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ id: z.ZodString; kind: z.ZodEnum<["docs", "glossary", "api"]>; visibility: z.ZodEnum<["public", "internal"]>; title: z.ZodString; text: z.ZodString; source: z.ZodString; metadata: z.ZodOptional>; updatedAt: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ id: z.ZodString; kind: z.ZodEnum<["docs", "glossary", "api"]>; visibility: z.ZodEnum<["public", "internal"]>; title: z.ZodString; text: z.ZodString; source: z.ZodString; metadata: z.ZodOptional>; updatedAt: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; /** Knowledge design v2 (2026-07-22) R4 + spike verdict (ENG-357, 2026-07-23): citation-grade refs are doc-id + an engine-scoped opaque chunk id — no provider documents page/offset precision, so the contract does not promise it. `fetch(ref)` accepts a ref with or without `chunkId`. */ export interface KnowledgeRef { docId: string; /** Opaque to callers; meaningful only to the engine that minted it. */ chunkId?: string; title?: string; source?: string; } export declare const knowledgeRefSchema: z.ZodObject<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; /** Knowledge design v2 (2026-07-22) R3 — the mode selector. `chat` = fast retrieval; `deep` = agentic search (engines without it treat as `chat`); `schema` = exact lookup over glossary/api rows — empty hits mean an honest not-found, never a fuzzy fallback. Intent is orthogonal to `kinds`: it selects the matching mode and never implies a kind filter — callers restrict kinds explicitly. */ export type KnowledgeIntent = "chat" | "deep" | "schema"; export declare const knowledgeIntentSchema: z.ZodEnum<["chat", "deep", "schema"]>; /** Knowledge design v2 (2026-07-22) R2. The contract carries NO tenant selector: tenancy is derived server-side by whichever composition wires the adapter (R5 invariant 1, confirmed by the spike across every provider). */ export interface KnowledgeQuery { text: string; /** Defaults to "chat" when absent. */ intent?: KnowledgeIntent; /** An empty array matches nothing. */ kinds?: KnowledgeKind[]; /** Absent means an engine-chosen default. `limit` truncates the most-relevant-first ordering without changing it — a limited query must not rank differently from the same query unlimited. */ limit?: number; } export declare const knowledgeQuerySchema: z.ZodObject<{ text: z.ZodString; intent: z.ZodOptional>; kinds: z.ZodOptional, "many">>; limit: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ text: z.ZodString; intent: z.ZodOptional>; kinds: z.ZodOptional, "many">>; limit: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ text: z.ZodString; intent: z.ZodOptional>; kinds: z.ZodOptional, "many">>; limit: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; /** Knowledge design v2 (2026-07-22) R5, review fix KB-COV-7: `includeInternal` is settable ONLY by trusted host-wired composition code (dev-rider wiring, host-registered automations, direct backend calls) and never derived from any request property. Absent means public-only on every principal-carrying path. */ export interface KnowledgeContext { principal: Principal; includeInternal?: boolean; } /** Knowledge design v2 (2026-07-22) R3/R4. */ export interface KnowledgeHit { ref: KnowledgeRef; snippet: string; kind: KnowledgeKind; visibility: KnowledgeVisibility; score?: number; } export declare const knowledgeHitSchema: z.ZodObject<{ ref: z.ZodObject<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; snippet: z.ZodString; kind: z.ZodEnum<["docs", "glossary", "api"]>; visibility: z.ZodEnum<["public", "internal"]>; score: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ ref: z.ZodObject<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; snippet: z.ZodString; kind: z.ZodEnum<["docs", "glossary", "api"]>; visibility: z.ZodEnum<["public", "internal"]>; score: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ ref: z.ZodObject<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; snippet: z.ZodString; kind: z.ZodEnum<["docs", "glossary", "api"]>; visibility: z.ZodEnum<["public", "internal"]>; score: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; /** Hits are ordered most-relevant-first. `score` is optional and engine-relative — never comparable across engines. */ export interface KnowledgeSearchResult { hits: KnowledgeHit[]; } export declare const knowledgeSearchResultSchema: z.ZodObject<{ hits: z.ZodArray; title: z.ZodOptional; source: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; snippet: z.ZodString; kind: z.ZodEnum<["docs", "glossary", "api"]>; visibility: z.ZodEnum<["public", "internal"]>; score: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ ref: z.ZodObject<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; snippet: z.ZodString; kind: z.ZodEnum<["docs", "glossary", "api"]>; visibility: z.ZodEnum<["public", "internal"]>; score: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ ref: z.ZodObject<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; snippet: z.ZodString; kind: z.ZodEnum<["docs", "glossary", "api"]>; visibility: z.ZodEnum<["public", "internal"]>; score: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>, "many">; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ hits: z.ZodArray; title: z.ZodOptional; source: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; snippet: z.ZodString; kind: z.ZodEnum<["docs", "glossary", "api"]>; visibility: z.ZodEnum<["public", "internal"]>; score: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ ref: z.ZodObject<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; snippet: z.ZodString; kind: z.ZodEnum<["docs", "glossary", "api"]>; visibility: z.ZodEnum<["public", "internal"]>; score: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ ref: z.ZodObject<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; snippet: z.ZodString; kind: z.ZodEnum<["docs", "glossary", "api"]>; visibility: z.ZodEnum<["public", "internal"]>; score: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>, "many">; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ hits: z.ZodArray; title: z.ZodOptional; source: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; snippet: z.ZodString; kind: z.ZodEnum<["docs", "glossary", "api"]>; visibility: z.ZodEnum<["public", "internal"]>; score: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ ref: z.ZodObject<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; snippet: z.ZodString; kind: z.ZodEnum<["docs", "glossary", "api"]>; visibility: z.ZodEnum<["public", "internal"]>; score: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ ref: z.ZodObject<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; snippet: z.ZodString; kind: z.ZodEnum<["docs", "glossary", "api"]>; visibility: z.ZodEnum<["public", "internal"]>; score: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>, "many">; }, z.ZodTypeAny, "passthrough">>; /** Knowledge design v2 (2026-07-22) R3 — read-more: expanded context around a ref, up to the whole doc; sizing against the tool-output cap is the CALLER's concern, not the adapter's. */ export interface KnowledgeFetchResult { ref: KnowledgeRef; text: string; truncated?: boolean; } export declare const knowledgeFetchResultSchema: z.ZodObject<{ ref: z.ZodObject<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; text: z.ZodString; truncated: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ ref: z.ZodObject<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; text: z.ZodString; truncated: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ ref: z.ZodObject<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ docId: z.ZodString; chunkId: z.ZodOptional; title: z.ZodOptional; source: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; text: z.ZodString; truncated: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; /** Knowledge design v2 (2026-07-22) R1/R4 — status() is the unified read-back across ingestion paths; the prompt index is built from it. */ export interface KnowledgeStatus { docs: number; byKind?: Partial>; lastSyncAt?: IsoDateTime; } export declare const knowledgeStatusSchema: z.ZodObject<{ docs: z.ZodNumber; byKind: z.ZodOptional, z.ZodNumber>>; lastSyncAt: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ docs: z.ZodNumber; byKind: z.ZodOptional, z.ZodNumber>>; lastSyncAt: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ docs: z.ZodNumber; byKind: z.ZodOptional, z.ZodNumber>>; lastSyncAt: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; /** Knowledge design v2 (2026-07-22) R2 — the declared capability posture. `search` and `status` are required of every adapter and therefore not declared; the posture names the optional halves. `public-only` is the host's attestation that the corpus carries no `internal` content. */ export interface KnowledgePosture { fetch: boolean; write: boolean; visibility: "enforced" | "public-only"; } export declare const knowledgePostureSchema: z.ZodObject<{ fetch: z.ZodBoolean; write: z.ZodBoolean; visibility: z.ZodEnum<["enforced", "public-only"]>; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ fetch: z.ZodBoolean; write: z.ZodBoolean; visibility: z.ZodEnum<["enforced", "public-only"]>; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ fetch: z.ZodBoolean; write: z.ZodBoolean; visibility: z.ZodEnum<["enforced", "public-only"]>; }, z.ZodTypeAny, "passthrough">>; /** Knowledge design v2 (2026-07-22) R2 — the seam all three engines (local, cloud, BYO HTTP template) implement. Optional members are present exactly when the posture declares them (conformance-tested, not promised). Adapters may assume inputs are schema-valid; the wire/tool layer owns validation. */ export interface KnowledgeAdapter { posture: KnowledgePosture; search(query: KnowledgeQuery, ctx: KnowledgeContext): Promise; /** Present iff `posture.fetch`. Internal-visibility docs behave as unknown (`null`) unless `ctx.includeInternal` — a ref is not a capability. The returned `ref` identifies what was actually fetched; `chunkId` may be omitted when the whole document is returned. */ fetch?(ref: KnowledgeRef, ctx: KnowledgeContext): Promise; /** Present iff `posture.write`. Document-level; engines own chunking. Resolves only once the documents are searchable — engines with asynchronous indexing must await searchability before resolving. */ upsert?(docs: KnowledgeDoc[]): Promise; /** Present iff `posture.write`. Unknown ids resolve as no-ops. */ remove?(docIds: string[]): Promise; status(): Promise; } /** Knowledge design v2 (2026-07-22) R1 — local-engine internal: one chunk of a structurally chunked doc. Frozen here, consumed only by the local engine; the cloud engine never sees it. */ export interface KnowledgeChunk { docId: string; /** Stable within (docId, chunker version) — the citation chunk anchor. */ chunkId: string; text: string; index: number; heading?: string; } /** Knowledge design v2 (2026-07-22) R1 — structural chunking only in v1 (semantic chunking cut 2026-07-22). Bumping `version` obliges the local engine to re-chunk stored docs (the engine owns re-index versioning). */ export interface KnowledgeChunker { version: number; chunk(doc: KnowledgeDoc): KnowledgeChunk[]; } /** Knowledge design v2 (2026-07-22) R1 — sync's doc-level content-hash manifest: which documents changed → re-upsert/remove. Persisted host-side in the store's meta area, engine-independent; sync owns it for every source it moves. */ export interface KnowledgeHashManifest { format: typeof VENDO_KNOWLEDGE_HASH_FORMAT; /** `sha256:<64 hex>` content hash per doc id. */ docs: Record; updatedAt: IsoDateTime; } export declare const knowledgeHashManifestSchema: z.ZodObject<{ format: z.ZodLiteral<"vendo/knowledge-hash@1">; docs: z.ZodRecord; updatedAt: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ format: z.ZodLiteral<"vendo/knowledge-hash@1">; docs: z.ZodRecord; updatedAt: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ format: z.ZodLiteral<"vendo/knowledge-hash@1">; docs: z.ZodRecord; updatedAt: z.ZodString; }, z.ZodTypeAny, "passthrough">>;