Skip to content

Commit 96317f9

Browse files
Serhatcckclaude
andcommitted
fix(hackbrowser): guard CYBERSTRIKE_VERSION in the worker's Copilot fetch — fixes Copilot crawls
The Copilot request path in the hackbrowser worker subprocess set its User-Agent with a bare `CYBERSTRIKE_VERSION` — a build-time define that the standalone worker bundle build never injects. In the subprocess that identifier is undefined, so the header line threw `ReferenceError: CYBERSTRIKE_VERSION is not defined` on every planner LLM call, before the fetch even ran; planPage then returned an empty plan for every page and the crawl "completed" immediately with no exploration. Only surfaces when a GitHub Copilot model is used — other providers never enter this branch. Guard it exactly like Installation.VERSION already does (installation/index.ts): `typeof CYBERSTRIKE_VERSION === "string" ? CYBERSTRIKE_VERSION : "local"`, so it falls back to "local" instead of throwing. The main-process chat path uses this same guarded accessor, so the worker now matches it. No token-exchange/header changes are needed: chat and worker both authenticate with the raw token and equivalent headers, and chat works — aligning the User-Agent is sufficient. Verified: the bare reference throws ReferenceError; the guarded form returns "cyberstrike/local" with no throw; cyberstrike typecheck clean. Related: #107. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent a8cd743 commit 96317f9

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

packages/cyberstrike/src/hackbrowser-subprocess/hackbrowser-worker.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,12 @@ function createModelFromDescriptor(desc: ModelDescriptor): LanguageModel {
169169
headers.delete("authorization")
170170
headers.set("Authorization", `Bearer ${token}`)
171171
headers.set("x-initiator", "user")
172-
headers.set("User-Agent", `cyberstrike/${CYBERSTRIKE_VERSION}`)
172+
// CYBERSTRIKE_VERSION is a build-time define that the standalone worker bundle does not
173+
// inject, so referencing it bare throws ReferenceError here (in the subprocess) and every
174+
// planner call fails → the crawl "completes" with no plan. Guard it exactly like
175+
// Installation.VERSION does (installation/index.ts) so it falls back to "local" instead.
176+
const version = typeof CYBERSTRIKE_VERSION === "string" ? CYBERSTRIKE_VERSION : "local"
177+
headers.set("User-Agent", `cyberstrike/${version}`)
173178
headers.set("Openai-Intent", "conversation-edits")
174179
return fetch(
175180
url,

0 commit comments

Comments
 (0)