@cyberstrike-io/cyberstrike-darwin-arm64 1.1.12 → 1.1.14-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cyberstrike +0 -0
- package/bin/hackbrowser-worker.js +107 -16
- package/package.json +1 -1
package/bin/cyberstrike
CHANGED
|
Binary file
|
|
@@ -31028,8 +31028,8 @@ async function waitForManualLogin(page, label) {
|
|
|
31028
31028
|
btn.style.cssText = [
|
|
31029
31029
|
"all: initial",
|
|
31030
31030
|
"position: fixed",
|
|
31031
|
-
"
|
|
31032
|
-
"
|
|
31031
|
+
"top: 16px",
|
|
31032
|
+
"right: 16px",
|
|
31033
31033
|
"z-index: 2147483647",
|
|
31034
31034
|
"display: flex",
|
|
31035
31035
|
"flex-direction: column",
|
|
@@ -40637,6 +40637,18 @@ Always respond with a valid JSON object. If there is nothing to explore, return:
|
|
|
40637
40637
|
|
|
40638
40638
|
// ../hackbrowser/src/navigator.ts
|
|
40639
40639
|
var log3 = Log.create({ service: "hackbrowser:navigator" });
|
|
40640
|
+
function isAuthError(err) {
|
|
40641
|
+
if (!err || typeof err !== "object")
|
|
40642
|
+
return false;
|
|
40643
|
+
const e = err;
|
|
40644
|
+
if (e.name === "AI_LoadAPIKeyError")
|
|
40645
|
+
return true;
|
|
40646
|
+
if (e.statusCode === 401 || e.statusCode === 403)
|
|
40647
|
+
return true;
|
|
40648
|
+
if (e.lastError && isAuthError(e.lastError))
|
|
40649
|
+
return true;
|
|
40650
|
+
return Array.isArray(e.errors) && e.errors.some(isAuthError);
|
|
40651
|
+
}
|
|
40640
40652
|
function loadPlannerPrompt() {
|
|
40641
40653
|
return planner_default;
|
|
40642
40654
|
}
|
|
@@ -40693,10 +40705,14 @@ async function planPage(snapshot, model, usageAcc) {
|
|
|
40693
40705
|
log3.debug("page plan", { tasks: plan.tasks.length });
|
|
40694
40706
|
return plan;
|
|
40695
40707
|
} catch (err) {
|
|
40708
|
+
if (isAuthError(err))
|
|
40709
|
+
throw err;
|
|
40696
40710
|
log3.warn("planPage failed, retrying once", { err: String(err) });
|
|
40697
40711
|
try {
|
|
40698
40712
|
return await attempt();
|
|
40699
40713
|
} catch (err2) {
|
|
40714
|
+
if (isAuthError(err2))
|
|
40715
|
+
throw err2;
|
|
40700
40716
|
log3.error("planPage failed after retry, returning empty plan", { err: String(err2) });
|
|
40701
40717
|
return { tasks: [] };
|
|
40702
40718
|
}
|
|
@@ -40743,6 +40759,8 @@ async function planUnexploredElements(snapshot, unexploredLabels, model, usageAc
|
|
|
40743
40759
|
log3.debug("unexplored plan", { tasks: plan.tasks.length });
|
|
40744
40760
|
return plan;
|
|
40745
40761
|
} catch (err) {
|
|
40762
|
+
if (isAuthError(err))
|
|
40763
|
+
throw err;
|
|
40746
40764
|
log3.warn("planUnexploredElements failed", { err: String(err) });
|
|
40747
40765
|
return { tasks: [] };
|
|
40748
40766
|
}
|
|
@@ -53975,8 +53993,7 @@ function validate(opts) {
|
|
|
53975
53993
|
if (!opts.url) {
|
|
53976
53994
|
throw new Error("opts.url is required");
|
|
53977
53995
|
}
|
|
53978
|
-
|
|
53979
|
-
if (opts.multiCredentials && opts.multiCredentials.length >= 2 && headlessRequested) {
|
|
53996
|
+
if (opts.multiCredentials && opts.multiCredentials.length >= 2 && opts.headless === true) {
|
|
53980
53997
|
throw new Error("multi-credential mode requires headless: false (manual login is currently the only supported flow)");
|
|
53981
53998
|
}
|
|
53982
53999
|
}
|
|
@@ -54056,33 +54073,107 @@ function send(msg) {
|
|
|
54056
54073
|
process.stdout.write(JSON.stringify(msg) + `
|
|
54057
54074
|
`);
|
|
54058
54075
|
}
|
|
54076
|
+
function stripSamplingParams(body) {
|
|
54077
|
+
if (typeof body !== "string")
|
|
54078
|
+
return body;
|
|
54079
|
+
try {
|
|
54080
|
+
const json2 = JSON.parse(body);
|
|
54081
|
+
if (json2 && typeof json2 === "object") {
|
|
54082
|
+
delete json2["temperature"];
|
|
54083
|
+
delete json2["top_p"];
|
|
54084
|
+
delete json2["top_k"];
|
|
54085
|
+
return JSON.stringify(json2);
|
|
54086
|
+
}
|
|
54087
|
+
} catch {}
|
|
54088
|
+
return body;
|
|
54089
|
+
}
|
|
54090
|
+
function applyAnthropicBearerBody(body, opts) {
|
|
54091
|
+
if (typeof body !== "string")
|
|
54092
|
+
return body;
|
|
54093
|
+
try {
|
|
54094
|
+
const j = JSON.parse(body);
|
|
54095
|
+
if (opts.stripSampling) {
|
|
54096
|
+
delete j["temperature"];
|
|
54097
|
+
delete j["top_p"];
|
|
54098
|
+
delete j["top_k"];
|
|
54099
|
+
}
|
|
54100
|
+
if (opts.userId)
|
|
54101
|
+
j["metadata"] = { ...j["metadata"] ?? {}, user_id: opts.userId };
|
|
54102
|
+
if (opts.systemPrefix) {
|
|
54103
|
+
const prefix = { type: "text", text: opts.systemPrefix };
|
|
54104
|
+
if (Array.isArray(j["system"]))
|
|
54105
|
+
j["system"] = [prefix, ...j["system"]];
|
|
54106
|
+
else if (typeof j["system"] === "string")
|
|
54107
|
+
j["system"] = [prefix, { type: "text", text: j["system"] }];
|
|
54108
|
+
else if (j["system"] == null)
|
|
54109
|
+
j["system"] = [prefix];
|
|
54110
|
+
}
|
|
54111
|
+
return JSON.stringify(j);
|
|
54112
|
+
} catch {
|
|
54113
|
+
return body;
|
|
54114
|
+
}
|
|
54115
|
+
}
|
|
54059
54116
|
function createModelFromDescriptor(desc) {
|
|
54117
|
+
const stripSampling = desc.supportsTemperature === false;
|
|
54118
|
+
const samplingFetch = stripSampling ? (input, init) => fetch(input, init ? { ...init, body: stripSamplingParams(init.body) } : init) : undefined;
|
|
54060
54119
|
if (desc.npm.includes("anthropic")) {
|
|
54061
|
-
|
|
54120
|
+
if (desc.authToken) {
|
|
54121
|
+
const token = desc.authToken;
|
|
54122
|
+
const beta = desc.anthropicBeta;
|
|
54123
|
+
const opts3 = {
|
|
54124
|
+
apiKey: "placeholder",
|
|
54125
|
+
fetch: (url2, init) => {
|
|
54126
|
+
const headers = new Headers(init?.headers);
|
|
54127
|
+
headers.delete("x-api-key");
|
|
54128
|
+
headers.set("authorization", `Bearer ${token}`);
|
|
54129
|
+
if (beta)
|
|
54130
|
+
headers.set("anthropic-beta", beta);
|
|
54131
|
+
const body = applyAnthropicBearerBody(init?.body, {
|
|
54132
|
+
stripSampling,
|
|
54133
|
+
userId: desc.anthropicUserId,
|
|
54134
|
+
systemPrefix: desc.anthropicSystemPrefix
|
|
54135
|
+
});
|
|
54136
|
+
return fetch(url2, { ...init, headers, body });
|
|
54137
|
+
}
|
|
54138
|
+
};
|
|
54139
|
+
if (desc.baseURL)
|
|
54140
|
+
opts3.baseURL = desc.baseURL;
|
|
54141
|
+
if (desc.headers)
|
|
54142
|
+
opts3.headers = desc.headers;
|
|
54143
|
+
return createAnthropic(opts3)(desc.modelApiId);
|
|
54144
|
+
}
|
|
54145
|
+
const opts2 = {};
|
|
54062
54146
|
if (desc.apiKey)
|
|
54063
|
-
|
|
54147
|
+
opts2.apiKey = desc.apiKey;
|
|
54064
54148
|
if (desc.baseURL)
|
|
54065
|
-
|
|
54149
|
+
opts2.baseURL = desc.baseURL;
|
|
54066
54150
|
if (desc.headers)
|
|
54067
|
-
|
|
54068
|
-
|
|
54151
|
+
opts2.headers = desc.headers;
|
|
54152
|
+
if (samplingFetch)
|
|
54153
|
+
opts2.fetch = samplingFetch;
|
|
54154
|
+
return createAnthropic(opts2)(desc.modelApiId);
|
|
54069
54155
|
}
|
|
54070
54156
|
if (desc.npm === "@ai-sdk/openai") {
|
|
54071
|
-
const
|
|
54157
|
+
const opts2 = {};
|
|
54072
54158
|
if (desc.apiKey)
|
|
54073
|
-
|
|
54159
|
+
opts2.apiKey = desc.apiKey;
|
|
54074
54160
|
if (desc.baseURL)
|
|
54075
|
-
|
|
54161
|
+
opts2.baseURL = desc.baseURL;
|
|
54076
54162
|
if (desc.headers)
|
|
54077
|
-
|
|
54078
|
-
|
|
54163
|
+
opts2.headers = desc.headers;
|
|
54164
|
+
if (samplingFetch)
|
|
54165
|
+
opts2.fetch = samplingFetch;
|
|
54166
|
+
return createOpenAI(opts2)(desc.modelApiId);
|
|
54079
54167
|
}
|
|
54080
|
-
|
|
54168
|
+
const opts = {
|
|
54081
54169
|
name: "hackbrowser-provider",
|
|
54082
54170
|
apiKey: desc.apiKey ?? "",
|
|
54083
54171
|
baseURL: desc.baseURL ?? "https://api.openai.com/v1",
|
|
54084
54172
|
headers: desc.headers
|
|
54085
|
-
}
|
|
54173
|
+
};
|
|
54174
|
+
if (samplingFetch)
|
|
54175
|
+
opts.fetch = samplingFetch;
|
|
54176
|
+
return createOpenAICompatible(opts).languageModel(desc.modelApiId);
|
|
54086
54177
|
}
|
|
54087
54178
|
function buildCrawlOptions(opts, signal) {
|
|
54088
54179
|
const logSink = (rec) => {
|