Summary
The README states that CallScript supports serverless and edge environments, but the core package currently relies on the Node-specific global Buffer.
The affected locations are:
packages/callscript/src/expr/eval.ts— Base64 and Base64URL helperspackages/callscript/src/execute.ts— tool-result byte measurementpackages/callscript/src/runner.ts— digest-output byte measurement
In a web-standard runtime where globalThis.Buffer is unavailable, Base64 expressions fail, and ordinary tool results can turn an otherwise successful run into an error.
Reproduction
Using the built package:
import { callscript, evalExpr, tool } from "callscript";
globalThis.Buffer = undefined;
evalExpr('Base64.encode("hi")', {});
// TypeError: Cannot read properties of undefined (reading 'from')
const engine = callscript({
tools: [
tool({
name: "demo.echo",
execute: async () => ({ ok: true }),
}),
],
});
const result = await engine.run({
script: {
steps: [
{
id: "result",
call: "demo.echo",
args: {},
},
],
},
});
console.log(result.status);
// "error"The execution error is caused by attempting to call Buffer.byteLength.
Expected behavior
Core functionality should work in edge and browser-like runtimes without requiring a Buffer polyfill.
Base64 helpers should also preserve their current behavior, including Unicode and Base64URL support.
Proposed fix
Replace the affected Buffer usages with dependency-free, web-standard UTF-8 and Base64 utilities, and add regression tests that run with Buffer unavailable.
Activity
0No activity yet.