Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1"use strict";2var __create = Object.create;3var __defProp = Object.defineProperty;4var __getOwnPropDesc = Object.getOwnPropertyDescriptor;5var __getOwnPropNames = Object.getOwnPropertyNames;6var __getProtoOf = Object.getPrototypeOf;7var __hasOwnProp = Object.prototype.hasOwnProperty;8var __export = (target, all) => {9 for (var name in all)10 __defProp(target, name, { get: all[name], enumerable: true });11};12var __copyProps = (to, from, except, desc) => {13 if (from && typeof from === "object" || typeof from === "function") {14 for (let key of __getOwnPropNames(from))15 if (!__hasOwnProp.call(to, key) && key !== except)16 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });17 }18 return to;19};20var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(21 // If the importer is in node compatibility mode or this is not an ESM22 // file that has been converted to a CommonJS file using a Babel-23 // compatible transform (i.e. "__esModule" has not been set), then set24 // "default" to the CommonJS "module.exports" for node compatibility.25 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,26 mod27));28var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);29var crBrowser_exports = {};30__export(crBrowser_exports, {31 CRBrowser: () => CRBrowser,32 CRBrowserContext: () => CRBrowserContext33});34module.exports = __toCommonJS(crBrowser_exports);35var import_path = __toESM(require("path"));36var import_assert = require("../../utils/isomorphic/assert");37var import_crypto = require("../utils/crypto");38var import_artifact = require("../artifact");39var import_browser = require("../browser");40var import_browserContext = require("../browserContext");41var import_frames = require("../frames");42var network = __toESM(require("../network"));43var import_page = require("../page");44var import_crConnection = require("./crConnection");45var import_crPage = require("./crPage");46var import_crProtocolHelper = require("./crProtocolHelper");47var import_crServiceWorker = require("./crServiceWorker");48class CRBrowser extends import_browser.Browser {49 constructor(parent, connection, options) {50 super(parent, options);51 this._clientRootSessionPromise = null;52 this._contexts = /* @__PURE__ */ new Map();53 this._crPages = /* @__PURE__ */ new Map();54 this._serviceWorkers = /* @__PURE__ */ new Map();55 this._version = "";56 this._tracingRecording = false;57 this._userAgent = "";58 this._connection = connection;59 this._session = this._connection.rootSession;60 this._connection.on(import_crConnection.ConnectionEvents.Disconnected, () => this._didDisconnect());61 this._session.on("Target.attachedToTarget", this._onAttachedToTarget.bind(this));62 this._session.on("Target.detachedFromTarget", this._onDetachedFromTarget.bind(this));63 this._session.on("Browser.downloadWillBegin", this._onDownloadWillBegin.bind(this));64 this._session.on("Browser.downloadProgress", this._onDownloadProgress.bind(this));65 }66 static async connect(parent, transport, options, devtools) {67 options = { ...options };68 const connection = new import_crConnection.CRConnection(parent, transport, options.protocolLogger, options.browserLogsCollector);69 const browser = new CRBrowser(parent, connection, options);70 browser._devtools = devtools;71 if (browser.isClank())72 browser._isCollocatedWithServer = false;73 const session = connection.rootSession;74 if (options.__testHookOnConnectToBrowser)75 await options.__testHookOnConnectToBrowser();76 const version = await session.send("Browser.getVersion");77 browser._version = version.product.substring(version.product.indexOf("/") + 1);78 browser._userAgent = version.userAgent;79 browser.options.headful = !version.userAgent.includes("Headless");80 if (!options.persistent) {81 await session.send("Target.setAutoAttach", { autoAttach: true, waitForDebuggerOnStart: true, flatten: true });82 return browser;83 }84 browser._defaultContext = new CRBrowserContext(browser, void 0, options.persistent);85 await Promise.all([86 session.send("Target.setAutoAttach", { autoAttach: true, waitForDebuggerOnStart: true, flatten: true }).then(async () => {87 await session.send("Target.getTargetInfo");88 }),89 browser._defaultContext._initialize()90 ]);91 await browser._waitForAllPagesToBeInitialized();92 return browser;93 }94 async doCreateNewContext(options) {95 const proxy = options.proxyOverride || options.proxy;96 let proxyBypassList = void 0;97 if (proxy) {98 if (process.env.PLAYWRIGHT_DISABLE_FORCED_CHROMIUM_PROXIED_LOOPBACK)99 proxyBypassList = proxy.bypass;100 else101 proxyBypassList = "<-loopback>" + (proxy.bypass ? `,${proxy.bypass}` : "");102 }103 const { browserContextId } = await this._session.send("Target.createBrowserContext", {104 disposeOnDetach: true,105 proxyServer: proxy ? proxy.server : void 0,106 proxyBypassList107 });108 const context = new CRBrowserContext(this, browserContextId, options);109 await context._initialize();110 this._contexts.set(browserContextId, context);111 return context;112 }113 contexts() {114 return Array.from(this._contexts.values());115 }116 version() {117 return this._version;118 }119 userAgent() {120 return this._userAgent;121 }122 _platform() {123 if (this._userAgent.includes("Windows"))124 return "win";125 if (this._userAgent.includes("Macintosh"))126 return "mac";127 return "linux";128 }129 isClank() {130 return this.options.name === "clank";131 }132 async _waitForAllPagesToBeInitialized() {133 await Promise.all([...this._crPages.values()].map((crPage) => crPage._page.waitForInitializedOrError()));134 }135 _onAttachedToTarget({ targetInfo, sessionId, waitingForDebugger }) {136 if (targetInfo.type === "browser")137 return;138 const session = this._session.createChildSession(sessionId);139 (0, import_assert.assert)(targetInfo.browserContextId, "targetInfo: " + JSON.stringify(targetInfo, null, 2));140 let context = this._contexts.get(targetInfo.browserContextId) || null;141 if (!context) {142 context = this._defaultContext;143 }144 if (targetInfo.type === "other" && targetInfo.url.startsWith("devtools://devtools") && this._devtools) {145 this._devtools.install(session);146 return;147 }148 const treatOtherAsPage = targetInfo.type === "other" && process.env.PW_CHROMIUM_ATTACH_TO_OTHER;149 if (!context || targetInfo.type === "other" && !treatOtherAsPage) {150 session.detach().catch(() => {151 });152 return;153 }154 (0, import_assert.assert)(!this._crPages.has(targetInfo.targetId), "Duplicate target " + targetInfo.targetId);155 (0, import_assert.assert)(!this._serviceWorkers.has(targetInfo.targetId), "Duplicate target " + targetInfo.targetId);156 if (targetInfo.type === "page" || treatOtherAsPage) {157 const opener = targetInfo.openerId ? this._crPages.get(targetInfo.openerId) || null : null;158 const crPage = new import_crPage.CRPage(session, targetInfo.targetId, context, opener, { hasUIWindow: targetInfo.type === "page" });159 this._crPages.set(targetInfo.targetId, crPage);160 return;161 }162 if (targetInfo.type === "service_worker") {163 const serviceWorker = new import_crServiceWorker.CRServiceWorker(context, session, targetInfo.url);164 this._serviceWorkers.set(targetInfo.targetId, serviceWorker);165 context.emit(CRBrowserContext.CREvents.ServiceWorker, serviceWorker);166 return;167 }168 session.detach().catch(() => {169 });170 }171 _onDetachedFromTarget(payload) {172 const targetId = payload.targetId;173 const crPage = this._crPages.get(targetId);174 if (crPage) {175 this._crPages.delete(targetId);176 crPage.didClose();177 return;178 }179 const serviceWorker = this._serviceWorkers.get(targetId);180 if (serviceWorker) {181 this._serviceWorkers.delete(targetId);182 serviceWorker.didClose();183 return;184 }185 }186 _didDisconnect() {187 for (const crPage of this._crPages.values())188 crPage.didClose();189 this._crPages.clear();190 for (const serviceWorker of this._serviceWorkers.values())191 serviceWorker.didClose();192 this._serviceWorkers.clear();193 this._didClose();194 }195 _findOwningPage(frameId) {196 for (const crPage of this._crPages.values()) {197 const frame = crPage._page.frameManager.frame(frameId);198 if (frame)199 return crPage;200 }201 return null;202 }203 _onDownloadWillBegin(payload) {204 const page = this._findOwningPage(payload.frameId);205 if (!page) {206 return;207 }208 page.willBeginDownload();209 let originPage = page._page.initializedOrUndefined();210 if (!originPage && page._opener)211 originPage = page._opener._page.initializedOrUndefined();212 if (!originPage)213 return;214 this._downloadCreated(originPage, payload.guid, payload.url, payload.suggestedFilename);215 }216 _onDownloadProgress(payload) {217 if (payload.state === "completed")218 this._downloadFinished(payload.guid, "");219 if (payload.state === "canceled")220 this._downloadFinished(payload.guid, this._closeReason || "canceled");221 }222 async _closePage(crPage) {223 await this._session.send("Target.closeTarget", { targetId: crPage._targetId });224 }225 async newBrowserCDPSession() {226 return await this._connection.createBrowserSession();227 }228 async startTracing(page, options = {}) {229 (0, import_assert.assert)(!this._tracingRecording, "Cannot start recording trace while already recording trace.");230 this._tracingClient = page ? page.delegate._mainFrameSession._client : this._session;231 const defaultCategories = [232 "-*",233 "devtools.timeline",234 "v8.execute",235 "disabled-by-default-devtools.timeline",236 "disabled-by-default-devtools.timeline.frame",237 "toplevel",238 "blink.console",239 "blink.user_timing",240 "latencyInfo",241 "disabled-by-default-devtools.timeline.stack",242 "disabled-by-default-v8.cpu_profiler",243 "disabled-by-default-v8.cpu_profiler.hires"244 ];245 const {246 screenshots = false,247 categories = defaultCategories248 } = options;249 if (screenshots)250 categories.push("disabled-by-default-devtools.screenshot");251 this._tracingRecording = true;252 await this._tracingClient.send("Tracing.start", {253 transferMode: "ReturnAsStream",254 categories: categories.join(",")255 });256 }257 async stopTracing() {258 (0, import_assert.assert)(this._tracingClient, "Tracing was not started.");259 const [event] = await Promise.all([260 new Promise((f) => this._tracingClient.once("Tracing.tracingComplete", f)),261 this._tracingClient.send("Tracing.end")262 ]);263 const tracingPath = import_path.default.join(this.options.artifactsDir, (0, import_crypto.createGuid)() + ".crtrace");264 await (0, import_crProtocolHelper.saveProtocolStream)(this._tracingClient, event.stream, tracingPath);265 this._tracingRecording = false;266 const artifact = new import_artifact.Artifact(this, tracingPath);267 artifact.reportFinished();268 return artifact;269 }270 isConnected() {271 return !this._connection._closed;272 }273 async _clientRootSession() {274 if (!this._clientRootSessionPromise)275 this._clientRootSessionPromise = this._connection.createBrowserSession();276 return this._clientRootSessionPromise;277 }278}279class CRBrowserContext extends import_browserContext.BrowserContext {280 static {281 this.CREvents = {282 ServiceWorker: "serviceworker"283 };284 }285 constructor(browser, browserContextId, options) {286 super(browser, options, browserContextId);287 this._authenticateProxyViaCredentials();288 }289 async _initialize() {290 (0, import_assert.assert)(!Array.from(this._browser._crPages.values()).some((page) => page._browserContext === this));291 const promises = [super._initialize()];292 if (this._browser.options.name !== "clank" && this._options.acceptDownloads !== "internal-browser-default") {293 promises.push(this._browser._session.send("Browser.setDownloadBehavior", {294 behavior: this._options.acceptDownloads === "accept" ? "allowAndName" : "deny",295 browserContextId: this._browserContextId,296 downloadPath: this._browser.options.downloadsPath,297 eventsEnabled: true298 }));299 }300 await Promise.all(promises);301 }302 _crPages() {303 return [...this._browser._crPages.values()].filter((crPage) => crPage._browserContext === this);304 }305 possiblyUninitializedPages() {306 return this._crPages().map((crPage) => crPage._page);307 }308 async doCreateNewPage() {309 const { targetId } = await this._browser._session.send("Target.createTarget", { url: "about:blank", browserContextId: this._browserContextId });310 return this._browser._crPages.get(targetId)._page;311 }312 async doGetCookies(urls) {313 const { cookies } = await this._browser._session.send("Storage.getCookies", { browserContextId: this._browserContextId });314 return network.filterCookies(cookies.map((c) => {315 const { name, value, domain, path: path2, expires, httpOnly, secure, sameSite } = c;316 const copy = {317 name,318 value,319 domain,320 path: path2,321 expires,322 httpOnly,323 secure,324 sameSite: sameSite ?? "Lax"325 };326 if (c.partitionKey) {327 copy._crHasCrossSiteAncestor = c.partitionKey.hasCrossSiteAncestor;328 copy.partitionKey = c.partitionKey.topLevelSite;329 }330 return copy;331 }), urls);332 }333 async addCookies(cookies) {334 function toChromiumCookie(cookie) {335 const { name, value, url, domain, path: path2, expires, httpOnly, secure, sameSite, partitionKey, _crHasCrossSiteAncestor } = cookie;336 const copy = {337 name,338 value,339 url,340 domain,341 path: path2,342 expires,343 httpOnly,344 secure,345 sameSite346 };347 if (partitionKey) {348 copy.partitionKey = {349 topLevelSite: partitionKey,350 // _crHasCrossSiteAncestor is non-standard, set it true by default if the cookie is partitioned.351 hasCrossSiteAncestor: _crHasCrossSiteAncestor ?? true352 };353 }354 return copy;355 }356 await this._browser._session.send("Storage.setCookies", {357 cookies: network.rewriteCookies(cookies).map(toChromiumCookie),358 browserContextId: this._browserContextId359 });360 }361 async doClearCookies() {362 await this._browser._session.send("Storage.clearCookies", { browserContextId: this._browserContextId });363 }364 async doGrantPermissions(origin, permissions) {365 const webPermissionToProtocol = /* @__PURE__ */ new Map([366 ["geolocation", "geolocation"],367 ["midi", "midi"],368 ["notifications", "notifications"],369 ["camera", "videoCapture"],370 ["microphone", "audioCapture"],371 ["background-sync", "backgroundSync"],372 ["ambient-light-sensor", "sensors"],373 ["accelerometer", "sensors"],374 ["gyroscope", "sensors"],375 ["magnetometer", "sensors"],376 ["clipboard-read", "clipboardReadWrite"],377 ["clipboard-write", "clipboardSanitizedWrite"],378 ["payment-handler", "paymentHandler"],379 // chrome-specific permissions we have.380 ["midi-sysex", "midiSysex"],381 ["storage-access", "storageAccess"],382 ["local-fonts", "localFonts"],383 ["local-network-access", "localNetworkAccess"]384 ]);385 const filtered = permissions.map((permission) => {386 const protocolPermission = webPermissionToProtocol.get(permission);387 if (!protocolPermission)388 throw new Error("Unknown permission: " + permission);389 return protocolPermission;390 });391 await this._browser._session.send("Browser.grantPermissions", { origin: origin === "*" ? void 0 : origin, browserContextId: this._browserContextId, permissions: filtered });392 }393 async doClearPermissions() {394 await this._browser._session.send("Browser.resetPermissions", { browserContextId: this._browserContextId });395 }396 async setGeolocation(geolocation) {397 (0, import_browserContext.verifyGeolocation)(geolocation);398 this._options.geolocation = geolocation;399 for (const page of this.pages())400 await page.delegate.updateGeolocation();401 }402 async doUpdateExtraHTTPHeaders() {403 for (const page of this.pages())404 await page.delegate.updateExtraHTTPHeaders();405 for (const sw of this.serviceWorkers())406 await sw.updateExtraHTTPHeaders();407 }408 async setUserAgent(userAgent) {409 this._options.userAgent = userAgent;410 for (const page of this.pages())411 await page.delegate.updateUserAgent();412 }413 async doUpdateOffline() {414 for (const page of this.pages())415 await page.delegate.updateOffline();416 for (const sw of this.serviceWorkers())417 await sw.updateOffline();418 }419 async doSetHTTPCredentials(httpCredentials) {420 this._options.httpCredentials = httpCredentials;421 for (const page of this.pages())422 await page.delegate.updateHttpCredentials();423 for (const sw of this.serviceWorkers())424 await sw.updateHttpCredentials();425 }426 async doAddInitScript(initScript) {427 for (const page of this.pages())428 await page.delegate.addInitScript(initScript);429 }430 async doRemoveInitScripts(initScripts) {431 for (const page of this.pages())432 await page.delegate.removeInitScripts(initScripts);433 }434 async doUpdateRequestInterception() {435 for (const page of this.pages())436 await page.delegate.updateRequestInterception();437 for (const sw of this.serviceWorkers())438 await sw.updateRequestInterception();439 }440 async doUpdateDefaultViewport() {441 }442 async doUpdateDefaultEmulatedMedia() {443 }444 async doExposePlaywrightBinding() {445 for (const page of this._crPages())446 await page.exposePlaywrightBinding();447 }448 async doClose(reason) {449 await this.dialogManager.closeBeforeUnloadDialogs();450 if (!this._browserContextId) {451 await this.stopVideoRecording();452 await this._browser.close({ reason });453 return;454 }455 await this._browser._session.send("Target.disposeBrowserContext", { browserContextId: this._browserContextId });456 this._browser._contexts.delete(this._browserContextId);457 for (const [targetId, serviceWorker] of this._browser._serviceWorkers) {458 if (serviceWorker.browserContext !== this)459 continue;460 serviceWorker.didClose();461 this._browser._serviceWorkers.delete(targetId);462 }463 }464 async stopVideoRecording() {465 await Promise.all(this._crPages().map((crPage) => crPage._mainFrameSession._stopVideoRecording()));466 }467 onClosePersistent() {468 }469 async clearCache() {470 for (const page of this._crPages())471 await page._networkManager.clearCache();472 }473 async cancelDownload(guid) {474 await this._browser._session.send("Browser.cancelDownload", {475 guid,476 browserContextId: this._browserContextId477 });478 }479 serviceWorkers() {480 return Array.from(this._browser._serviceWorkers.values()).filter((serviceWorker) => serviceWorker.browserContext === this);481 }482 async newCDPSession(page) {483 let targetId = null;484 if (page instanceof import_page.Page) {485 targetId = page.delegate._targetId;486 } else if (page instanceof import_frames.Frame) {487 const session = page._page.delegate._sessions.get(page._id);488 if (!session)489 throw new Error(`This frame does not have a separate CDP session, it is a part of the parent frame's session`);490 targetId = session._targetId;491 } else {492 throw new Error("page: expected Page or Frame");493 }494 const rootSession = await this._browser._clientRootSession();495 return rootSession.attachToTarget(targetId);496 }497}498// Annotate the CommonJS export names for ESM import in node:4990 && (module.exports = {500 CRBrowser,501 CRBrowserContext502});503 