Skip to content

Commit 589c308

Browse files
fix(server): secure opencode proxy + add skill delete (anomalyco#505)
* fix(server): harden opencode proxy auth * feat(server): add skill delete endpoint * fix(ci): reuse resolved OPENCODE_VERSION for desktop build * fix(desktop): skip opencode version lookup when sidecar exists * fix(desktop): avoid TDZ when reusing opencode sidecar * chore(desktop): update Cargo.lock
1 parent 366bc36 commit 589c308

4 files changed

Lines changed: 17 additions & 9 deletions

File tree

‎.github/workflows/build-desktop.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ jobs:
8989
exit 1
9090
fi
9191
92+
# Reuse this resolved version for subsequent steps (e.g. prepare-sidecar).
93+
echo "OPENCODE_VERSION=$version" >> "$GITHUB_ENV"
94+
9295
opencode_asset="opencode-linux-x64-baseline.tar.gz"
9396
url="https://github.com/anomalyco/opencode/releases/download/v${version}/${opencode_asset}"
9497
tmp_dir="$RUNNER_TEMP/opencode"

‎packages/desktop/scripts/prepare-sidecar.mjs‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ const opencodeTargetName = resolvedTargetTriple
128128
: null;
129129
const opencodeTargetPath = opencodeTargetName ? join(sidecarDir, opencodeTargetName) : null;
130130

131+
const opencodeCandidatePath = opencodeTargetPath ?? opencodePath;
132+
let existingOpencodeVersion = null;
133+
131134
// openwork-server paths
132135
const openworkServerBaseName = "openwork-server";
133136
const openworkServerName = process.platform === "win32" ? `${openworkServerBaseName}.exe` : openworkServerBaseName;
@@ -334,7 +337,17 @@ if (existsSync(openworkServerBuildPath)) {
334337
}
335338
}
336339

340+
if (!existingOpencodeVersion && opencodeCandidatePath) {
341+
existingOpencodeVersion =
342+
existsSync(opencodeCandidatePath) && !isStubBinary(opencodeCandidatePath)
343+
? readBinaryVersion(opencodeCandidatePath)
344+
: null;
345+
}
346+
337347
let normalizedOpencodeVersion = normalizeVersion(opencodeVersion);
348+
if (!normalizedOpencodeVersion && existingOpencodeVersion) {
349+
normalizedOpencodeVersion = normalizeVersion(existingOpencodeVersion);
350+
}
338351
if (!normalizedOpencodeVersion) {
339352
normalizedOpencodeVersion = await fetchLatestOpencodeVersion();
340353
}
@@ -362,12 +375,6 @@ const opencodeUrl = opencodeAsset
362375
? `https://github.com/anomalyco/opencode/releases/download/v${normalizedOpencodeVersion}/${opencodeAsset}`
363376
: null;
364377

365-
const opencodeCandidatePath = opencodeTargetPath ?? opencodePath;
366-
const existingOpencodeVersion =
367-
opencodeCandidatePath && existsSync(opencodeCandidatePath)
368-
? readBinaryVersion(opencodeCandidatePath)
369-
: null;
370-
371378
const shouldDownloadOpencode =
372379
!opencodeCandidatePath ||
373380
!existsSync(opencodeCandidatePath) ||

‎packages/desktop/src-tauri/Cargo.lock‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/server/src/server.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,14 +1533,12 @@ function createRoutes(config: ServerConfig, approvals: ApprovalService, tokens:
15331533
if (!name) {
15341534
throw new ApiError(400, "invalid_skill_name", "Skill name is required");
15351535
}
1536-
15371536
await requireApproval(ctx, {
15381537
workspaceId: workspace.id,
15391538
action: "skills.delete",
15401539
summary: `Delete skill ${name}`,
15411540
paths: [join(workspace.path, ".opencode", "skills", name)],
15421541
});
1543-
15441542
const result = await deleteSkill(workspace.path, name);
15451543
await recordAudit(workspace.path, {
15461544
id: shortId(),

0 commit comments

Comments
 (0)