different-ai/openwork · error · InterpreterRuntimeError
String.${name} is not available in CodeMode.
Error message
String.${name} is not available in CodeMode. What it means
CodeMode only whitelists the String statics fromCharCode and fromCodePoint. Any other String.* static (e.g. String.raw, String.fromCharCode-adjacent helpers) is rejected by the sandbox to keep the exposed API surface minimal.
Source
Thrown at packages/codemode/src/stdlib/string.ts:49
"search",
"localeCompare",
"normalize",
])
export const stringStatics = new Set(["fromCharCode", "fromCodePoint"])
export const invokeStringStatic = (name: string, args: Array<unknown>, node: AstNode): unknown => {
const codes = args.map((arg) => {
if (typeof arg !== "number") throw new InterpreterRuntimeError(`String.${name} expects number arguments.`, node)
return arg
})
switch (name) {
case "fromCharCode":
return String.fromCharCode(...codes)
case "fromCodePoint":
return String.fromCodePoint(...codes)
default:
throw new InterpreterRuntimeError(`String.${name} is not available in CodeMode.`, node)
}
}
import { type AstNode, InterpreterRuntimeError } from "../interpreter/model.js"
View on GitHub (pinned to 2b7df46e8a)
Solutions
- Use only fromCharCode or fromCodePoint.
- Replace String.raw with an explicitly escaped string literal.
- Build the needed helper in plain CodeMode code (e.g. a template literal instead of String.raw).
Example fix
// before const p = String.raw`\n\t` // after const p = "\\n\\t"
Defensive patterns
Strategy: validation
Validate before calling
const stringStatics = new Set(["fromCharCode", "fromCodePoint"])
if (!stringStatics.has(name)) throw new TypeError(`String.${name} unsupported in CodeMode`) Type guard
const isAllowedStringStatic = (name) => ["fromCharCode", "fromCodePoint"].includes(name)
Try / catch
try { v = String.raw`\n` } catch { v = "\\n" } Prevention
- Replace String.raw with escaped literals
- Keep a mental whitelist of sandbox String statics
- Lint sandbox scripts against forbidden APIs
When it happens
Trigger: Calling `String.raw`...`` or any static other than fromCharCode/fromCodePoint on the sandbox String object.
Common situations: Copying normal JS snippets into CodeMode that rely on String.raw or other statics; assuming the sandbox mirrors full ECMAScript.
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.
- ${ref.namespace}.${ref.name} is not available in CodeMode.
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/b51c83f2690ea8d8.
Report an issue: GitHub.