Skip to content

Commit 0a5124e

Browse files
fix(server): standalone CLI builds again with Cursor usage (#71)
Upstream's Cursor usage reader (pingdotgg#10409) loads @napi-rs/keyring with a dynamic import(). A Node single executable can only import built-ins, so the release's build-exe check rejects the bundle. Load it through createRequire like node-pty and fff-node. Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 563c178 commit 0a5124e

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎apps/server/src/provider/cursorCredentialStore.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import * as NodeModule from "node:module";
2+
13
const CACHE_MS = 5 * 60_000;
24

35
/** Share one Keychain request across usage history and limits in this server process. */
@@ -22,8 +24,12 @@ export function makeCachedCursorAccessTokenReader(
2224
};
2325
}
2426

27+
// `import()` cannot load file-backed packages inside the single-executable CLI;
28+
// `require` reads the real filesystem.
29+
const requireForKeyring = NodeModule.createRequire(import.meta.url);
30+
2531
/** Read the Cursor CLI's default macOS credential without invoking the shared security binary. */
2632
export const readMacCursorAccessToken = makeCachedCursorAccessTokenReader(async () => {
27-
const { AsyncEntry } = await import("@napi-rs/keyring");
33+
const { AsyncEntry } = requireForKeyring("@napi-rs/keyring") as typeof import("@napi-rs/keyring");
2834
return (await new AsyncEntry("cursor-access-token", "cursor-user").getPassword()) ?? null;
2935
});

0 commit comments

Comments
 (0)