Skip to content

agent-bundle/meta throws at import outside the compiler, making any source module that uses it un-importable from unit tests (agentBundleRstest does not alias it) #386

Description

@ScriptedAlchemy

What happened

Following the framework-mode guidance ("plugin source imports agent-bundle/meta instead of maintaining a hand-written src/lib/version.ts"), cargo-hauler moved its daemon version constant to:

import { version } from 'agent-bundle/meta';

in src/daemon/main.ts. Outside a compiled surface, node_modules/agent-bundle/dist/meta.js initializes every binding through throwUnavailableEntrypoint(), so importing the module throws at evaluation:

agent-bundle/meta is available only inside a surface Agent Bundle compiles; a plugin module reached it outside the compiler.

Consequences:

  • Every plain rstest unit test that imports the daemon (directly or transitively: tests/harness.ts, lifecycle, ensure-daemon, broker, query, …) fails at import.
  • The framework's own agentBundleRstest() route-unit preset does not alias it either. renderRoute('tool:hauler/hauler_status') and invokeCli(['daemon','status']) both fail with the same error as soon as the route reaches the daemon module (error load file dist/.rstest-temp/src_daemon_main_ts-effect_Schedule.mjs failed).

Workaround in use

A package.json-backed stand-in plus an alias in both rstest configs:

// tests/fixtures/agent-bundle-meta.ts
import type { AgentBundleMeta } from 'agent-bundle/meta';
import pkg from '../../package.json' with { type: 'json' };
export const version: AgentBundleMeta['version'] = pkg.version;
// ...

// rstest.config.ts and rstest.route-unit.config.ts
resolve: { alias: { 'agent-bundle/meta': fileURLToPath(new URL('./tests/fixtures/agent-bundle-meta.ts', import.meta.url)) } }

Ask

Either of:

  1. A non-throwing development fallback for agent-bundle/meta that reads the nearest package.json when no compiled surface replaced the module (the value is knowable; only the compile-time inlining is not), or
  2. agentBundleRstest() (and agent-bundle/test) aliasing agent-bundle/meta to such a fallback automatically, with the docs blurb updated to say how unit tests are expected to load a module that imports it.

Pin: agent-bundle@105c65d8f (pkg.pr.new), @rstest/core@0.11.11.

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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions