UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

29 lines (28 loc) • 2.4 kB
import type { ArtifactResultCode } from "../../core/artifact-host.js"; /** Rejections of one key/reason/message before the banner rides (upstream `E = 3`). */ export declare const ARTIFACT_REJECT_BREAKER_THRESHOLD = 3; /** Each key component is read at most this long (upstream `I = 1024`). */ export declare const ARTIFACT_REJECT_KEY_COMPONENT_MAX = 1024; /** The banner for a rejection the model can act on (fix the arguments, or stop and tell the user). */ export declare const ARTIFACT_REJECT_BANNER_RETRYABLE = "IMPORTANT: Artifact calls for this target have now been rejected 3 or more times in this session for the same reason. Do not send the same call again: either make the specific change the error describes, or stop calling Artifact for this target and tell the user what is failing and why."; /** The banner for a host-authority refusal that no argument change can get past. */ export declare const ARTIFACT_REJECT_BANNER_REFUSAL = "IMPORTANT: Artifact calls for this target have now been rejected 3 or more times in this session for the same reason. Stop calling Artifact for this target and tell the user the artifact could not be published and why \u2014 do not try to work around this refusal."; /** The result codes whose banner is the refusal form: the host's authority said no, and "work around it" is not an option. */ export declare const ARTIFACT_REJECT_REFUSAL_CODES: ReadonlySet<ArtifactResultCode>; /** The target key of a call: action (omitted ⇒ publish), file_path and url, NUL-joined. */ export declare function artifactRejectKeyOf(args: unknown): string; /** A rejection text with a banner this module put in front of it stripped, so the fingerprint of the third rejection equals the first's. */ export declare function stripArtifactRejectBanner(text: string): string; export declare function artifactRejectBannerFor(reason: string): string; export interface ArtifactRejectBreaker { /** Record a rejection; the count of consecutive same-key/same-reason/same-message rejections including this one. */ hit(key: string, reason: string, text: string): number; /** A successful call: forget every streak. */ clear(): void; /** Inspection: the live streak of a key, if any. */ streakOf(key: string): { reason: string; count: number; } | undefined; } export declare function createArtifactRejectBreaker(): ArtifactRejectBreaker;