different-ai/openwork · error · InterpreterRuntimeError
Date.${ref.name} is not available in CodeMode.
Error message
Date.${ref.name} is not available in CodeMode. What it means
CodeMode exposes only a whitelist of Date statics (dateStatics). Any Date.<name> reference not present in that set is rejected before invokeDateStatic runs. This prevents use of statics the interpreter has not validated for determinism or safety.
Source
Thrown at packages/codemode/src/interpreter/runtime.ts:562
throw new InterpreterRuntimeError("Array.from expects an array, string, Map, Set, or array-like value.", node)
}
default:
throw new InterpreterRuntimeError(`Array.${name} is not available in CodeMode.`, node)
}
}
const invokeGlobalMethod = (ref: GlobalMethodReference, args: Array<unknown>, node: AstNode): unknown => {
if (ref.namespace === "console")
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"))View on GitHub (pinned to 2b7df46e8a)
Solutions
- Check dateStatics in the runtime for supported Date statics and use only those
- Pass timestamps in as arguments from the host instead of computing Date.now() inside the code
- Do date parsing/formatting outside CodeMode and feed results in
Example fix
// before const ts = Date.now(); // after // host passes timestamp as an input parameter const ts = now; // `now` provided by the caller
Defensive patterns
Strategy: validation
Validate before calling
const supportedDateStatics = ['now','parse','UTC']; // verify against dateStatics in runtime
for (const m of code.matchAll(/Date\.([A-Za-z_$][\w$]*)/g)) {
if (!supportedDateStatics.includes(m[1])) throw new Error(`Date.${m[1]} unsupported in CodeMode`);
} Type guard
function dateStaticSupported(name, whitelist) { return whitelist.has(name); } Prevention
- Check dateStatics in the runtime before using Date.*
- Pass timestamps as inputs from the host rather than calling Date.now() in code
- Do complex date parsing outside the sandbox
When it happens
Trigger: Calling unsupported Date statics such as Date.now() (if not whitelisted), Date.parse, Date.UTC, or mistyped names like date.now; dispatched from invokeGlobalMethod when namespace === 'Date'.
Common situations: Timestamping work inside sandboxed code expecting Date.now(); parsing date strings with Date.parse; assuming full Date API parity with standard JS.
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.
- ${ref.namespace}.${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/3d37a6229387bfb4.
Report an issue: GitHub.