import { z } from "zod"; import { type Database } from "./database.js"; export { CreditDebitAttribution, creditDebitAttributionMetadata, creditDebitAttributionForTurn, currentCreditDebitAttribution, withCreditDebitAttribution, ambientBillingOrigin, billingOriginOverride, manualScheduledTaskRunBillingOrigin, markScheduledTaskApiBilled, readScheduledTaskBillingOrigin, readSessionBillingOrigin, readTurnBillingOrigin, withBillingOriginOverride, } from "./credit-debit-attribution.js"; declare const Claim: z.ZodObject<{ accountId: z.ZodUUID; entryId: z.ZodUUID; revisionId: z.ZodUUID; leaseId: z.ZodUUID; model: z.ZodString; dimensions: z.ZodNumber; generation: z.ZodNumber; nextIndex: z.ZodNumber; billingAttribution: z.ZodDiscriminatedUnion<[z.ZodObject<{ kind: z.ZodLiteral<"turn">; turnId: z.ZodUUID; initiatingHumanSubjectId: z.ZodNullable; billingOrigin: z.ZodOptional>; }, z.core.$strip>, z.ZodObject<{ kind: z.ZodLiteral<"human">; initiatingHumanSubjectId: z.ZodString; billingOrigin: z.ZodOptional>; }, z.core.$strip>, z.ZodObject<{ kind: z.ZodLiteral<"service">; billingOrigin: z.ZodOptional>; }, z.core.$strip>, z.ZodObject<{ kind: z.ZodLiteral<"unknown">; }, z.core.$strip>], "kind">; }, z.core.$strip>; export type KnowledgeIndexClaim = z.infer; /** DB-clock cutoff for this worker's first indexing poll, not a host-clock guess. */ export declare function knowledgeIndexBillingActivationTime(db: Database): Promise; /** Persist the chosen mode for exactly this leased generation. Paid review-first * revisions release the lease without embedding until published. */ export declare function freezeKnowledgeIndexBillingMode(db: Database, raw: KnowledgeIndexClaim, requested: "usage_only" | "shadow" | "credits", activatedAt: Date, rateMicrosPerMillionBytes: number): Promise<{ mode: "awaiting_review" | "credits" | "obsolete" | "shadow" | "usage_only"; rateMicrosPerMillionBytes: number; }>; /** Serialize paid query admission and settlement across an entire account. */ export declare function withKnowledgeQueryAccountLock(db: Database, accountId: string, workspaceId: string, fn: (db: Database) => Promise): Promise; /** Internal projection dispatcher. No HTTP, MCP or agent tool exposes this capability. */ export declare function claimKnowledgeIndexJobs(db: Database, input: { model: string; dimensions: number; limit?: number; }): Promise<{ accountId: string; entryId: string; revisionId: string; leaseId: string; model: string; dimensions: number; generation: number; nextIndex: number; billingAttribution: { kind: "turn"; turnId: string; initiatingHumanSubjectId: string | null; billingOrigin?: "api" | "app" | undefined; } | { kind: "human"; initiatingHumanSubjectId: string; billingOrigin?: "api" | "app" | undefined; } | { kind: "service"; billingOrigin?: "api" | "app" | undefined; } | { kind: "unknown"; }; }[]>; export declare function readKnowledgeIndexSource(db: Database, claim: KnowledgeIndexClaim): Promise<{ billingWorkspaceId: string; entry: { title: string; kind: "decision" | "fact" | "group" | "incident" | "note" | "requirement" | "source"; content: string; source?: { kind: "connector" | "conversation" | "file" | "manual" | "repository" | "slack" | "task_note" | "web"; noteId?: string | undefined; fileId?: string | undefined; documentId?: string | undefined; sessionId?: string | undefined; uri?: string | undefined; externalId?: string | undefined; version?: string | undefined; capturedAt?: string | undefined; retention?: "full_text" | "passages" | "reference" | undefined; purpose?: "evidence" | "reference" | undefined; } | undefined; evidence: { entryId: string; revisionId: string; location: { page?: number | undefined; passage?: string | undefined; messageIds?: string[] | undefined; path?: string | undefined; commit?: string | undefined; lineStart?: number | undefined; lineEnd?: number | undefined; }; quote?: string | undefined; }[]; groupIds: string[]; relationships: { entryId: string; relation: "applies_to" | "conflicts_with" | "depends_on" | "related_to" | "supersedes"; }[]; }; nextIndex: number; originWorkspaceId: string; scope: "organization" | "personal" | "workspace"; } | null>; export type KnowledgeIndexProjectionChunk = { index: number; field: "content" | "title"; start: number; end: number; text: string; embedding: number[]; }; export declare function appendKnowledgeIndexChunks(db: Database, claim: KnowledgeIndexClaim, expectedNextIndex: number, chunks: KnowledgeIndexProjectionChunk[]): Promise<{ [x: string]: unknown; status: "obsolete" | "pending" | "ready" | "running"; nextIndex?: number | undefined; }>; export declare function completeKnowledgeIndexJob(db: Database, claim: KnowledgeIndexClaim, expectedNextIndex: number): Promise<{ [x: string]: unknown; status: "obsolete" | "pending" | "ready" | "running"; nextIndex?: number | undefined; }>; export declare function deferKnowledgeIndexJob(db: Database, claim: KnowledgeIndexClaim): Promise<{ [x: string]: unknown; status: "obsolete" | "pending" | "ready" | "running"; nextIndex?: number | undefined; }>; /** A funding wait is not a provider failure. Keep the lease checkpoint intact. */ export declare function waitKnowledgeIndexForFunding(db: Database, raw: KnowledgeIndexClaim): Promise<{ status: "obsolete" | "pending"; }>; /** Hold publication stable through the paid append + post-use debit commit. * Call only after embedding, inside the same transaction as settlement. */ export declare function guardPaidKnowledgeIndexPublication(db: Database, raw: KnowledgeIndexClaim): Promise<"awaiting_review" | "obsolete" | "published">; export declare function continueKnowledgeIndexJob(db: Database, claim: KnowledgeIndexClaim): Promise<{ [x: string]: unknown; status: "obsolete" | "pending" | "ready" | "running"; nextIndex?: number | undefined; }>;