import { AgencyNode, Expression, InterpolationSegment, Scope } from "../types.js"; import type { BlockArgument } from "../types/blockArgument.js"; /** `BlockArgument` is a child of `FunctionCall`, not a standalone statement, * so it isn't in the `AgencyNode` union. But blocks DO appear on the ancestors * list when `walkNodes` descends into a block body — widen the type so * consumers can match `a.type === "blockArgument"`. */ export type WalkAncestor = AgencyNode | BlockArgument; export declare function isInsideBlock(ancestors: WalkAncestor[]): boolean; /** * The immediate *expression* children of any AST node — the single source of * truth for "what sub-expressions does this node contain". Consumed by * `attachExpressionsToFlow` (flow builder) and `checkConstMutations` * (scopes.ts) so neither re-implements the per-node-kind recursion. Returns * `[]` for leaves and for nested definitions (`function`/`graphNode`), which * own their scope and are walked separately. */ export declare function expressionChildren(node: AgencyNode): AgencyNode[]; /** * Extract the base variable name from an interpolation segment's expression. * Returns the variable name if the expression is a simple variable or the base * of a value access chain. For other expression types, returns an empty string. */ export declare function getBaseVarName(seg: InterpolationSegment): string; /** * Render an expression as a string WITHOUT scope prefix. * Used for prompt function bodies (where variables are function parameters) * and for re-emitting agency source code. */ export declare function expressionToString(expr: Expression): string; export declare function getAllVariablesInBody(body: AgencyNode[]): Generator<{ name: string; node: AgencyNode; }>; export declare function getNodesOfType(nodes: AgencyNode[], type: T): AgencyNode[]; export declare let walkNodeDebug: boolean; export declare const setWalkNodeDebug: (value: boolean) => boolean; export declare function walkNodes(nodes: AgencyNode[], ancestors?: WalkAncestor[], scopes?: Scope[]): Generator<{ node: AgencyNode; ancestors: WalkAncestor[]; scopes: Scope[]; }>; export declare function walkNodesArray(nodes: AgencyNode[], ancestors?: WalkAncestor[], scopes?: Scope[]): { node: AgencyNode; ancestors: WalkAncestor[]; scopes: Scope[]; }[]; export declare function getAllVariablesInBodyArray(body: AgencyNode[]): { name: string; node: AgencyNode; }[]; /** * The parser represents `null` as a variableName node — there is no * `{ type: "null" }` in parser output. Single point of truth for the check * so no caller ever tests `expr.type === "null"` (dead code). */ export declare function isNullLiteral(expr: Expression): boolean; /** * True when the expression is a self-contained literal: string, number, * boolean, null, or an object/array composed of literals all the way down. * Used by the optimizer to gate targets and proposed values — the * typechecker alone cannot enforce it, because an unknown bare identifier * (top-level or nested in a container) synthesizes to `any` and passes * typechecking unflagged. */ export declare function isLiteralExpression(expr: Expression): boolean; /** * True when a literal expression contains a string interpolation anywhere — * at top level or nested inside object/array literals. Structural traversal * only — no type semantics. */ export declare function hasInterpolation(expr: Expression): boolean;