different-ai/openwork · error · InterpreterRuntimeError
${ref.namespace}.${ref.name} is not available in CodeMode.
Error message
${ref.namespace}.${ref.name} is not available in CodeMode. What it means
Constructors/statics for RegExp, Map, Set, and URLSearchParams are entirely unavailable in CodeMode's global-method dispatch. invokeGlobalMethod throws this namespaced error for any method reference on those namespaces rather than attempting partial support.
Source
Thrown at packages/codemode/src/interpreter/runtime.ts:571
throw new InterpreterRuntimeError(`console.${ref.name} is not available in CodeMode.`, node)
if (ref.namespace === "Object") return invokeObjectMethod(ref.name, args, node)
if (ref.namespace === "Math") return invokeMathMethod(ref.name, args, node)
if (ref.namespace === "Array") return invokeArrayStatic(ref.name, args, node)
if (ref.namespace === "Number") return invokeNumberStatic(ref.name, args, node)
if (ref.namespace === "String") return invokeStringStatic(ref.name, args, node)
if (ref.namespace === "URL") return invokeURLStatic(ref.name, args, node)
if (ref.namespace === "Date") {
if (!dateStatics.has(ref.name))
throw new InterpreterRuntimeError(`Date.${ref.name} is not available in CodeMode.`, node)
return invokeDateStatic(ref.name, args, node)
}
if (
ref.namespace === "RegExp" ||
ref.namespace === "Map" ||
ref.namespace === "Set" ||
ref.namespace === "URLSearchParams"
) {
throw new InterpreterRuntimeError(`${ref.namespace}.${ref.name} is not available in CodeMode.`, node)
}
return invokeJsonMethod(ref.name, args, node)
}
// Every identifier a parameter pattern binds, used to seed TDZ slots before defaults run.
const collectPatternNames = (pattern: AstNode, out: Array<string> = []): Array<string> => {
switch (pattern.type) {
case "Identifier":
out.push(getString(pattern, "name"))
break
case "AssignmentPattern":
collectPatternNames(getNode(pattern, "left"), out)
break
case "RestElement":
collectPatternNames(getNode(pattern, "argument"), out)
break
case "ArrayPattern":
for (const element of getArray(pattern, "elements")) {View on GitHub (pinned to 2b7df46e8a)
Solutions
- Use supported alternatives: object literals as maps, array + includes for sets, string methods for parsing
- Parse query strings manually with split/map over supported string methods
- Do regex or URL work in a host tool call instead of inline CodeMode
Example fix
// before
const params = new URLSearchParams(qs).get('id');
// after
const params = qs.split('&').map(p => p.split('=')).find(p => p[0] === 'id')?.[1] ?? null; Defensive patterns
Strategy: validation
Validate before calling
const bannedNamespaces = ['RegExp','Map','Set','URLSearchParams'];
for (const ns of bannedNamespaces) {
if (new RegExp(`\\b${ns}\\s*\\.`).test(code)) throw new Error(`${ns}.* is unavailable in CodeMode`);
} Prevention
- Avoid RegExp/Map/Set/URLSearchParams globals in sandbox code
- Use object literals, arrays, and string methods as substitutes
- Delegate regex-heavy or URL parsing work to host tools
- Add a pre-execution lint for banned global namespaces
When it happens
Trigger: Calling RegExp.something, Map.something, Set.something, or URLSearchParams.something in CodeMode code (e.g. new-dependent patterns expressed as static calls, or Set.from-like usage).
Common situations: Code that manipulates query strings via URLSearchParams; dedup logic assuming Set statics; dynamic regex construction via RegExp static calls; LLM-generated code using these globals.
Related errors
- String method '${name}' is not available in CodeMode.
- Array.${name} is not available in CodeMode.
- console.${ref.name} is not available in CodeMode.
- Date.${ref.name} is not available in CodeMode.
- RegExp method '${name}' is not available in CodeMode.
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/7e63ded44da9d34a.
Report an issue: GitHub.