Skip to content

feat(mount): resolve relayfile-mount from @relayfile/mount-* optional package, drop postinstall download#184

Merged
khaliqgant merged 1 commit into
mainfrom
feat/mount-optional-dep-no-postinstall
Jun 9, 2026
Merged

feat(mount): resolve relayfile-mount from @relayfile/mount-* optional package, drop postinstall download#184
khaliqgant merged 1 commit into
mainfrom
feat/mount-optional-dep-no-postinstall

Conversation

@khaliqgant

Copy link
Copy Markdown
Member

Summary

Changes how the relayfile-mount binary is acquired: instead of a postinstall download, it now resolves from the @relayfile/mount-* optional dependency of @relayfile/sdk (activates once the SDK + platform mount-* packages are published), with the bundled bin/relayfile-mount / adjacent dist as fallback.

  • package.json: drop the postinstall mount download
  • relayfile-mount-launcher.ts (+ test): resolve the binary from the optional @relayfile/mount-* package, fall back to the bundled binary
  • electron-builder.yml: package the resolved binary

Notes

  • Until the SDK + @relayfile/mount-* packages are published, a fresh npm i may not provide the optional binary — the bundled bin/relayfile-mount fallback covers local/dev. Integration remote reads (SDK joinWorkspace) do not depend on the local mount binary.

🤖 Generated with Claude Code

… package, drop postinstall download

Will's feedback: `npm i` ran a postinstall that downloaded the Go relayfile-mount
binary from GitHub Releases, instead of it being a normal bundled dependency like
the Rust broker.

Switch to the broker distribution model: the binary now arrives via
@relayfile/sdk's optionalDependencies (@relayfile/mount-<platform>-<arch>) and is
bundled into the app from node_modules.

- Remove the postinstall hook and unwire install-relayfile-mount from
  build/dist:mac/release:mac (kept relayfile-mount:install* as a manual escape
  hatch for pre-publish dev).
- resolveRelayfileMountBinary now checks the per-platform optional package
  (top-level and SDK-nested), then the existing dev/source fallbacks.
