import type { Effect } from "../ast/nodes.js"; import type { TypeExpr } from "../ast/types.js"; /** * A concrete AST patch an agent can apply to fix an error. * `nodeId` identifies the node to patch, `field` is the field to change, * and `value` is the new value for that field. */ export interface FixSuggestion { nodeId: string | null; field: string; value: unknown; } /** * Union of all compiler errors (Phase 1–4). */ export type StructuredError = DuplicateIdError | UnknownNodeKindError | MissingFieldError | InvalidFieldTypeError | InvalidEffectError | InvalidOperatorError | InvalidBasicTypeName | ConflictingEffectsError | UndefinedReferenceError | DuplicateDefinitionError | UnknownRecordError | UnknownEnumError | UnknownVariantError | TypeMismatchError | UnitMismatchError | ArityMismatchError | NotAFunctionError | UnknownFieldError | MissingRecordFieldsError | FunctionComplexityExceededError | ModuleComplexityExceededError | EffectViolationError | EffectInPureError | ContractFailureError | VerificationTimeoutError | UndecidablePredicateError | PreconditionNotMetError | InvalidSemanticAssertionError | PatchNodeNotFoundError | PatchInvalidFieldError | PatchIndexOutOfRangeError | PatchDeleteNotInArrayError | WasmValidationError | MissingEntryPointError | UnsatisfiedRequirementError | DuplicateProvisionError | CircularImportError | UnresolvedModuleError | DuplicateModuleNameError | MissingExternalModuleError | MigrationFailedError | UnsupportedSchemaVersionError | CapabilityMissingError | ApprovalPropagationMissingError | UnknownToolError | ToolArgMismatchError | ScaffoldFailedError | DeployFailedError | UnknownDeployTargetError | QuickJSRuntimeError; export interface DuplicateIdError { error: "duplicate_id"; nodeId: string; firstPath: string; secondPath: string; } export interface UnknownNodeKindError { error: "unknown_node_kind"; path: string; received: string; validKinds: readonly string[]; suggestion?: FixSuggestion; } export interface MissingFieldError { error: "missing_field"; path: string; nodeId: string | null; field: string; expectedFormat: string; hint: string; suggestion?: FixSuggestion; } export interface InvalidFieldTypeError { error: "invalid_field_type"; path: string; nodeId: string | null; field: string; expectedFormat: string; actualFormat: string; } export interface InvalidEffectError { error: "invalid_effect"; path: string; nodeId: string | null; received: string; validEffects: readonly string[]; } export interface InvalidOperatorError { error: "invalid_operator"; path: string; nodeId: string | null; received: string; validOperators: readonly string[]; } export interface InvalidBasicTypeName { error: "invalid_basic_type_name"; path: string; nodeId: string | null; received: string; validNames: readonly string[]; } export interface ConflictingEffectsError { error: "conflicting_effects"; path: string; nodeId: string | null; effectsFound: string[]; } export interface UndefinedReferenceError { error: "undefined_reference"; nodeId: string | null; name: string; candidates: string[]; suggestion?: FixSuggestion; } export interface DuplicateDefinitionError { error: "duplicate_definition"; nodeId: string | null; name: string; firstNodeId: string | null; } export interface UnknownRecordError { error: "unknown_record"; nodeId: string | null; name: string; candidates: string[]; suggestion?: FixSuggestion; } export interface UnknownEnumError { error: "unknown_enum"; nodeId: string | null; name: string; candidates: string[]; suggestion?: FixSuggestion; } export interface UnknownVariantError { error: "unknown_variant"; nodeId: string | null; enumName: string; variantName: string; availableVariants: string[]; suggestion?: FixSuggestion; } export interface TypeMismatchError { error: "type_mismatch"; nodeId: string | null; expected: TypeExpr; actual: TypeExpr; suggestion?: FixSuggestion; } export interface UnitMismatchError { error: "unit_mismatch"; nodeId: string | null; expectedUnit: string; actualUnit: string; expectedBase: "Int" | "Float"; actualBase: "Int" | "Float"; } export interface ArityMismatchError { error: "arity_mismatch"; nodeId: string | null; expected: number; actual: number; } export interface NotAFunctionError { error: "not_a_function"; nodeId: string | null; actualType: TypeExpr; } export interface UnknownFieldError { error: "unknown_field"; nodeId: string | null; recordName: string; fieldName: string; availableFields: string[]; suggestion?: FixSuggestion; } export interface MissingRecordFieldsError { error: "missing_record_fields"; nodeId: string | null; recordName: string; missingFields: string[]; suggestion?: FixSuggestion; } export declare function duplicateId(nodeId: string, firstPath: string, secondPath: string): DuplicateIdError; export declare function unknownNodeKind(path: string, received: string, validKinds: readonly string[], suggestion?: FixSuggestion): UnknownNodeKindError; export declare function missingField(path: string, nodeId: string | null, field: string, expectedFormat: string, suggestion?: FixSuggestion): MissingFieldError; export declare function invalidFieldType(path: string, nodeId: string | null, field: string, expectedFormat: string, actualFormat: string): InvalidFieldTypeError; export declare function invalidEffect(path: string, nodeId: string | null, received: string, validEffects: readonly string[]): InvalidEffectError; export declare function invalidOperator(path: string, nodeId: string | null, received: string, validOperators: readonly string[]): InvalidOperatorError; export declare function invalidBasicTypeName(path: string, nodeId: string | null, received: string, validNames: readonly string[]): InvalidBasicTypeName; export declare function conflictingEffects(path: string, nodeId: string | null, effectsFound: string[]): ConflictingEffectsError; export declare function undefinedReference(nodeId: string | null, name: string, candidates: string[], suggestion?: FixSuggestion): UndefinedReferenceError; export declare function duplicateDefinition(nodeId: string | null, name: string, firstNodeId: string | null): DuplicateDefinitionError; export declare function unknownRecord(nodeId: string | null, name: string, candidates: string[], suggestion?: FixSuggestion): UnknownRecordError; export declare function unknownEnum(nodeId: string | null, name: string, candidates: string[], suggestion?: FixSuggestion): UnknownEnumError; export declare function unknownVariant(nodeId: string | null, enumName: string, variantName: string, availableVariants: string[], suggestion?: FixSuggestion): UnknownVariantError; export declare function typeMismatch(nodeId: string | null, expected: TypeExpr, actual: TypeExpr, suggestion?: FixSuggestion): TypeMismatchError; export declare function unitMismatch(nodeId: string | null, expectedUnit: string, actualUnit: string, expectedBase: "Int" | "Float", actualBase: "Int" | "Float"): UnitMismatchError; export declare function arityMismatch(nodeId: string | null, expected: number, actual: number): ArityMismatchError; export declare function notAFunction(nodeId: string | null, actualType: TypeExpr): NotAFunctionError; export declare function unknownField(nodeId: string | null, recordName: string, fieldName: string, availableFields: string[], suggestion?: FixSuggestion): UnknownFieldError; export declare function missingRecordFields(nodeId: string | null, recordName: string, missingFields: string[], suggestion?: FixSuggestion): MissingRecordFieldsError; export interface FunctionComplexityExceededError { error: "function_complexity_exceeded"; nodeId: string; functionName: string; metric: "maxAstNodes" | "maxCallDepth" | "maxBranches"; actual: number; limit: number; } export interface ModuleComplexityExceededError { error: "module_complexity_exceeded"; metric: "maxAstNodes" | "maxCallDepth" | "maxBranches"; actual: number; limit: number; } export declare function functionComplexityExceeded(nodeId: string, functionName: string, metric: "maxAstNodes" | "maxCallDepth" | "maxBranches", actual: number, limit: number): FunctionComplexityExceededError; export declare function moduleComplexityExceeded(metric: "maxAstNodes" | "maxCallDepth" | "maxBranches", actual: number, limit: number): ModuleComplexityExceededError; export interface EffectViolationError { error: "effect_violation"; nodeId: string | null; functionName: string; missingEffects: Effect[]; callSiteNodeId: string | null; calleeName: string; suggestion?: FixSuggestion; } export interface EffectInPureError { error: "effect_in_pure"; nodeId: string | null; functionName: string; callSiteNodeId: string | null; calleeName: string; calleeEffects: Effect[]; suggestion?: FixSuggestion; } export declare function effectViolation(nodeId: string | null, functionName: string, missingEffects: Effect[], callSiteNodeId: string | null, calleeName: string, suggestion?: FixSuggestion): EffectViolationError; export declare function effectInPure(nodeId: string | null, functionName: string, callSiteNodeId: string | null, calleeName: string, calleeEffects: Effect[], suggestion?: FixSuggestion): EffectInPureError; export interface ContractFailureError { error: "contract_failure"; nodeId: string; contractId: string; functionName: string; contractKind: "pre" | "post"; counterexample: Record; semanticAssertion?: string; } export interface VerificationTimeoutError { error: "verification_timeout"; nodeId: string; contractId: string; functionName: string; timeoutMs: number; } export interface UndecidablePredicateError { error: "undecidable_predicate"; nodeId: string; contractId: string; functionName: string; unsupportedNodeKind: string; } export interface PreconditionNotMetError { error: "precondition_not_met"; nodeId: string; callSiteId: string; callerName: string; calleeName: string; contractId: string; counterexample: Record; } export interface InvalidSemanticAssertionError { error: "invalid_semantic_assertion"; nodeId: string; contractId: string; received: string; validAssertions: readonly string[]; } export declare function contractFailure(nodeId: string, contractId: string, functionName: string, contractKind: "pre" | "post", counterexample: Record, semanticAssertion?: string): ContractFailureError; export declare function verificationTimeout(nodeId: string, contractId: string, functionName: string, timeoutMs: number): VerificationTimeoutError; export declare function undecidablePredicate(nodeId: string, contractId: string, functionName: string, unsupportedNodeKind: string): UndecidablePredicateError; export declare function preconditionNotMet(nodeId: string, callSiteId: string, callerName: string, calleeName: string, contractId: string, counterexample: Record): PreconditionNotMetError; export declare function invalidSemanticAssertion(nodeId: string, contractId: string, received: string, validAssertions: readonly string[]): InvalidSemanticAssertionError; export interface PatchNodeNotFoundError { error: "patch_node_not_found"; nodeId: string | null; patchIndex: number; } export interface PatchInvalidFieldError { error: "patch_invalid_field"; nodeId: string; field: string; availableFields: string[]; patchIndex: number; } export interface PatchIndexOutOfRangeError { error: "patch_index_out_of_range"; nodeId: string; field: string; index: number; arrayLength: number; patchIndex: number; } export interface PatchDeleteNotInArrayError { error: "patch_delete_not_in_array"; nodeId: string; patchIndex: number; } export declare function patchNodeNotFound(nodeId: string | null, patchIndex: number): PatchNodeNotFoundError; export declare function patchInvalidField(nodeId: string, field: string, availableFields: string[], patchIndex: number): PatchInvalidFieldError; export declare function patchIndexOutOfRange(nodeId: string, field: string, index: number, arrayLength: number, patchIndex: number): PatchIndexOutOfRangeError; export declare function patchDeleteNotInArray(nodeId: string, patchIndex: number): PatchDeleteNotInArrayError; export type AnalysisDiagnosticKind = "effect_skipped_import" | "effect_skipped_unknown_callee" | "contract_skipped_unsupported_params"; export interface AnalysisDiagnostic { diagnostic: AnalysisDiagnosticKind; functionName: string; nodeId: string; phase: "effects" | "contracts"; /** Additional context, e.g. the import name or unsupported param type */ detail?: string; } export interface VerificationCoverage { effects: { checked: number; skipped: number; total: number; }; contracts: { proven: number; skipped: number; total: number; }; } export declare function analysisDiagnostic(diagnostic: AnalysisDiagnosticKind, functionName: string, nodeId: string, phase: "effects" | "contracts", detail?: string): AnalysisDiagnostic; export interface WasmValidationError { error: "wasm_validation_error"; message: string; } export interface MissingEntryPointError { error: "missing_entry_point"; entryPointName: string; } export declare function wasmValidationError(message: string): WasmValidationError; export declare function missingEntryPoint(entryPointName: string): MissingEntryPointError; export interface UnsatisfiedRequirementError { error: "unsatisfied_requirement"; fragmentId: string; requirement: string; availableProvisions: string[]; } export interface DuplicateProvisionError { error: "duplicate_provision"; name: string; fragmentIds: string[]; } export declare function unsatisfiedRequirement(fragmentId: string, requirement: string, availableProvisions: string[]): UnsatisfiedRequirementError; export declare function duplicateProvision(name: string, fragmentIds: string[]): DuplicateProvisionError; export interface CircularImportError { error: "circular_import"; cycle: string[]; nodeId: string | null; } export interface UnresolvedModuleError { error: "unresolved_module"; moduleName: string; importNodeId: string; available: string[]; } export interface DuplicateModuleNameError { error: "duplicate_module_name"; moduleName: string; moduleIds: string[]; } export declare function circularImport(cycle: string[], nodeId?: string | null): CircularImportError; export declare function unresolvedModule(moduleName: string, importNodeId: string, available: string[]): UnresolvedModuleError; export declare function duplicateModuleName(moduleName: string, moduleIds: string[]): DuplicateModuleNameError; export interface MissingExternalModuleError { error: "missing_external_module"; module: string; availableModules: string[]; } export declare function missingExternalModule(module: string, availableModules: string[]): MissingExternalModuleError; export interface MigrationFailedError { error: "migration_failed"; fromVersion: string; toVersion: string; detail: string; } export interface UnsupportedSchemaVersionError { error: "unsupported_schema_version"; version: string; supportedRange: { min: string; max: string; }; } export declare function migrationFailed(fromVersion: string, toVersion: string, detail: string): MigrationFailedError; export declare function unsupportedSchemaVersion(version: string, supportedRange: { min: string; max: string; }): UnsupportedSchemaVersionError; export interface CapabilityMissingError { error: "capability_missing"; nodeId: string | null; required: string[]; available: string[]; suggestion?: FixSuggestion; } /** Emit when a function call requires capability permissions the caller doesn't have. */ export declare function capabilityMissing(nodeId: string | null, required: string[], available: string[], suggestion?: FixSuggestion): CapabilityMissingError; export interface ApprovalPropagationMissingError { error: "approval_propagation_missing"; nodeId: string | null; functionName: string; callSiteNodeId: string | null; calleeName: string; calleeApproval: { scope: string; reason: string; }; suggestion?: FixSuggestion; } /** Emit when a function calls an approval-gated callee without being approval-gated itself. */ export declare function approvalPropagationMissing(nodeId: string | null, functionName: string, callSiteNodeId: string | null, calleeName: string, calleeApproval: { scope: string; reason: string; }, suggestion?: FixSuggestion): ApprovalPropagationMissingError; export interface UnknownToolError { error: "unknown_tool"; nodeId: string | null; toolName: string; registeredTools: string[]; suggestion?: FixSuggestion; } export interface ToolArgMismatchError { error: "tool_arg_mismatch"; nodeId: string | null; toolName: string; missingArgs: string[]; extraArgs: string[]; typeMismatches: { arg: string; expected: TypeExpr; actual: TypeExpr; }[]; } /** Emit when a tool_call references a tool name not registered in any ToolDef. */ export declare function unknownTool(nodeId: string | null, toolName: string, registeredTools: string[], suggestion?: FixSuggestion): UnknownToolError; /** Emit when tool_call args don't match the tool's parameter signature. */ export declare function toolArgMismatch(nodeId: string | null, toolName: string, missingArgs: string[], extraArgs: string[], typeMismatches: { arg: string; expected: TypeExpr; actual: TypeExpr; }[]): ToolArgMismatchError; export interface ScaffoldFailedError { error: "scaffold_failed"; reason: string; } export interface DeployFailedError { error: "deploy_failed"; code?: string; reason?: string; responseBody?: string; } export interface UnknownDeployTargetError { error: "unknown_deploy_target"; target: string; validTargets: string[]; } export declare function scaffoldFailed(reason: string): ScaffoldFailedError; export declare function deployFailed(code?: string, reason?: string, responseBody?: string): DeployFailedError; export declare function unknownDeployTarget(target: string, validTargets: string[]): UnknownDeployTargetError; export interface QuickJSRuntimeError { error: "quickjs_runtime_error"; message: string; } export declare function quickjsRuntimeError(message: string): QuickJSRuntimeError; //# sourceMappingURL=structured-errors.d.ts.map