Skip to content

fix: add prepare script for git dependency installs#2

Merged
mattapperson merged 5 commits intomainfrom
add-prepare-script
Apr 1, 2026
Merged

fix: add prepare script for git dependency installs#2
mattapperson merged 5 commits intomainfrom
add-prepare-script

Conversation

@mattapperson
Copy link
Copy Markdown
Collaborator

Summary

  • Add "prepare": "npm run build" to scripts

When this package is installed from a git URL (e.g. by the monorepo via git+https://github.com/OpenRouterTeam/typescript-agent.git#main), pnpm runs the prepare lifecycle script. Without it, tsc never runs and the build artifacts referenced by the exports map are missing, causing Cannot find package '@openrouter/agent/tool' errors.

Test plan

  • pnpm add @openrouter/agent@git+https://github.com/OpenRouterTeam/typescript-agent.git#add-prepare-script resolves subpath exports

When this package is installed from a git URL (e.g. by the monorepo),
pnpm runs the prepare lifecycle script. Without it, tsc never runs
and the esm/ build artifacts referenced by the exports map are missing.
The agent uses types (ResponsesRequest, InputsUnion, etc.) that exist
in the SDK repo's main branch but aren't in the npm-published 0.10.2.
Point to git URL so the prepare script can build successfully.
The lockfile was out of sync with the git URL for @openrouter/sdk.
Also add pnpm.onlyBuiltDependencies so the SDK's prepare script
runs during install.
The monorepo's vitest config uses a "source" export condition that
resolves to ./src/*.ts files. Without src/ in the files field,
pnpm pack excludes it from the installed package, causing
"Cannot find package" errors in vitest tests.
The "source" export condition points to TypeScript source files,
which causes resolution issues when the agent is installed as a
git dependency. The compiled esm/ output is sufficient for consumers.
This avoids nested dependency resolution failures where the agent's
source files try to import @openrouter/sdk subpaths.
@mattapperson mattapperson merged commit 6bf5bb8 into main Apr 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant