Skip to content

SDK embed requires package-adjacent package.json at runtime #5226

@mattiacerutti

Description

@mattiacerutti

What happened?

Related to #5108.

When embedding @earendil-works/pi-coding-agent into a bundled Node app, Pi reads package-adjacent metadata at runtime via getPackageDir() / getPackageJsonPath().

If the app bundles Pi into another entrypoint, Pi can try to read a package.json next to that bundled entrypoint, for example:

dist/package.json

If that file is not present, startup fails with:

ENOENT: no such file or directory, open '.../dist/package.json'

Steps to reproduce

  1. Bundle an app that imports @earendil-works/pi-coding-agent:
bun build src/file.ts --target node --outdir dist
  1. Run the bundled entrypoint from a directory without package.json next to or above it.

  2. Observe startup failing when Pi reads getPackageJsonPath().

Expected behavior

SDK embedding should not require package-adjacent files at import/startup time, or Pi should expose/document an explicit embedding configuration for package metadata and asset paths.

Version

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinginprogressIssue is being worked on

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions