import type { LearningRefusal, LearningRefusalDestination } from "@opengeni/contracts/learning-refusal"; /** * A correction the agent can make itself and then retry: * - `evidence_not_shared`: cited evidence is personal or not yet published, * so readers of the destination could not see it. * - `source_not_shared`: the entry's own source file or document is private * to its owner, belongs to another workspace or is not ready, so readers of * the destination could not open it. * - `reference_unavailable`: a referenced entry, revision, source, task note, * confirmation or Skill revision does not exist or is not visible here. * - `scope_kept`: the change named a scope other than the one it must keep * (an existing entry's or Skill's own scope, or where this chat learns). */ export type LearningSaveCorrection = "evidence_not_shared" | "source_not_shared" | "reference_unavailable" | "scope_kept"; /** * What one SQLSTATE 42501 refusal of a durable learning write means: * - `correction`: a fixable choice the agent made. The agent is told how to * fix it; the person is shown nothing. * - `fence`: the attempt, its host context or what it depended on is no * longer current. The change was not judged; the next attempt or turn * retries it under current authority, so no one is shown a refusal. * - `refusal`: a genuine decision a person can act on, Agent learning Off or * not permitted. The agent tells the person and the timeline shows it. */ export type LearningRefusalClass = { kind: "correction"; correction: LearningSaveCorrection; } | { kind: "fence"; } | { kind: "refusal"; reason: "learning_off" | "not_permitted"; }; /** * Every 42501 message the Knowledge, workspace instruction and Skill write * routines can raise, by its exact text, and what it means. This is the only * place that decides it. `learning-refusal-audit-postgres.test.ts` reads every * 42501 raise reachable from those routines in the migrated schema and fails * on one missing here, so a new message is classified on purpose instead of * silently becoming a refusal card. A message not listed (such as a * row-level security refusal) is still shown as `not_permitted`: a refusal * is never lost silently. */ export declare const LEARNING_REFUSAL_MESSAGES: ReadonlyMap; /** What a 42501 refusal of a durable learning write means; unlisted ones are shown. */ export declare function learningRefusalClass(message: string): LearningRefusalClass; /** Whether a 42501 refusal says the calling agent attempt is no longer live. */ export declare function isAgentAttemptLivenessFence(message: string): boolean; /** The correction the agent can make itself, or null. */ export declare function learningSaveCorrection(message: string): LearningSaveCorrection | null; /** The message of the 42501 raise inside a possibly wrapped driver error. */ export declare function nestedAuthorityRefusalMessage(error: unknown): string | null; /** * What a definite authority refusal of a durable learning write means for the * person, or null when it is a fence or a correction the agent can make * itself rather than a decision to show anyone. */ export declare function classifyLearningRefusal(input: { destination: LearningRefusalDestination; message: string; skillId?: string | undefined; }): LearningRefusal | null;