import type { KnowledgePage, KnowledgeProvenance, KnowledgeReadScope, KnowledgeStorage } from '../storage/domains/knowledge/index.js';
import type { KnowledgeRole } from './declarations.js';
import type { KnowledgeScopeRuntime } from './scope-runtime.js';
/** What tools receive as their second argument. */
export type KnowledgeRunContext = {
    agent?: {
        threadId?: string;
        resourceId?: string;
        agentId?: string;
    };
    requestContext?: {
        get(key: string): unknown;
    };
};
/** A page reference the run can't resolve; identical for missing and unreadable pages. */
export declare class KnowledgeNotFoundError extends Error {
    constructor(ref: string, closeMatches?: string[]);
}
/**
 * One call's view of Knowledge: the run's principals, its read scope and its provenance. Built per
 * tool call from the run's own scopes, so access always follows the current declarations.
 * @internal
 */
export declare class KnowledgeRun {
    #private;
    readonly runtime: KnowledgeScopeRuntime;
    readonly storage: KnowledgeStorage;
    readonly principals: string[];
    readonly read: Exclude<KnowledgeReadScope, 'all'>;
    readonly provenance: KnowledgeProvenance;
    private constructor();
    static start(runtime: KnowledgeScopeRuntime, storage: KnowledgeStorage, context: KnowledgeRunContext | undefined, options?: {
        write?: boolean;
    }): Promise<KnowledgeRun>;
    /** The strongest role on a scope page, or null. */
    roleOn(scope: KnowledgePage): Promise<KnowledgeRole | null>;
    /** The home scope page of a page the run can read. */
    scopeOf(page: KnowledgePage): Promise<KnowledgePage>;
    /** Throws unless the run holds at least `min` on `scope`. */
    require(scope: KnowledgePage, min: KnowledgeRole, action: string): Promise<void>;
    /**
     * A scope a write names (create home, move destination, note stamp). Unmaterialized scopes are
     * created only when the run's rules already give it at least `min` there, so a model can't spawn
     * scope pages it couldn't write to.
     */
    targetScope(address: string, min: KnowledgeRole, action: string): Promise<KnowledgePage>;
    /**
     * Resolves a page reference through the run's read view: a page id, a scope address,
     * `<scope>#<key>[/<key>…]` (walked key by key), or an exact name (ambiguous names are refused with candidate ids).
     * A scope that hasn't been created yet is not found, unless `createAt` is given and the run's rules give it at
     * least that role there: model-supplied references never create scope pages on a read.
     */
    page(ref: string, createAt?: KnowledgeRole): Promise<KnowledgePage>;
    /**
     * {@link page}, but a miss names up to a few readable pages whose name or path matches the ref's last
     * segment, by full ref, so a model that guessed a path can read the right one next. Costs one search on a miss.
     */
    pageOrCloseMatches(ref: string): Promise<KnowledgePage>;
}
/**
 * The run's principals in canonical form: its resolved run scopes plus its Memory identity. Every one
 * must match a declared scope type.
 * @internal
 */
export declare function knowledgeRunPrincipals(runtime: KnowledgeScopeRuntime, context: KnowledgeRunContext | undefined): string[];
//# sourceMappingURL=run.d.ts.map