vercel-labs / vercel-labs/callscript

Core runtime depends on Node Buffer despite documented edge portability

Open
#14 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
86
Forks
5
Avg merge
28m
Merged PRs (30d)
9

Description

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 helpers
  • packages/callscript/src/execute.ts — tool-result byte measurement
  • packages/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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the affected Buffer usages in packages/callscript/src/expr/eval.ts, packages/callscript/src/execute.ts, and packages/callscript/src/runner.ts, then reproduce the issue with globalThis.Buffer unavailable. Replace those usages with dependency-free web-standard utilities, add regression tests, and verify Base64, Base64URL, Unicode, and ordinary tool-result execution still work without Buffer.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.