GeezerVison is showing github.com — feat(openwrk): download sidecars on demand (#387) · bussard76/openwork@120c106
File treeExpand file treeCollapse file tree Open diff view settings .opencode/skills/openwrk-npm-publish
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .opencode/skills/openwrk-npm-publish/SKILL.md +13-2Lines changed: 13 additions & 2 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -14,13 +14,23 @@ description: | | 14 | 14 | 1. Ensure you are on the default branch and the tree is clean. | 15 | 15 | 2. Bump the version in `packages/headless/package.json`. | 16 | 16 | 3. Commit the bump. | 17 | | -4. Publish the package. | | 17 | +4. Build sidecar artifacts and publish them to a release tag. | | 18 | + | | 19 | +```bash | | 20 | +pnpm --filter openwrk build:sidecars | | 21 | +gh release create openwrk-vX.Y.Z packages/headless/dist/sidecars/* \ | | 22 | + --repo different-ai/openwork \ | | 23 | + --title "openwrk vX.Y.Z sidecars" \ | | 24 | + --notes "Sidecar binaries and manifest for openwrk vX.Y.Z" | | 25 | +``` | | 26 | + | | 27 | +5. Publish the package. | 18 | 28 |
| 19 | 29 | ```bash | 20 | 30 | pnpm --filter openwrk publish --access public | 21 | 31 | ``` | 22 | 32 |
| 23 | | -5. Verify the published version. | | 33 | +6. Verify the published version. | 24 | 34 |
| 25 | 35 | ```bash | 26 | 36 | npm view openwrk version | @@ -52,3 +62,4 @@ Alternatively, export an npm token in your environment (see `.env.example`). | 52 | 62 |
| 53 | 63 | - `pnpm publish` requires a clean git tree. | 54 | 64 | - This publish flow is separate from app release tags. | | 65 | +- openwrk downloads sidecars from `openwrk-vX.Y.Z` release assets by default. |
Collapse file Copy file name to clipboardExpand all lines: AGENTS.md +5-2Lines changed: 5 additions & 2 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -147,7 +147,10 @@ This is separate from app release tags. Use `.opencode/skills/openwrk-npm-publis | 147 | 147 | 1. Ensure the default branch is up to date and clean. | 148 | 148 | 2. Bump `packages/headless/package.json` (`version`). | 149 | 149 | 3. Commit the bump. | 150 | | -4. Publish: | | 150 | +4. Build and upload sidecar assets for the same version tag: | | 151 | + * `pnpm --filter openwrk build:sidecars` | | 152 | + * `gh release create openwrk-vX.Y.Z packages/headless/dist/sidecars/* --repo different-ai/openwork` | | 153 | +5. Publish: | 151 | 154 | * `pnpm --filter openwrk publish --access public` | 152 | | -5. Verify: | | 155 | +6. Verify: | 153 | 156 | * `npm view openwrk version` |
Collapse file Copy file name to clipboardExpand all lines: packages/headless/README.md +6-3Lines changed: 6 additions & 3 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -11,9 +11,12 @@ openwrk start --workspace /path/to/workspace --approval auto | 11 | 11 |
| 12 | 12 | `openwrk` ships as a compiled binary, so Bun is not required at runtime. | 13 | 13 |
| 14 | | -`openwrk` bundles and validates exact versions of `openwork-server` + `owpenbot` from the | 15 | | -monorepo using a SHA-256 manifest. It will refuse to start if the bundled binaries are missing | 16 | | -or tampered with. | | 14 | +`openwrk` downloads and caches the `openwork-server`, `owpenbot`, and `opencode` sidecars on | | 15 | +first run using a SHA-256 manifest. Use `--sidecar-dir` or `OPENWRK_SIDECAR_DIR` to control the | | 16 | +cache location, and `--sidecar-base-url` / `--sidecar-manifest` to point at a custom host. | | 17 | + | | 18 | +By default the manifest is fetched from | | 19 | +`https://github.com/different-ai/openwork/releases/download/openwrk-v<openwrk-version>/openwrk-sidecars.json`. | 17 | 20 |
| 18 | 21 | Owpenbot is optional. If it exits, `openwrk` continues running unless you pass | 19 | 22 | `--owpenbot-required` or set `OPENWRK_OWPENBOT_REQUIRED=1`. | |
Collapse file Copy file name to clipboardExpand all lines: packages/headless/package.json +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | "version": "0.1.11", | 4 | 4 | "description": "Headless OpenWork host orchestrator for OpenCode + OpenWork server + Owpenbot", | 5 | 5 | "type": "module", | | 6 | + "opencodeVersion": "1.1.45", | 6 | 7 | "bin": { | 7 | 8 | "openwrk": "dist/openwrk" | 8 | 9 | }, | 9 | 10 | "scripts": { | 10 | 11 | "dev": "bun src/cli.ts", | 11 | 12 | "build": "tsc -p tsconfig.json", | 12 | | - "build:bin": "node ../desktop/scripts/prepare-sidecar.mjs --outdir dist && bun build --compile src/cli.ts --outfile dist/openwrk", | | 13 | + "build:bin": "node scripts/clean-dist.mjs && bun build --compile src/cli.ts --outfile dist/openwrk", | | 14 | + "build:bin:bundled": "node scripts/clean-dist.mjs && node ../desktop/scripts/prepare-sidecar.mjs --outdir dist && bun build --compile src/cli.ts --outfile dist/openwrk && bun scripts/build-bin.ts", | | 15 | + "build:sidecars": "node scripts/build-sidecars.mjs", | 13 | 16 | "typecheck": "tsc -p tsconfig.json --noEmit", | 14 | 17 | "test:router": "pnpm build && node scripts/router.mjs", | 15 | 18 | "prepublishOnly": "pnpm build:bin" | 16 | 19 | }, | 17 | 20 | "files": [ | 18 | 21 | "dist", | 19 | | - "README.md", | 20 | | - "dist/openwork-server", | 21 | | - "dist/owpenbot", | 22 | | - "dist/versions.json" | | 22 | + "README.md" | 23 | 23 | ], | 24 | 24 | "repository": { | 25 | 25 | "type": "git", | |
Collapse file Copy file name to clipboard +96Lines changed: 96 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +import { spawnSync } from "node:child_process"; | | 2 | +import { createHash } from "node:crypto"; | | 3 | +import { copyFileSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs"; | | 4 | +import { basename, join, resolve } from "node:path"; | | 5 | +import { fileURLToPath } from "node:url"; | | 6 | + | | 7 | +const root = resolve(fileURLToPath(new URL("..", import.meta.url))); | | 8 | +const repoRoot = resolve(root, "..", ".."); | | 9 | +const outdir = resolve(root, "dist", "sidecars"); | | 10 | + | | 11 | +const openwrkPkg = JSON.parse(readFileSync(resolve(root, "package.json"), "utf8")); | | 12 | +const openwrkVersion = String(openwrkPkg.version ?? "").trim(); | | 13 | +if (!openwrkVersion) { | | 14 | + throw new Error("openwrk version missing in packages/headless/package.json"); | | 15 | +} | | 16 | + | | 17 | +const serverPkg = JSON.parse(readFileSync(resolve(repoRoot, "packages", "server", "package.json"), "utf8")); | | 18 | +const serverVersion = String(serverPkg.version ?? "").trim(); | | 19 | +if (!serverVersion) { | | 20 | + throw new Error("openwork-server version missing in packages/server/package.json"); | | 21 | +} | | 22 | + | | 23 | +const owpenbotPkg = JSON.parse(readFileSync(resolve(repoRoot, "packages", "owpenbot", "package.json"), "utf8")); | | 24 | +const owpenbotVersion = String(owpenbotPkg.version ?? "").trim(); | | 25 | +if (!owpenbotVersion) { | | 26 | + throw new Error("owpenbot version missing in packages/owpenbot/package.json"); | | 27 | +} | | 28 | + | | 29 | +const run = (command, args, cwd) => { | | 30 | + const result = spawnSync(command, args, { cwd, stdio: "inherit" }); | | 31 | + if (result.status !== 0) { | | 32 | + process.exit(result.status ?? 1); | | 33 | + } | | 34 | +}; | | 35 | + | | 36 | +run("pnpm", ["--filter", "openwork-server", "build:bin:all"], repoRoot); | | 37 | +run("pnpm", ["--filter", "owpenwork", "build:bin:all"], repoRoot); | | 38 | + | | 39 | +const targets = [ | | 40 | + { id: "darwin-arm64", bun: "bun-darwin-arm64" }, | | 41 | + { id: "darwin-x64", bun: "bun-darwin-x64" }, | | 42 | + { id: "linux-x64", bun: "bun-linux-x64" }, | | 43 | + { id: "linux-arm64", bun: "bun-linux-arm64" }, | | 44 | + { id: "windows-x64", bun: "bun-windows-x64" }, | | 45 | +]; | | 46 | + | | 47 | +const sha256File = (path) => { | | 48 | + const data = readFileSync(path); | | 49 | + return createHash("sha256").update(data).digest("hex"); | | 50 | +}; | | 51 | + | | 52 | +const serverDir = resolve(repoRoot, "packages", "server", "dist", "bin"); | | 53 | +const owpenbotDir = resolve(repoRoot, "packages", "owpenbot", "dist", "bin"); | | 54 | + | | 55 | +mkdirSync(outdir, { recursive: true }); | | 56 | + | | 57 | +const entries = { | | 58 | + "openwork-server": { version: serverVersion, targets: {} }, | | 59 | + owpenbot: { version: owpenbotVersion, targets: {} }, | | 60 | +}; | | 61 | + | | 62 | +for (const target of targets) { | | 63 | + const ext = target.id.startsWith("windows") ? ".exe" : ""; | | 64 | + const serverSrc = join(serverDir, `openwork-server-${target.bun}${ext}`); | | 65 | + if (!existsSync(serverSrc)) { | | 66 | + throw new Error(`Missing openwork-server binary at ${serverSrc}`); | | 67 | + } | | 68 | + const serverDest = join(outdir, `openwork-server-${target.id}${ext}`); | | 69 | + copyFileSync(serverSrc, serverDest); | | 70 | + | | 71 | + const owpenbotSrc = join(owpenbotDir, `owpenbot-${target.bun}${ext}`); | | 72 | + if (!existsSync(owpenbotSrc)) { | | 73 | + throw new Error(`Missing owpenbot binary at ${owpenbotSrc}`); | | 74 | + } | | 75 | + const owpenbotDest = join(outdir, `owpenbot-${target.id}${ext}`); | | 76 | + copyFileSync(owpenbotSrc, owpenbotDest); | | 77 | + | | 78 | + entries["openwork-server"].targets[target.id] = { | | 79 | + asset: basename(serverDest), | | 80 | + sha256: sha256File(serverDest), | | 81 | + size: statSync(serverDest).size, | | 82 | + }; | | 83 | + entries.owpenbot.targets[target.id] = { | | 84 | + asset: basename(owpenbotDest), | | 85 | + sha256: sha256File(owpenbotDest), | | 86 | + size: statSync(owpenbotDest).size, | | 87 | + }; | | 88 | +} | | 89 | + | | 90 | +const manifest = { | | 91 | + version: openwrkVersion, | | 92 | + generatedAt: new Date().toISOString(), | | 93 | + entries, | | 94 | +}; | | 95 | + | | 96 | +writeFileSync(join(outdir, "openwrk-sidecars.json"), `${JSON.stringify(manifest, null, 2)}\n`, "utf8"); |
Collapse file Copy file name to clipboard +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +import { rm } from "node:fs/promises"; | | 2 | +import { resolve } from "node:path"; | | 3 | +import { fileURLToPath } from "node:url"; | | 4 | + | | 5 | +const root = resolve(fileURLToPath(new URL("..", import.meta.url))); | | 6 | +await rm(resolve(root, "dist"), { recursive: true, force: true }); |
|