@sema-agent/core
Version:
Stateless, task-oriented AI agent core
21 lines (20 loc) • 1.53 kB
TypeScript
import type { ToolCallPathTarget } from "./tool-face.js";
/** The longest scalar an argument rule reads, unless a policy states its own (`caps.maxScalarValueChars`): a longer value is not
* read, and the rule's lane wins (fail-closed). */
export declare const DEFAULT_MAX_SCALAR_VALUE_CHARS = 16384;
/** The call an argument rule is judged on: its arguments as the loop handed them, and its face (the tool's reading). */
export interface ParamRuleCall {
readonly args: unknown;
readonly face?: (object & {
readonly pathTarget?: ToolCallPathTarget | undefined;
}) | undefined;
}
/**
* Does the rule on argument `param` with `pattern` reach this call? Non-object arguments ⇒ no; own top-level properties only
* (`param` is a literal key, never a dotted path); scalar values only, trimmed, matched whole by the `*` glob; a value longer than
* `maxScalarValueChars` FAIL-CLOSES (reached: it cannot be read, so the rule's lane wins). A call without the parameter is reached
* by a rule whose value the tool's reading folds away ({@link readingAbsorbs}). A list in a slot the call's face reads element by
* element (`pathTarget.each`, the slot's `param` or an alias) is that many values: a tightening rule (`direction` `"tighten"`, a
* deny or an ask) reaches the call when it reaches ANY element, an allow only when it reaches EVERY one.
*/
export declare function paramRuleReaches(call: ParamRuleCall, param: string, pattern: string, maxScalarValueChars?: number, direction?: "tighten" | "allow"): boolean;