Skip to content

Commit 12900a0

Browse files
authored
feat(server-v2): add standalone runtime and SDK foundation (anomalyco#1468)
* feat(server-v2): add standalone runtime and SDK foundation * docs(server-v2): drop planning task checklists * build(server-v2): generate OpenAPI and SDK during dev * build(server-v2): generate API artifacts before builds * build(server-v2): drop duplicate root SDK generation * build(app): remove SDK generation hooks --------- Co-authored-by: src-opn <[email protected]>
1 parent 2ad9dfb commit 12900a0

111 files changed

Lines changed: 26679 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: Windows Signed Artifacts
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
ref:
7+
description: Git ref to build
8+
required: false
9+
type: string
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
build-and-sign-windows:
16+
name: Build and sign Windows artifacts
17+
runs-on: windows-latest
18+
env:
19+
TAURI_TARGET: x86_64-pc-windows-msvc
20+
BUN_TARGET: bun-windows-x64
21+
WINDOWS_SIGNING_CERT_PASSWORD: ${{ secrets.WINDOWS_CERT_PASSWORD }}
22+
WINDOWS_TIMESTAMP_URL: ${{ secrets.WINDOWS_TIMESTAMP_URL || 'http://timestamp.digicert.com' }}
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
with:
27+
ref: ${{ github.event.inputs.ref || github.ref }}
28+
29+
- name: Setup Node
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: 20
33+
34+
- name: Setup pnpm
35+
uses: pnpm/action-setup@v4
36+
with:
37+
version: 10.27.0
38+
39+
- name: Setup Bun
40+
uses: oven-sh/setup-bun@v1
41+
with:
42+
bun-version: 1.3.10
43+
44+
- name: Setup Rust
45+
uses: dtolnay/rust-toolchain@stable
46+
with:
47+
targets: x86_64-pc-windows-msvc
48+
49+
- name: Install dependencies
50+
run: pnpm install --frozen-lockfile
51+
52+
- name: Prepare sidecars
53+
run: pnpm -C apps/desktop prepare:sidecar
54+
55+
- name: Import Windows signing certificate
56+
shell: pwsh
57+
env:
58+
WINDOWS_CERT_PFX_BASE64: ${{ secrets.WINDOWS_CERT_PFX_BASE64 }}
59+
run: |
60+
if ([string]::IsNullOrWhiteSpace($env:WINDOWS_CERT_PFX_BASE64)) {
61+
throw "WINDOWS_CERT_PFX_BASE64 is required for Windows signing."
62+
}
63+
if ([string]::IsNullOrWhiteSpace($env:WINDOWS_SIGNING_CERT_PASSWORD)) {
64+
throw "WINDOWS_CERT_PASSWORD is required for Windows signing."
65+
}
66+
$bytes = [Convert]::FromBase64String($env:WINDOWS_CERT_PFX_BASE64)
67+
$certPath = Join-Path $env:RUNNER_TEMP "windows-codesign.pfx"
68+
[IO.File]::WriteAllBytes($certPath, $bytes)
69+
"WINDOWS_CERT_PATH=$certPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
70+
71+
- name: Sign bundled Windows sidecars
72+
shell: pwsh
73+
run: |
74+
$targets = @(
75+
"apps/desktop/src-tauri/sidecars/opencode-$env:TAURI_TARGET.exe",
76+
"apps/desktop/src-tauri/sidecars/opencode-router-$env:TAURI_TARGET.exe",
77+
"apps/desktop/src-tauri/sidecars/openwork-server-v2-$env:TAURI_TARGET.exe"
78+
)
79+
foreach ($target in $targets) {
80+
if (!(Test-Path $target)) {
81+
throw "Expected Windows sidecar missing: $target"
82+
}
83+
signtool sign /fd SHA256 /td SHA256 /tr $env:WINDOWS_TIMESTAMP_URL /f $env:WINDOWS_CERT_PATH /p $env:WINDOWS_SIGNING_CERT_PASSWORD $target
84+
}
85+
86+
- name: Build embedded Server V2 runtime
87+
run: pnpm --filter openwork-server-v2 build:bin:embedded:windows --bundle-dir ../desktop/src-tauri/sidecars
88+
working-directory: apps/server-v2
89+
90+
- name: Sign Server V2 executable
91+
shell: pwsh
92+
run: |
93+
$serverPath = "apps/server-v2/dist/bin/openwork-server-v2-$env:BUN_TARGET.exe"
94+
if (!(Test-Path $serverPath)) {
95+
throw "Expected Server V2 executable missing: $serverPath"
96+
}
97+
signtool sign /fd SHA256 /td SHA256 /tr $env:WINDOWS_TIMESTAMP_URL /f $env:WINDOWS_CERT_PATH /p $env:WINDOWS_SIGNING_CERT_PASSWORD $serverPath
98+
signtool verify /pa /v $serverPath
99+
100+
- name: Build desktop Windows bundle
101+
run: pnpm --filter @openwork/desktop exec tauri build --target x86_64-pc-windows-msvc
102+
103+
- name: Sign desktop Windows artifacts
104+
shell: pwsh
105+
run: |
106+
$artifacts = Get-ChildItem -Path "apps/desktop/src-tauri/target/x86_64-pc-windows-msvc/release/bundle" -Recurse -Include *.exe,*.msi
107+
if ($artifacts.Count -eq 0) {
108+
throw "No Windows desktop artifacts were produced to sign."
109+
}
110+
foreach ($artifact in $artifacts) {
111+
signtool sign /fd SHA256 /td SHA256 /tr $env:WINDOWS_TIMESTAMP_URL /f $env:WINDOWS_CERT_PATH /p $env:WINDOWS_SIGNING_CERT_PASSWORD $artifact.FullName
112+
signtool verify /pa /v $artifact.FullName
113+
}
114+
115+
- name: Upload signed artifacts
116+
uses: actions/upload-artifact@v4
117+
with:
118+
name: windows-signed-artifacts
119+
path: |
120+
apps/server-v2/dist/bin/openwork-server-v2-*.exe
121+
apps/desktop/src-tauri/target/x86_64-pc-windows-msvc/release/bundle/**/*.exe
122+
apps/desktop/src-tauri/target/x86_64-pc-windows-msvc/release/bundle/**/*.msi

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ apps/desktop/src-tauri/sidecars/
3030
# Bun build artifacts
3131
*.bun-build
3232
apps/server/cli
33+
apps/server-v2/openapi/openapi.json
34+
packages/openwork-server-sdk/generated/
3335

3436
# pnpm store (created by Docker volume mounts)
3537
.pnpm-store/
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env node
2+
3+
import { spawn } from "node:child_process";
4+
import { dirname, resolve } from "node:path";
5+
import { fileURLToPath } from "node:url";
6+
7+
const binDir = dirname(fileURLToPath(import.meta.url));
8+
const packageDir = resolve(binDir, "..");
9+
10+
const child = spawn("bun", ["src/cli.ts", ...process.argv.slice(2)], {
11+
cwd: packageDir,
12+
stdio: "inherit",
13+
env: process.env,
14+
});
15+
16+
child.once("exit", (code, signal) => {
17+
if (signal) {
18+
process.kill(process.pid, signal);
19+
return;
20+
}
21+
22+
process.exit(code ?? 1);
23+
});

‎apps/server-v2/package.json‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "openwork-server-v2",
3+
"version": "0.11.206",
4+
"private": true,
5+
"type": "module",
6+
"bin": {
7+
"openwork-server-v2": "bin/openwork-server-v2.mjs"
8+
},
9+
"scripts": {
10+
"dev": "OPENWORK_DEV_MODE=1 bun --watch src/cli.ts",
11+
"start": "bun src/cli.ts",
12+
"openapi:generate": "bun ./scripts/generate-openapi.ts",
13+
"openapi:watch": "node ./scripts/watch-openapi.mjs",
14+
"test": "bun test",
15+
"typecheck": "tsc -p tsconfig.json --noEmit",
16+
"build:bin": "bun ./script/build.ts --outdir dist/bin --filename openwork-server-v2",
17+
"build:bin:windows": "bun ./script/build.ts --outdir dist/bin --filename openwork-server-v2 --target bun-windows-x64",
18+
"build:bin:embedded": "bun ./script/build.ts --outdir dist/bin --filename openwork-server-v2 --embed-runtime",
19+
"build:bin:embedded:windows": "bun ./script/build.ts --outdir dist/bin --filename openwork-server-v2 --embed-runtime --target bun-windows-x64",
20+
"build:bin:all": "bun ./script/build.ts --outdir dist/bin --filename openwork-server-v2 --target bun-darwin-arm64 --target bun-darwin-x64-baseline --target bun-linux-x64-baseline --target bun-linux-arm64 --target bun-windows-x64",
21+
"build:bin:embedded:all": "bun ./script/build.ts --outdir dist/bin --filename openwork-server-v2 --embed-runtime --target bun-darwin-arm64 --target bun-darwin-x64-baseline --target bun-linux-x64-baseline --target bun-linux-arm64 --target bun-windows-x64",
22+
"prepublishOnly": "pnpm openapi:generate && pnpm build:bin"
23+
},
24+
"files": [
25+
"bin",
26+
"openapi",
27+
"src"
28+
],
29+
"dependencies": {
30+
"@opencode-ai/sdk": "1.2.27",
31+
"hono": "4.12.12",
32+
"hono-openapi": "1.3.0",
33+
"jsonc-parser": "^3.3.1",
34+
"yaml": "^2.8.1",
35+
"zod": "^4.3.6"
36+
},
37+
"devDependencies": {
38+
"@types/node": "^22.10.2",
39+
"bun-types": "^1.3.6",
40+
"typescript": "^5.6.3"
41+
},
42+
"packageManager": "[email protected]"
43+
}

0 commit comments

Comments
 (0)