import type { CompiledContextPack, ContextPackCommunityContext, ContextPackEvidenceClass, ContextPackExpandablePreview, ContextPackExplainAnswerReadySummary, ContextPackExecutionSlice, ContextPackGraphSignals, ContextPackNode, ContextPackRelationship, ContextPackTaskContract, ContextPackTaskKind } from '../contracts/context-pack.js'; import type { RetrievalGateDecision } from '../contracts/retrieval-gate.js'; import type { TaskIntentKind } from '../contracts/task-intent.js'; import { type SourceDomain } from '../shared/source-discovery.js'; export interface ClassifyTaskContractOptions { budget: number; prompt?: string; task_intent?: TaskIntentKind; has_change_evidence?: boolean; } export interface ContextPackNodeCandidate { label: string; node_id?: string | undefined; community?: number | null; source_file?: string; line_number?: number; file_type?: string; node_kind?: string; framework?: string; framework_role?: string; framework_boost?: number; source_domain?: SourceDomain; match_score?: number; exact_anchor_match?: boolean; direct_symbol_match?: boolean; source_path_match?: boolean; graph_signal?: 'bridge' | 'god' | 'high-impact'; graph_degree?: number; snippet?: string | null; evidence_class: ContextPackEvidenceClass; expandable_ref?: ContextPackExpandablePreview; estimate_tokens: () => number; build_entry: () => TNode; } export interface CompileContextPackInput { task_contract: ContextPackTaskContract; nodes: readonly ContextPackNodeCandidate[]; relationships?: readonly TRelationship[]; community_context?: readonly TCommunity[]; graph_signals?: ContextPackGraphSignals; /** * Retrieval-gate decision (#75). When supplied, the resulting * CompiledContextPack carries it through unchanged so consumers can * audit retrieval scope. The gate is *not* re-classified here — callers * compute it once and pass the result down. */ retrieval_gate?: RetrievalGateDecision; /** * v0.20 #131 — strategy for choosing candidates under budget: * - 'evidence-order' (default): walk sortCandidatesByEvidence order, * take until budget overflow. Same behaviour as v0.19 and earlier. * - 'value-per-token': required-evidence-class candidates are * placed first (must-include), then the remaining optional * candidates are picked by density (score / token_cost) via * selectByValuePerToken. Higher information density per token at * the same budget. */ selection_strategy?: ContextPackSelectionStrategy; } export type ContextPackSelectionStrategy = 'evidence-order' | 'value-per-token'; export type CompactContextPackMode = { kind: 'retrieve'; max_nodes?: number; hoist_empty_shared_file_type?: boolean; } | { kind: 'review'; seed_node_ids?: readonly string[]; seed_labels?: readonly string[]; max_supporting_nodes?: number; }; export declare function classifyTaskContract(taskKind: ContextPackTaskKind, options: ClassifyTaskContractOptions): ContextPackTaskContract; export declare function estimateContextPackEntryTokens(label: string, sourceFile: string, lineNumber: number, snippet: string | null): number; export declare function renderCompiledContextPackNodes(taskContract: ContextPackTaskContract, nodes: readonly TNode[], relationships: readonly TRelationship[]): { nodes: TNode[]; token_count: number; }; export declare function compileContextPack(input: CompileContextPackInput): CompiledContextPack; export declare function compactContextPack(pack: CompiledContextPack, mode: CompactContextPackMode): CompiledContextPack; export declare function generateAnswerReadyFromExecutionSlice(executionSlice: ContextPackExecutionSlice | undefined, taskKind: ContextPackTaskKind): ContextPackExplainAnswerReadySummary | undefined;