// engine/provider-adapters/shared/token-estimator.ts — SPEC-670: Cheap token estimator.
//
// Heuristic: ~4 chars per token (i.e. 0.25 tokens/char). Same convention as
// context-md-generator.ts and most OpenAI/Anthropic estimators for English prose.
/**
 * Default token budget for the markdown provider (planu/context.md).
 * Read from `planu.json#contextMd.maxTokens` if present at runtime; this is the fallback.
 */
export const MARKDOWN_MAX_TOKENS = 800;
/** Marker appended to truncated markdown output. */
export const MARKDOWN_TRUNCATE_MARKER = '…[truncated]';
/**
 * Tokens per character heuristic. 0.25 = 4 chars/token, the standard rough estimate
 * shared by OpenAI tiktoken (cl100k) and Anthropic for English markdown.
 */
export const TOKENS_PER_CHAR = 0.25;
/**
 * Estimate the token count of a string.
 *
 * Uses `length * TOKENS_PER_CHAR` and rounds up. Fast, deterministic, dependency-free.
 * For accurate counting, callers should re-estimate via the provider's own tokenizer.
 */
export function estimateTokens(text) {
    if (!text) {
        return 0;
    }
    return Math.ceil(text.length * TOKENS_PER_CHAR);
}
//# sourceMappingURL=token-estimator.js.map