Compile a name pattern into a predicate. /body/flags compiles to a RegExp;
anything else (including a malformed literal, which is logged) becomes an
exact, case-sensitive match.
compileNameMatcher hands its returned predicate straight to .test()
against untrusted data: a viewer list column, an SDK psetName/propName
argument, or an LLM/agent-authored sandbox script's own call arguments
(packages/sandbox/src/bridge-query.ts's property tool forwards its
args unmodified into sdk.property → compileNameMatcher, and the regex
compiles and runs on the HOST's main thread, outside the QuickJS sandbox —
a pattern the sandboxed script "owns" can hang the real browser tab). For
that reason, before compiling a /regex/ literal's body, this runs it
through @ifc-lite/regex-guard's assertGuardedRegexPattern, which
rejects the well-known catastrophic-backtracking shapes and overlong
patterns.
Throws a plain Error — naming the pattern and the reason — when the body
is syntactically valid but rejected by the guard: unlike a malformed
literal, there is no safe fallback here, because the whole point of
rejecting it is to never call .test() with it. A caller that cannot let
an exception propagate (the sandbox bridge, in particular) MUST catch
this — see the callers' own comments for why a throw is safe to cross
that boundary.
Compile a name pattern into a predicate.
/body/flagscompiles to a RegExp; anything else (including a malformed literal, which is logged) becomes an exact, case-sensitive match.compileNameMatcherhands its returned predicate straight to.test()against untrusted data: a viewer list column, an SDKpsetName/propNameargument, or an LLM/agent-authored sandbox script's own call arguments (packages/sandbox/src/bridge-query.ts'spropertytool forwards its args unmodified intosdk.property→compileNameMatcher, and the regex compiles and runs on the HOST's main thread, outside the QuickJS sandbox — a pattern the sandboxed script "owns" can hang the real browser tab). For that reason, before compiling a/regex/literal's body, this runs it through@ifc-lite/regex-guard'sassertGuardedRegexPattern, which rejects the well-known catastrophic-backtracking shapes and overlong patterns.Throws a plain
Error— naming the pattern and the reason — when the body is syntactically valid but rejected by the guard: unlike a malformed literal, there is no safe fallback here, because the whole point of rejecting it is to never call.test()with it. A caller that cannot let an exception propagate (the sandbox bridge, in particular) MUST catch this — see the callers' own comments for why a throw is safe to cross that boundary.