import type { BackendAdmissionClass, BoundedTextEvidence, ContextPolicy, CustomSecret, GroundingBundle, OutputContract, RunMetadata, SearchResult, TotemConfig } from '@mmnto/totem'; import { CONFIG_FILES } from '@mmnto/totem'; import type { RuntimeBoundedTextEvidence } from './orchestrators/orchestrator.js'; /** execFileSync on Windows can't resolve executables without `shell: true`. */ export declare const IS_WIN: boolean; /** Timeout for GitHub CLI calls (ms). */ export declare const GH_TIMEOUT_MS = 15000; /** * Load environment variables from .env file (does not override existing). * Uses the `dotenv` library for robust parsing of inline comments, quoted * values containing `#`, and other edge cases. */ export declare function loadEnv(cwd: string): void; export { CONFIG_FILES }; export type ConfigFormat = 'ts' | 'yaml' | 'toml'; /** Return the global totem directory path (~/.totem/). Accepts override for testing. */ export declare function getGlobalTotemDir(homeDir?: string): string; /** * Resolve config path by checking the fallback chain: .ts → .yaml → .yml → .toml * Falls back to the global ~/.totem/ profile when no local config exists. */ export declare function resolveConfigPath(cwd: string, homeDir?: string): string; /** Check whether a resolved config path comes from the global ~/.totem/ profile. */ export declare function isGlobalConfigPath(configPath: string, homeDir?: string): boolean; /** * Load and validate Totem configuration from any supported format. * Routes parsing by file extension: .ts via jiti, .yaml/.yml via yaml, .toml via smol-toml. */ export declare function loadConfig(configPath: string): Promise; export { requireEmbedding } from '@mmnto/totem'; /** * Reap orphaned temp files older than `maxAgeMs` from `.totem/temp/`. * Fire-and-forget — never blocks the CLI critical path. */ export declare function reapOrphanedTempFiles(cwd: string, totemDir: string, maxAgeMs?: number): Promise; /** * Load a custom system prompt from `.totem/prompts/.md` if it exists. * Falls back to the built-in default prompt when the file is missing, empty, or unreadable. */ export declare function getSystemPrompt(commandName: string, defaultPrompt: string, cwd: string, totemDir: string): string; export declare function writeOutput(content: string, outPath?: string): void; export { sanitize } from '@mmnto/totem'; export { wrapUntrustedXml, wrapXml } from '@mmnto/totem'; export { matchesGlob } from '@mmnto/totem'; export declare function formatResults(results: SearchResult[], heading: string, condensed?: boolean): string; /** Default character budget for lesson sections across orchestrator commands. */ export declare const DEFAULT_MAX_LESSON_CHARS = 8000; /** * Partition search results into lessons (from lessons.md) and non-lesson specs. */ export declare function partitionLessons(allSpecs: SearchResult[], maxLessons: number, maxSpecs: number): { lessons: SearchResult[]; specs: SearchResult[]; }; /** * Format lessons as a prompt section with character budgeting. * Use `condensed` for high-frequency commands (triage) to save tokens. * Returns empty string if no lessons fit within the budget. */ export declare function formatLessonSection(lessons: SearchResult[], maxChars?: number, condensed?: boolean): string; export interface OrchestratorRunOptions { raw?: boolean; out?: string; model?: string; fresh?: boolean; } /** * Caller-supplied context for grounded run-artifact emission * (mmnto-ai/totem#2100). STRICTLY additive: callers that omit `artifact` * observe byte-identical `runOrchestrator` behavior — the #2106 constraint * (12 call sites compile untouched; spec/review migrate first). * * The caller supplies what only it knows (its grounding context + how that * context was assembled); `runOrchestrator` supplies what only IT knows (the * post-DLP masked prompt, the post-quota-fallback resolved backend, the * `OrchestratorResult` metrics that never leave this function). */ export interface RunArtifactRequest { /** Deterministic hash of the grounding surface — `calculateDeterministicHash(bundle)` when a bundle is supplied (mmnto-ai/totem#2101). */ groundingHash: string; /** Derived class-count summary (`summarizeProvenance(bundle)`) when a bundle is supplied; explicit string otherwise (bundle-less reruns of slice-1 artifacts). */ provenanceSummary: string; /** * Per-item provenance record (mmnto-ai/totem#2101), recorded verbatim into * `grounding.bundle`. Optional ONLY for reruns of slice-1 artifacts, which * carry their original grounding identity and have no bundle to forge. */ bundle?: GroundingBundle; /** Deterministic diff input when the run was scoped (`lint/review --branch`, #2098). */ diffScope?: string; /** The grounded spec contract, when the run senses against one. */ specContract?: string; /** Fires after a successful write (or dedup hit) with the content address + path. */ onEmitted?: (hash: string, artifactPath: string) => void; /** Fires after terminal invocation evidence is written (or deduplicated). */ onFailureEmitted?: (hash: string, artifactPath: string) => void; } type EvidenceMasker = (text: string, customSecrets?: CustomSecret[]) => string; /** * Convert bounded raw runtime text into persisted evidence. Masking and * terminal sanitization happen before a second UTF-8 byte bound because a * replacement may grow or shrink the retained text. A masking exception * fails closed: no raw bytes cross the artifact boundary. */ export declare function persistRuntimeTextEvidence(runtime: RuntimeBoundedTextEvidence, customSecrets?: CustomSecret[], limitBytes?: number, masker?: EvidenceMasker): BoundedTextEvidence; /** * Pre-bound provider-controlled terminal prose before DLP. Secret masking can * expand retained text, so `persistRuntimeTextEvidence` applies the same cap a * second time after masking; this first bound prevents unbounded regex work. */ export declare function runtimeMessageEvidence(message: string): RuntimeBoundedTextEvidence; /** The identity-relevant subset of a retrieval hit — what the bundle records. */ type RetrievalItem = Pick; /** * Assemble the grounding bundle for the spec/review retrieval shape * (mmnto-ai/totem#2101): every partition's items enter under their partition * as `sourceType`, classed `similarity-only` by the core builder. Shared by * both callers so the retrieval→bundle mapping has ONE enumeration — a * caller-local copy that drifted would silently drop a partition from the * provenance record. */ export declare function buildRetrievalGroundingBundle(context: { specs: RetrievalItem[]; sessions: RetrievalItem[]; code: RetrievalItem[]; lessons: RetrievalItem[]; }): GroundingBundle; /** * User-facing notice surfaced on the 0-code path. Advisory-neutral by design * (strategy#474 Q2): a broad/new-area `spec` can legitimately retrieve 0 code, * so this must read as a caveat, not a hard failure. */ export declare const CODE_BLIND_BANNER = "No code context retrieved \u2014 architecture claims are unverified against the codebase. Treat any file, type, or system specifics as unconfirmed assumptions, not facts."; /** * Directive folded into the system prompt on the 0-code path so the model * degrades instead of confabulating. Soft (LLM-side) by design — the banner * carries the deterministic guarantee. */ export declare const CODE_BLIND_PROMPT_DIRECTIVE: string; /** * True when retrieval returned zero code chunks — the 0-code grounding signal * (mmnto-ai/totem#2106). Keyed strictly on `code`, independent of * specs/sessions/lessons. */ export declare function isCodeBlind(context: { code: readonly unknown[]; }): boolean; export interface CodeBlindGuardResult { /** Whether the 0-code guard fired. */ codeBlind: boolean; /** System prompt to use: directive-augmented when `codeBlind`, else unchanged. */ systemPrompt: string; /** User-facing banner — present iff `codeBlind`. */ banner?: string; } /** * Apply the code-blind grounding guard for a `spec`/`review` run. Pure and * total: never throws, never disables — the command always proceeds. Callers * emit `banner` (when present) to their surface and pass `systemPrompt` on to * prompt assembly. */ export declare function applyCodeBlindGuard(context: { code: readonly unknown[]; }, systemPrompt: string): CodeBlindGuardResult; /** * Validate orchestrator config, then either output raw context (--raw) or * invoke the configured orchestrator provider and return the LLM content. * * Returns `undefined` in --raw mode (prompt already written to output). * Returns the LLM response content string otherwise. * Callers are responsible for writing output via `writeOutput()`. */ export declare function runOrchestrator(opts: { prompt: string; /** * Optional persistent system context that providers MAY cache server-side * (mmnto/totem#1291 Phase 3). When set AND the orchestrator config has * `enableContextCaching: true`, providers like Anthropic mark this segment * with `cache_control: { type: 'ephemeral' }` so subsequent calls within * the TTL window read from prompt cache at ~10% the input-token cost. */ systemPrompt?: string; tag: string; options: OrchestratorRunOptions; config: TotemConfig; cwd: string; /** Absolute path to the directory containing totem.config.* — used for cache paths instead of cwd */ configRoot?: string; totalResults?: number; temperature?: number; /** User-defined custom secrets to redact via DLP before outbound LLM calls (#921). */ customSecrets?: CustomSecret[]; /** * Opt-in grounded run-artifact emission (mmnto-ai/totem#2100). When set, a * successful ACTUAL invoke (never a response-cache hit) appends an immutable * content-addressed record under `/artifacts/runs/`. Emission * failure warns and never fails the run. Omitted = today's behavior. */ artifact?: RunArtifactRequest; /** Neutral task identity — records to `backend.taskProfile` as `task ?? tag` (`tag` stays the UI/cache/TTL key). */ task?: string; /** * The delivered grounding identity, reconciled with `artifact.bundle`: * one supplied serves both roles; both supplied must hash-agree, else a * hard ambiguous-grounding-identity error before any invoke. */ groundingBundle?: GroundingBundle; /** Requested admission class — gated against `orchestrator.capabilities.admissionClasses` before EACH invoke. Defaults to `completion_only`. */ backendAdmissionClass?: BackendAdmissionClass; /** Advisory context policy (budget unit: input tokens) — recorded into the artifact `admission` group. */ contextPolicy?: ContextPolicy; /** Caller-declared output contract — recorded; #2103 post-checks enforce. */ outputContract?: OutputContract; /** Caller identity metadata — recorded verbatim into the artifact `admission` group. */ runMetadata?: RunMetadata; }): Promise; //# sourceMappingURL=utils.d.ts.map