UNPKG

@adonis-agora/agent

Version:

Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.

23 lines • 1.57 kB
/** * A screen for the one thing a remote JSON Schema can do to the process that validates against it. * * Every validator in the MCP SDK compiles a schema's `pattern` to a native `RegExp`, and JS regex * matching backtracks: `(a+)+$` against 27 a's and a non-matching tail takes ~1s, 30 a's ~8s, 40 a's * longer than anyone will wait — synchronously, on the only thread the process has. The pattern is * written by the remote server and the string is written by the model, which the same server's tool * description is free to steer, so the whole thing fits inside one tool definition. * * What is detected is the shape that makes backtracking EXPONENTIAL: an unbounded repetition whose * body can match one piece of text in more than one way, so a failed match has to try every split. * It is a structural screen and not a decision procedure — `(ab|abc)+` is ambiguous across * alternatives and is not flagged here. A host that needs a guarantee rather than a screen gives * `validator` an engine that does not backtrack (AJV's `code.regExp` option takes an RE2 binding). */ /** Whether this pattern can be made to backtrack exponentially. See the file comment for the limits. */ export declare function isUnsafeRegex(pattern: string): boolean; /** * The first pattern anywhere in a JSON Schema that {@link isUnsafeRegex} flags — `pattern` at any * depth, and the keys of `patternProperties`, which are regexes too. */ export declare function findUnsafePattern(schema: unknown): string | undefined; //# sourceMappingURL=unsafe-regex.d.ts.map