Files
openwork/apps/server-v2/src/runtime/manifest.ts
Source Open 12900a0b9e feat(server-v2): add standalone runtime and SDK foundation (#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 <src-opn@users.noreply.github.com>
2026-04-17 09:54:26 -07:00

89 lines
1.9 KiB
TypeScript

export type RuntimeTarget =
| "darwin-arm64"
| "darwin-x64"
| "linux-arm64"
| "linux-x64"
| "windows-arm64"
| "windows-x64";
export type RuntimeAssetName = "opencode" | "opencode-router";
export type RuntimeAssetSource = "development" | "release";
export type RuntimeManifestFile = {
path: string;
sha256: string;
size: number;
};
export type RuntimeManifest = {
files: Record<RuntimeAssetName, RuntimeManifestFile>;
generatedAt: string;
manifestVersion: 1;
opencodeVersion: string;
rootDir: string;
routerVersion: string;
serverVersion: string;
source: RuntimeAssetSource;
target: RuntimeTarget;
};
export type ResolvedRuntimeBinary = {
absolutePath: string;
name: RuntimeAssetName;
sha256: string;
size: number;
source: RuntimeAssetSource;
stagedRoot: string;
target: RuntimeTarget;
version: string;
};
export type ResolvedRuntimeBundle = {
manifest: RuntimeManifest;
opencode: ResolvedRuntimeBinary;
router: ResolvedRuntimeBinary;
};
export function resolveRuntimeTarget(): RuntimeTarget | null {
if (process.platform === "darwin") {
if (process.arch === "arm64") {
return "darwin-arm64";
}
if (process.arch === "x64") {
return "darwin-x64";
}
return null;
}
if (process.platform === "linux") {
if (process.arch === "arm64") {
return "linux-arm64";
}
if (process.arch === "x64") {
return "linux-x64";
}
return null;
}
if (process.platform === "win32") {
if (process.arch === "arm64") {
return "windows-arm64";
}
if (process.arch === "x64") {
return "windows-x64";
}
return null;
}
return null;
}
export function runtimeBinaryFilename(name: RuntimeAssetName, target: RuntimeTarget) {
const base = name === "opencode" ? "opencode" : "opencode-router";
return target.startsWith("windows") ? `${base}.exe` : base;
}
export function resolveBunTarget(target: RuntimeTarget) {
return `bun-${target}`;
}