/** * Every string a user or the model can see from the guard is built here, so * approval prompts, denial reasons, notices, and `/guard` output share one * voice. Approval prompts are always returned in both languages for the DSH * UI; every other surface receives the active `GuardLocale`. * @module dsh-sensitive-guard/messages */ import type { RedactionHit } from './contracts.js'; import type { CanaryResult } from './egress/canary.js'; import type { EgressSnapshot } from './egress/index.js'; import type { EgressReport } from './egress/report.js'; import type { GuardLocale } from './locale.js'; export type { GuardLocale } from './locale.js'; /** Stable model-facing reason for a failed rule evaluation. */ export declare const EVALUATION_FAILURE_REASON = "Policy evaluation failed while checking this call."; export interface LocalizedText { en: string; zh: string; } /** One redacted operation summary, localized for the approval UI. */ export interface LocalizedAction { en: string; zh: string; } /** Risk categories shown instead of raw rule text. */ export type RiskKind = 'arguments-too-large' | 'secret-in-arguments' | 'embedded-credentials' | 'credential-query' | 'sensitive-path' | 'high-risk-command' | 'policy-approval' | 'default-approval' | 'evaluation-failed'; export interface Risk { kind: RiskKind; /** Rule-supplied explanation; sanitized before display. */ detail?: string; } export interface LocalizedReason { en: string; zh: string; readonly [locale: string]: string; } /** Normalize an action summary without changing its command or path text. */ export declare function cleanAction(action: string | undefined): string | undefined; /** * Collapse a rule reason to one bounded sentence. Reasons are authored without * secrets, but a project file can still contain newlines or control bytes. */ export declare function cleanDetail(detail: string | undefined): string | undefined; /** * Localized approval prompt. The web UI collapses newlines, so this stays one * line; the action summary is already redacted by the caller. */ export declare function approvalPrompt(tool: string, risk: Risk, action?: LocalizedAction): LocalizedReason; /** Model-facing approval reason; the localized prompt is rendered separately. */ export declare function approvalReason(tool: string, risk: Risk, locale?: GuardLocale): string; /** Model-facing denial: name the risk, explain it, and give one safe next step. */ export declare function denyReason(tool: string, risk: Risk, locale?: GuardLocale): string; /** Count-only notice; category names and counts are never sensitive. */ export declare function noticeText(hits: readonly RedactionHit[], locale?: GuardLocale): string; /** Compact egress state reused by `/guard status` and the startup line. */ export interface EgressSummary { bound: boolean; port: number; mode: string; envMatches: boolean; } export interface GuardStatus { mode: string; failClosed: boolean; inputLevel: string; outputLevel: string; policyRules: number; redactionRules: number; auditEnabled: boolean; auditPath: string; piiEnabled: boolean; piiRestore: boolean; /** Absent when `egress.enabled` is off. */ egress?: EgressSummary; } /** `/guard status`: a short key-value block, not a machine status line. */ export declare function statusText(status: GuardStatus, locale?: GuardLocale): string; /** One-line egress state for `/guard status` and the startup line. */ export declare function egressSummaryLine(summary: EgressSummary, locale?: GuardLocale): string; /** `/guard egress status`: listener, wiring, rules, counters, and recents. */ export declare function egressStatusText(snapshot: EgressSnapshot, locale?: GuardLocale): string; /** Result of one canary probe, including what to check when it fails. */ export declare function egressCanaryText(result: CanaryResult, port: number, locale?: GuardLocale): string; /** `/guard egress report`: destinations aggregated from the audit log. */ export declare function egressReportText(report: EgressReport, locale?: GuardLocale): string; export declare function egressReportUsage(locale?: GuardLocale): string; export declare function egressReportInvalidSince(locale?: GuardLocale): string; export declare function egressReportFailed(locale?: GuardLocale): string; /** `/guard egress` before `egress.enabled`. */ export declare function egressDisabledText(locale?: GuardLocale): string; /** `/guard egress` when the config is on but this process mounted nothing. */ export declare function egressUnavailableText(locale?: GuardLocale): string; /** Startup line emitted after the egress listener settles. */ export declare function egressStartupText(snapshot: EgressSnapshot, locale?: GuardLocale): string; /** `/guard on|off` confirmation; the mode is never persisted. */ export declare function modeText(mode: string, locale?: GuardLocale): string; /** Startup line emitted once by the plugin. */ export declare function startupText(args: { mode: string; policyRules: number; redactionRules: number; auditEnabled: boolean; }, locale?: GuardLocale): string; export declare function guardUsage(locale?: GuardLocale): string; export declare function restoreUsage(locale?: GuardLocale): string; export declare function unknownCommandText(verb: string, locale?: GuardLocale): string; export declare function restoreDisabledText(locale?: GuardLocale): string; export declare function restoreMissingText(locale?: GuardLocale): string; export declare function restoreInvalidText(locale?: GuardLocale): string; export declare function restoreUnknownText(locale?: GuardLocale): string; export declare function restoreExistsText(file: string, locale?: GuardLocale): string; export declare function restoreWriteFailedText(file: string, locale?: GuardLocale): string; export declare function restoreSuccessText(placeholder: string, file: string, locale?: GuardLocale): string; /** Human-readable byte limit for "arguments too large" explanations. */ export declare function formatBytes(bytes: number): string; //# sourceMappingURL=messages.d.ts.map