Skip to content

The open-source app everyone uses to manage agents at work

fix: stabilize paperclipai run server import errors

Dotta3ae9d9535433
diff --git a/cli/src/commands/run.ts b/cli/src/commands/run.ts
index 6d6ccae231..6e061b2e22 100644
--- a/cli/src/commands/run.ts
+++ b/cli/src/commands/run.ts
@@ -84,6 +84,15 @@ function isModuleNotFoundError(err: unknown): boolean {
return err.message.includes("Cannot find module");
}
+function getMissingModuleSpecifier(err: unknown): string | null {
+ if (!(err instanceof Error)) return null;
+ const packageMatch = err.message.match(/Cannot find package '([^']+)' imported from/);
+ if (packageMatch?.[1]) return packageMatch[1];
+ const moduleMatch = err.message.match(/Cannot find module '([^']+)'/);
+ if (moduleMatch?.[1]) return moduleMatch[1];
+ return null;
+}
+
function maybeEnableUiDevMiddleware(entrypoint: string): void {
if (process.env.PAPERCLIP_UI_DEV_MIDDLEWARE !== undefined) return;
const normalized = entrypoint.replaceAll("\\", "/");
@@ -106,7 +115,9 @@ async function importServerEntry(): Promise<void> {
try {
await import("@paperclipai/server");
} catch (err) {
- if (isModuleNotFoundError(err)) {
+ const missingSpecifier = getMissingModuleSpecifier(err);
+ const missingServerEntrypoint = !missingSpecifier || missingSpecifier === "@paperclipai/server";
+ if (isModuleNotFoundError(err) && missingServerEntrypoint) {
throw new Error(
`Could not locate a Paperclip server entrypoint.\n` +
`Tried: ${devEntry}, @paperclipai/server\n` +
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 304bb69186..f04df9b8d3 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -174,7 +174,7 @@ importers:
specifier: workspace:*
version: link:../packages/shared
better-auth:
- specifier: ^1.3.8
+ specifier: 1.4.18
detect-port:
specifier: ^2.1.0
diff --git a/server/package.json b/server/package.json
index df87aca2f1..6e3bfd3c9f 100644
--- a/server/package.json
+++ b/server/package.json
@@ -37,7 +37,7 @@
"@paperclipai/adapter-utils": "workspace:*",
"@paperclipai/db": "workspace:*",
"@paperclipai/shared": "workspace:*",
- "better-auth": "^1.3.8",
+ "better-auth": "1.4.18",
"detect-port": "^2.1.0",
"dotenv": "^17.0.1",
"drizzle-orm": "^0.38.4",