Building & Distribution
Relevant source files
The following files were used as context for generating this wiki page:
The Building & Distribution system for Agent Cowork facilitates the transformation of source code into production-ready desktop applications for macOS, Windows, and Linux. The project utilizes a dual-build process involving Vite for the React frontend and TypeScript (tsc) for the Electron main process, coordinated through electron-builder for final packaging.
Sources: README.md:89-94, package.json:11-16
Build Lifecycle
The build process is divided into three primary phases: transpilation of the Electron main process, building the React frontend, and packaging the application into platform-specific binaries.
Compilation Sequence
To ensure the application functions correctly, the Electron main process must be transpiled from TypeScript to JavaScript, and the React frontend must be bundled. These steps are prerequisite to the distribution phase.
Key Build Scripts
The project defines several scripts in package.json to handle different build requirements:
| Script | Purpose | Command |
|---|---|---|
transpile:electron | Compiles Electron TypeScript code | tsc --project src/electron/tsconfig.json |
build | Full application compilation | tsc -b && vite build |
rebuild | Force rebuilds native modules | npx electron-rebuild -f -w better-sqlite3 |
dist:mac-arm64 | Build for Apple Silicon | bun run transpile:electron && bun run build && electron-builder --mac --arm64 |
dist:win | Build for Windows x64 | bun run transpile:electron && bun run build && electron-builder --win --x64 |
Sources: package.json:7-16
Configuration Management
Electron Builder Configuration
The electron-builder.json file defines the structure of the final distribution package, including file inclusions, resource management, and platform-specific targets.
Sources: electron-builder.json:1-26
Resource Resolution
The application uses a pathResolver to distinguish between development and production file paths. This ensures that assets like the preload script and the UI entry point are correctly located regardless of the execution environment.
export function getPreloadPath() {
return path.join(
app.getAppPath(),
isDev() ? './' : '../',
'/dist-electron/preload.cjs'
)
}
Sources: src/electron/pathResolver.ts:5-11
Distribution Targets
The project supports three major operating systems with specific packaging formats defined in the builder configuration.
| Platform | Target Format | Architecture | Configuration Detail |
|---|---|---|---|
| macOS | dmg | arm64 / x64 | Built via electron-builder --mac |
| Windows | portable | x64 | Single executable, no installation required |
| Linux | AppImage | x64 | Category: Utility |
Sources: electron-builder.json:15-25, package.json:13-16
Dependency Packaging (ASAR)
A critical aspect of the distribution is the treatment of the @anthropic-ai/claude-agent-sdk. Due to its nature as a CLI-based SDK, it is specifically excluded from the ASAR archive to allow the OS to execute its internal cli.js file directly.
"asarUnpack": [
"node_modules/@anthropic-ai/claude-agent-sdk/**/*"
]
Sources: electron-builder.json:11-13, src/electron/libs/claude-settings.ts:8-16
Environment-Specific Logic
The build system accounts for differences between the development environment and the packaged application, particularly regarding the path to the Claude Code CLI.
Summary
The "Building & Distribution" system ensures that Agent Cowork can be reliably compiled and packaged for multiple platforms. By combining TypeScript transpilation, Vite bundling, and platform-specific configuration via electron-builder, the project maintains a consistent delivery pipeline for its desktop AI assistant.