- electron-builder asarUnpacks node_modules/@relayfile/mount-*/bin/** so the
  binary is spawnable from the packaged app.
- Update the launcher-import test to assert the new contract (no postinstall, no
  download in the release path, optional-package resolution + asarUnpack).

Activates once the SDK + mount-* packages are published and pear's @relayfile/sdk
dep is bumped to that version.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codeant-ai

codeant-ai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Your free trial PR review limit of 300 PRs has been reached. Please upgrade your plan to continue using CodeAnt AI.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@khaliqgant, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 59 minutes and 48 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c780dfda-b6b9-4c34-a440-8cb53892bd9e

📥 Commits

Reviewing files that changed from the base of the PR and between 901d508 and dc80afb.

📒 Files selected for processing (4)
  • electron-builder.yml
  • package.json
  • src/main/__tests__/relayfile-mount-launcher-import.test.ts
  • src/main/relayfile-mount-launcher.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/mount-optional-dep-no-postinstall

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@agent-relay-code

Copy link
Copy Markdown
Contributor

pr-reviewer could not complete review for #184 in AgentWorkforce/pear.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request transitions the distribution of the relayfile-mount binary from a postinstall download script to a per-platform optional package (@relayfile/mount--) installed transitively via @relayfile/sdk. It updates electron-builder.yml to unpack these binaries, removes the download scripts from package.json, updates the launcher to resolve the binary from node_modules, and updates the test suite accordingly. Feedback on these changes highlights that the fallback candidate paths in resolveRelayfileMountBinary still hardcode 'relayfile-mount' without the .exe extension on Windows, which will cause resolution to fail when falling back to development or packaged paths.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +28 to +68
// Locate the relayfile-mount binary shipped as the per-platform optional
// package (@relayfile/mount-<platform>-<arch>), installed transitively via
// @relayfile/sdk's optionalDependencies — the same distribution model as the
// agent-relay broker (see resolveBundledBrokerBinary in broker.ts). The SDK
// itself resolves this via import.meta.url, but that points at out/main/ once
// electron-vite bundles the main process, so we resolve from __dirname instead.
function optionalPackageMountBinaries(): string[] {
const pkgArch = `${process.platform}-${process.arch}`
const binName = process.platform === 'win32' ? 'relayfile-mount.exe' : 'relayfile-mount'
const unpackIfPackaged = (binary: string): string =>
app.isPackaged ? binary.replace('app.asar', 'app.asar.unpacked') : binary
// __dirname is out/main; ../../ reaches the app root that holds node_modules.
const nodeModules = join(__dirname, '..', '..', 'node_modules')
return [
// Hoisted to the app's top-level node_modules (the common case).
join(nodeModules, '@relayfile', `mount-${pkgArch}`, 'bin', binName),
// Nested under @relayfile/sdk when npm can't hoist it.
join(nodeModules, '@relayfile', 'sdk', 'node_modules', '@relayfile', `mount-${pkgArch}`, 'bin', binName)
].map(unpackIfPackaged)
}

export function resolveRelayfileMountBinary(): string | null {
if (canExecute(process.env.RELAYFILE_MOUNT_BIN)) return resolve(process.env.RELAYFILE_MOUNT_BIN)

const appPath = app.getAppPath()
const candidates = app.isPackaged
? [
join(process.resourcesPath, 'bin', 'relayfile-mount'),
join(appPath.replace('app.asar', 'app.asar.unpacked'), 'bin', 'relayfile-mount')
]
: [
join(appPath, 'bin', 'relayfile-mount'),
join(process.cwd(), 'bin', 'relayfile-mount'),
join(appPath, '..', 'relayfile', 'dist', `relayfile-mount-${archSuffix()}`),
join(process.cwd(), '..', 'relayfile', 'dist', `relayfile-mount-${archSuffix()}`)
]
const candidates = [
// Primary production path: the per-platform optional-dependency package.
...optionalPackageMountBinaries(),
// Development / source-checkout fallbacks.
...(app.isPackaged
? [
join(process.resourcesPath, 'bin', 'relayfile-mount'),
join(appPath.replace('app.asar', 'app.asar.unpacked'), 'bin', 'relayfile-mount')
]
: [
join(appPath, 'bin', 'relayfile-mount'),
join(process.cwd(), 'bin', 'relayfile-mount'),
join(appPath, '..', 'relayfile', 'dist', `relayfile-mount-${archSuffix()}`),
join(process.cwd(), '..', 'relayfile', 'dist', `relayfile-mount-${archSuffix()}`)
])
]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

On Windows, executable binaries require the .exe extension to be correctly resolved and executed. While optionalPackageMountBinaries correctly appends .exe on Windows, the fallback candidate paths in resolveRelayfileMountBinary still hardcode 'relayfile-mount' without the extension. This will cause resolution to fail on Windows when falling back to development or packaged paths.

Extracting the binary name to a shared constant BIN_NAME and using it across all candidate paths (including appending .exe to the local dist build suffix on Windows) ensures consistent and correct resolution on Windows.

// Locate the relayfile-mount binary shipped as the per-platform optional
// package (@relayfile/mount-<platform>-<arch>), installed transitively via
// @relayfile/sdk's optionalDependencies — the same distribution model as the
// agent-relay broker (see resolveBundledBrokerBinary in broker.ts). The SDK
// itself resolves this via import.meta.url, but that points at out/main/ once
// electron-vite bundles the main process, so we resolve from __dirname instead.
const BIN_NAME = process.platform === 'win32' ? 'relayfile-mount.exe' : 'relayfile-mount'

function optionalPackageMountBinaries(): string[] {
  const pkgArch = process.platform + '-' + process.arch
  const unpackIfPackaged = (binary: string): string =>
    app.isPackaged ? binary.replace('app.asar', 'app.asar.unpacked') : binary
  // __dirname is out/main; ../../ reaches the app root that holds node_modules.
  const nodeModules = join(__dirname, '..', '..', 'node_modules')
  return [
    // Hoisted to the app's top-level node_modules (the common case).
    join(nodeModules, '@relayfile', 'mount-' + pkgArch, 'bin', BIN_NAME),
    // Nested under @relayfile/sdk when npm can't hoist it.
    join(nodeModules, '@relayfile', 'sdk', 'node_modules', '@relayfile', 'mount-' + pkgArch, 'bin', BIN_NAME)
  ].map(unpackIfPackaged)
}

export function resolveRelayfileMountBinary(): string | null {
  if (canExecute(process.env.RELAYFILE_MOUNT_BIN)) return resolve(process.env.RELAYFILE_MOUNT_BIN)

  const appPath = app.getAppPath()
  const candidates = [
    // Primary production path: the per-platform optional-dependency package.
    ...optionalPackageMountBinaries(),
    // Development / source-checkout fallbacks.
    ...(app.isPackaged
      ? [
          join(process.resourcesPath, 'bin', BIN_NAME),
          join(appPath.replace('app.asar', 'app.asar.unpacked'), 'bin', BIN_NAME)
        ]
      : [
          join(appPath, 'bin', BIN_NAME),
          join(process.cwd(), 'bin', BIN_NAME),
          join(appPath, '..', 'relayfile', 'dist', 'relayfile-mount-' + archSuffix() + (process.platform === 'win32' ? '.exe' : '')),
          join(process.cwd(), '..', 'relayfile', 'dist', 'relayfile-mount-' + archSuffix() + (process.platform === 'win32' ? '.exe' : ''))
        ])
  ]

@agent-relay-code

Copy link
Copy Markdown
Contributor

ℹ️ pr-reviewer: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed.

pr-reviewer could not complete review for #184 in AgentWorkforce/pear.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@agent-relay-code

Copy link
Copy Markdown
Contributor

pr-reviewer could not complete review for #184 in AgentWorkforce/pear.
The review harness exited with code 1.
No review was posted; this needs operator attention.

1 similar comment
@agent-relay-code

Copy link
Copy Markdown
Contributor

pr-reviewer could not complete review for #184 in AgentWorkforce/pear.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@agent-relay-code

Copy link
Copy Markdown
Contributor

ℹ️ pr-reviewer: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed.

pr-reviewer could not complete review for #184 in AgentWorkforce/pear.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@agent-relay-code

Copy link
Copy Markdown
Contributor

pr-reviewer could not complete review for #184 in AgentWorkforce/pear.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@agent-relay-code

Copy link
Copy Markdown
Contributor

ℹ️ pr-reviewer: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed.

pr-reviewer could not complete review for #184 in AgentWorkforce/pear.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@agent-relay-code

Copy link
Copy Markdown
Contributor

pr-reviewer could not complete review for #184 in AgentWorkforce/pear.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@agent-relay-code

Copy link
Copy Markdown
Contributor

ℹ️ pr-reviewer: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed.

pr-reviewer could not complete review for #184 in AgentWorkforce/pear.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@khaliqgant khaliqgant merged commit bc7ce7f into main Jun 9, 2026
4 checks passed
@khaliqgant khaliqgant deleted the feat/mount-optional-dep-no-postinstall branch June 9, 2026 14:25
khaliqgant added a commit that referenced this pull request Jun 9, 2026
…ount-optional-dep (#190)

@relayfile/sdk@0.8.20 declares the @relayfile/mount-{darwin,linux}-{arm64,x64}@0.8.20 optional deps, so relocking pulls the platform mount binary as an npm optional package (no postinstall download) — activating the #184 launcher resolution (relayfile-mount-launcher.ts). All four mount-*@0.8.20 verified published on npm.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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