Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

build: fetch the engine from this repo's release

ogsamrat4b0bf4fc2406
diff --git a/.github/actions/setup-tests/action.yml b/.github/actions/setup-tests/action.yml
index 12f76433..93e0cedb 100644
--- a/.github/actions/setup-tests/action.yml
+++ b/.github/actions/setup-tests/action.yml
@@ -13,10 +13,9 @@ runs:
with:
version: 11.4.0
- # The engine is OmniRush.ai's build of opencode 1.18.32, on a private
- # release of omnirush-ai/omnirush-cli (sha256-pinned in
- # apps/desktop/scripts/engine-release.json). The calling job passes a token
- # that can read it as OMNIRUSH_ENGINE_TOKEN.
+ # The engine is OmniRush.ai's build of opencode 1.18.32, on this repo's
+ # public engine pre-release (sha256-pinned in
+ # apps/desktop/scripts/engine-release.json).
- name: Install OpenCode CLI
shell: bash
run: |
diff --git a/.github/workflows/build-electron-desktop.yml b/.github/workflows/build-electron-desktop.yml
index 298196f0..abe2e889 100644
--- a/.github/workflows/build-electron-desktop.yml
+++ b/.github/workflows/build-electron-desktop.yml
@@ -14,11 +14,6 @@ on:
- package.json
- .github/workflows/build-electron-desktop.yml
-# The bundled engine is fetched from a private release of omnirush-ai/omnirush-cli
-# (apps/desktop/scripts/prepare-sidecar.mjs): this repo's own token cannot read it.
-env:
- OMNIRUSH_ENGINE_TOKEN: ${{ secrets.OMNIRUSH_ENGINE_TOKEN }}
-
permissions:
contents: read
diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml
index b86d3477..1d7416db 100644
--- a/.github/workflows/ci-tests.yml
+++ b/.github/workflows/ci-tests.yml
@@ -17,10 +17,6 @@ concurrency:
group: omnirush-tests-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
-# The bundled engine is fetched from a private release of omnirush-ai/omnirush-cli
-# (apps/desktop/scripts/prepare-sidecar.mjs): this repo's own token cannot read it.
-env:
- OMNIRUSH_ENGINE_TOKEN: ${{ secrets.OMNIRUSH_ENGINE_TOKEN }}
permissions:
contents: read
diff --git a/.github/workflows/daytona-e2e.yml b/.github/workflows/daytona-e2e.yml
index 5b9434eb..d85a3aec 100644
--- a/.github/workflows/daytona-e2e.yml
+++ b/.github/workflows/daytona-e2e.yml
@@ -20,11 +20,6 @@ on:
workflows: [Warden]
types: [completed]
-# The bundled engine is fetched from a private release of omnirush-ai/omnirush-cli
-# (apps/desktop/scripts/prepare-sidecar.mjs): this repo's own token cannot read it.
-env:
- OMNIRUSH_ENGINE_TOKEN: ${{ secrets.OMNIRUSH_ENGINE_TOKEN }}
-
permissions:
actions: read
contents: read
diff --git a/.github/workflows/linux-packages.yml b/.github/workflows/linux-packages.yml
index 071a5080..bb85be1d 100644
--- a/.github/workflows/linux-packages.yml
+++ b/.github/workflows/linux-packages.yml
@@ -17,11 +17,6 @@ on:
- .github/workflows/release-desktop.yml
- .github/workflows/linux-packages.yml
-# The bundled engine is fetched from a private release of omnirush-ai/omnirush-cli
-# (apps/desktop/scripts/prepare-sidecar.mjs): this repo's own token cannot read it.
-env:
- OMNIRUSH_ENGINE_TOKEN: ${{ secrets.OMNIRUSH_ENGINE_TOKEN }}
-
permissions:
contents: read
diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.yml
index a9b9e4e5..abfa6e72 100644
--- a/.github/workflows/release-desktop.yml
+++ b/.github/workflows/release-desktop.yml
@@ -11,11 +11,6 @@ on:
required: true
type: string
-# The bundled engine is fetched from a private release of omnirush-ai/omnirush-cli
-# (apps/desktop/scripts/prepare-sidecar.mjs): this repo's own token cannot read it.
-env:
- OMNIRUSH_ENGINE_TOKEN: ${{ secrets.OMNIRUSH_ENGINE_TOKEN }}
-
permissions:
contents: write
diff --git a/apps/desktop/electron/runtime.test.mjs b/apps/desktop/electron/runtime.test.mjs
index d1b99a6c..97387b2f 100644
--- a/apps/desktop/electron/runtime.test.mjs
+++ b/apps/desktop/electron/runtime.test.mjs
@@ -100,7 +100,8 @@ describe("bundled OpenCode runtime", () => {
// bundled from 2.2.0 is gone (its sessions are imported, engine2/import.ts).
assert.equal(constants.opencodeVersion, "v1.18.32");
assert.equal(release.version, "1.18.32");
- assert.equal(release.repo, "omnirush-ai/omnirush-cli");
+ // A public pre-release of this repo, never marked latest: no token needed.
+ assert.equal(release.repo, "omnirush-ai/omnirush-gui");
assert.equal(release.tag, "engine-1.18.32-r2");
for (const target of ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu"]) {
assert.match(release.assets[target].name, /^omnirush-engine-[a-z0-9-]+-1\.18\.32\.tar\.gz$/);
diff --git a/apps/desktop/scripts/engine-release.json b/apps/desktop/scripts/engine-release.json
index b5adba6a..9d8b8467 100644
--- a/apps/desktop/scripts/engine-release.json
+++ b/apps/desktop/scripts/engine-release.json
@@ -1,7 +1,8 @@
{
- "repo": "omnirush-ai/omnirush-cli",
+ "repo": "omnirush-ai/omnirush-gui",
"tag": "engine-1.18.32-r2",
"version": "1.18.32",
+ "origin": "The same archives as release engine-1.18.32-r2 of omnirush-ai/omnirush-cli (the CLI's engine), copied to a public pre-release of this repo that is never marked latest.",
"license": {
"name": "LICENSE-opencode-MIT",
"sha256": "625f0f619133f89bbbb2abe37369613dfa1885eba1e50d02170deb62bb42cb6b"
diff --git a/apps/desktop/scripts/prepare-sidecar.mjs b/apps/desktop/scripts/prepare-sidecar.mjs
index 4829c533..98937466 100644
--- a/apps/desktop/scripts/prepare-sidecar.mjs
+++ b/apps/desktop/scripts/prepare-sidecar.mjs
@@ -50,9 +50,9 @@ const normalizeVersion = (value) => {
};
// The engine is OmniRush.ai's build of opencode 1.18.32 (the one the CLI
-// bundles), published as per-platform tarballs on a private GitHub release of
-// the CLI repo and sha256-pinned in engine-release.json. Each tarball holds one
-// executable, `opencode[.exe]`, at its root.
+// bundles): per-platform tarballs on a public pre-release of this repo (never
+// marked latest), sha256-pinned in engine-release.json. No token is needed.
+// Each tarball holds one executable, `opencode[.exe]`, at its root.
const engineReleasePath = resolve(__dirname, "engine-release.json");
const engineRelease = JSON.parse(readFileSync(engineReleasePath, "utf8"));
@@ -253,31 +253,24 @@ if (!shouldDownloadOpencode) {
console.log(`OpenCode sidecar already present (${existingOpencodeVersion}, ${engineRelease.tag}).`);
}
-/** A token that can read the private engine release (never printed). */
-const githubToken = () => {
- for (const name of ["OMNIRUSH_ENGINE_TOKEN", "GH_TOKEN", "GITHUB_TOKEN"]) {
- const value = process.env[name]?.trim();
- if (value) return value;
+/** A public release asset's bytes, with a few tries (GitHub's download hosts answer 5xx now and then). */
+const download = async (url) => {
+ let last = null;
+ for (let attempt = 1; attempt <= 4; attempt++) {
+ try {
+ const response = await fetch(url, { headers: { "user-agent": "omnirush-desktop-prepare-sidecar" }, redirect: "follow" });
+ if (response.ok) return Buffer.from(await response.arrayBuffer());
+ last = new Error(`GitHub answered ${response.status} for ${url}`);
+ if (response.status < 500 && response.status !== 429) break;
+ } catch (error) {
+ last = error;
+ }
+ await new Promise((done) => setTimeout(done, 2_000 * attempt));
}
- const gh = spawnSync("gh", ["auth", "token"], { encoding: "utf8" });
- return gh.status === 0 ? gh.stdout.trim() || null : null;
+ throw last ?? new Error(`Download of ${url} failed`);
};
-const githubApi = async (url, accept, token) => {
- const response = await fetch(url, {
- headers: {
- accept,
- authorization: `Bearer ${token}`,
- "user-agent": "omnirush-desktop-prepare-sidecar",
- "x-github-api-version": "2022-11-28",
- },
- redirect: "follow",
- });
- if (!response.ok) throw new Error(`GitHub answered ${response.status} for ${url}`);
- return response;
-};
-
-/** The pinned archive's bytes: a local copy (OMNIRUSH_ENGINE_ARCHIVE), the cache, or the release. */
+/** The pinned archive's bytes: a local copy (OMNIRUSH_ENGINE_ARCHIVE), the cache, or the public release. */
const readEngineArchive = async () => {
const verify = (bytes, source) => {
const actual = createHash("sha256").update(bytes).digest("hex");
@@ -299,21 +292,8 @@ const readEngineArchive = async () => {
console.warn(`${error instanceof Error ? error.message : String(error)}; downloading it again.`);
}
}
- const token = githubToken();
- if (!token) {
- throw new Error(
- `A GitHub token that can read ${engineRelease.repo} is required to fetch the engine from its private release ${engineRelease.tag}: ` +
- "set OMNIRUSH_ENGINE_TOKEN (or GH_TOKEN / GITHUB_TOKEN), sign in with `gh auth login`, or point OMNIRUSH_ENGINE_ARCHIVE at the archive.",
- );
- }
- const release = await (await githubApi(
- `https://api.github.com/repos/${engineRelease.repo}/releases/tags/${engineRelease.tag}`,
- "application/vnd.github+json",
- token,
- )).json();
- const asset = (release.assets ?? []).find((entry) => entry.name === engineAsset.name);
- if (!asset) throw new Error(`${engineAsset.name} is not an asset of ${engineRelease.repo} release ${engineRelease.tag}`);
- const bytes = verify(Buffer.from(await (await githubApi(asset.url, "application/octet-stream", token)).arrayBuffer()), asset.url);
+ const url = `https://github.com/${engineRelease.repo}/releases/download/${engineRelease.tag}/${engineAsset.name}`;
+ const bytes = verify(await download(url), url);
try {
mkdirSync(dirname(cached), { recursive: true });
writeFileSync(cached, bytes);