rivet-dev / rivet-dev/agentos

Inline JavaScript resolves dynamic import() from / instead of the working directory

Open
#1,990 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
4.6k
Forks
251
Avg merge
2d 15h
Merged PRs (30d)
34

Description

Inline execute / evaluate code cannot import a package installed in the VM's working directory.

Repro

const vm = await AgentOs.create({ permissions: { network: "allow" } });
await vm.javascript.npm.install(["zod"]);            // installs to /workspace/node_modules
await vm.javascript.evaluate(`import("zod").then(() => "ok")`);

Actual
Cannot resolve module 'zod' (imported from '/[agentos-evaluation.js]'). The inline importer path is /[agentos-evaluation.js], /[agentos-inline.js], or /<entry>.js, so resolution starts at /. TypeScript static imports (rewritten to require) do resolve, so the two paths disagree.

Expected
Match node -e: inline code resolves bare specifiers from the working directory.

Workaround
Pass filePath: "/workspace/main.mjs", or run a file with executeFile.

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 tracing the javascript.evaluate and execute inline-code entry points, then compare dynamic import resolution with static imports and executeFile. Reproduce the issue with a package installed in /workspace; done means bare imports resolve from the working directory like node -e, without requiring filePath.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.