Skip to content

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

Description

@NathanFlurry

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions