Team Ai
Datasetpublic

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.

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes3.1kdownloads
ffBrowser.js429 linesDownload Raw Back to firefox
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 ffBrowser_exports = {};30__export(ffBrowser_exports, {31  FFBrowser: () => FFBrowser,32  FFBrowserContext: () => FFBrowserContext33});34module.exports = __toCommonJS(ffBrowser_exports);35var import_utils = require("../../utils");36var import_browser = require("../browser");37var import_browserContext = require("../browserContext");38var import_errors = require("../errors");39var network = __toESM(require("../network"));40var import_ffConnection = require("./ffConnection");41var import_ffPage = require("./ffPage");42var import_page = require("../page");43class FFBrowser extends import_browser.Browser {44  constructor(parent, connection, options) {45    super(parent, options);46    this._version = "";47    this._userAgent = "";48    this._connection = connection;49    this.session = connection.rootSession;50    this._ffPages = /* @__PURE__ */ new Map();51    this._contexts = /* @__PURE__ */ new Map();52    this._connection.on(import_ffConnection.ConnectionEvents.Disconnected, () => this._onDisconnect());53    this.session.on("Browser.attachedToTarget", this._onAttachedToTarget.bind(this));54    this.session.on("Browser.detachedFromTarget", this._onDetachedFromTarget.bind(this));55    this.session.on("Browser.downloadCreated", this._onDownloadCreated.bind(this));56    this.session.on("Browser.downloadFinished", this._onDownloadFinished.bind(this));57    this.session.on("Browser.videoRecordingFinished", this._onVideoRecordingFinished.bind(this));58  }59  static async connect(parent, transport, options) {60    const connection = new import_ffConnection.FFConnection(transport, options.protocolLogger, options.browserLogsCollector);61    const browser = new FFBrowser(parent, connection, options);62    if (options.__testHookOnConnectToBrowser)63      await options.__testHookOnConnectToBrowser();64    let firefoxUserPrefs = options.originalLaunchOptions.firefoxUserPrefs ?? {};65    if (Object.keys(kBandaidFirefoxUserPrefs).length)66      firefoxUserPrefs = { ...kBandaidFirefoxUserPrefs, ...firefoxUserPrefs };67    const promises = [68      browser.session.send("Browser.enable", {69        attachToDefaultContext: !!options.persistent,70        userPrefs: Object.entries(firefoxUserPrefs).map(([name, value]) => ({ name, value }))71      }),72      browser._initVersion()73    ];74    if (options.persistent) {75      browser._defaultContext = new FFBrowserContext(browser, void 0, options.persistent);76      promises.push(browser._defaultContext._initialize());77    }78    const proxy = options.originalLaunchOptions.proxyOverride || options.proxy;79    if (proxy)80      promises.push(browser.session.send("Browser.setBrowserProxy", toJugglerProxyOptions(proxy)));81    await Promise.all(promises);82    return browser;83  }84  async _initVersion() {85    const result = await this.session.send("Browser.getInfo");86    this._version = result.version.substring(result.version.indexOf("/") + 1);87    this._userAgent = result.userAgent;88  }89  isConnected() {90    return !this._connection._closed;91  }92  async doCreateNewContext(options) {93    if (options.isMobile)94      throw new Error("options.isMobile is not supported in Firefox");95    const { browserContextId } = await this.session.send("Browser.createBrowserContext", { removeOnDetach: true });96    const context = new FFBrowserContext(this, browserContextId, options);97    await context._initialize();98    this._contexts.set(browserContextId, context);99    return context;100  }101  contexts() {102    return Array.from(this._contexts.values());103  }104  version() {105    return this._version;106  }107  userAgent() {108    return this._userAgent;109  }110  _onDetachedFromTarget(payload) {111    const ffPage = this._ffPages.get(payload.targetId);112    this._ffPages.delete(payload.targetId);113    ffPage.didClose();114  }115  _onAttachedToTarget(payload) {116    const { targetId, browserContextId, openerId, type } = payload.targetInfo;117    (0, import_utils.assert)(type === "page");118    const context = browserContextId ? this._contexts.get(browserContextId) : this._defaultContext;119    (0, import_utils.assert)(context, `Unknown context id:${browserContextId}, _defaultContext: ${this._defaultContext}`);120    const session = this._connection.createSession(payload.sessionId);121    const opener = openerId ? this._ffPages.get(openerId) : null;122    const ffPage = new import_ffPage.FFPage(session, context, opener);123    this._ffPages.set(targetId, ffPage);124  }125  _onDownloadCreated(payload) {126    const ffPage = this._ffPages.get(payload.pageTargetId);127    if (!ffPage)128      return;129    ffPage._page.frameManager.frameAbortedNavigation(payload.frameId, "Download is starting");130    let originPage = ffPage._page.initializedOrUndefined();131    if (!originPage) {132      ffPage._markAsError(new Error("Starting new page download"));133      if (ffPage._opener)134        originPage = ffPage._opener._page.initializedOrUndefined();135    }136    if (!originPage)137      return;138    this._downloadCreated(originPage, payload.uuid, payload.url, payload.suggestedFileName);139  }140  _onDownloadFinished(payload) {141    const error = payload.canceled ? "canceled" : payload.error;142    this._downloadFinished(payload.uuid, error);143  }144  _onVideoRecordingFinished(payload) {145    this._takeVideo(payload.screencastId)?.reportFinished();146  }147  _onDisconnect() {148    for (const video of this._idToVideo.values())149      video.artifact.reportFinished(new import_errors.TargetClosedError());150    this._idToVideo.clear();151    for (const ffPage of this._ffPages.values())152      ffPage.didClose();153    this._ffPages.clear();154    this._didClose();155  }156}157class FFBrowserContext extends import_browserContext.BrowserContext {158  constructor(browser, browserContextId, options) {159    super(browser, options, browserContextId);160  }161  async _initialize() {162    (0, import_utils.assert)(!this._ffPages().length);163    const browserContextId = this._browserContextId;164    const promises = [165      super._initialize(),166      this._updateInitScripts()167    ];168    if (this._options.acceptDownloads !== "internal-browser-default") {169      promises.push(this._browser.session.send("Browser.setDownloadOptions", {170        browserContextId,171        downloadOptions: {172          behavior: this._options.acceptDownloads === "accept" ? "saveToDisk" : "cancel",173          downloadsDir: this._browser.options.downloadsPath174        }175      }));176    }177    promises.push(this.doUpdateDefaultViewport());178    if (this._options.hasTouch)179      promises.push(this._browser.session.send("Browser.setTouchOverride", { browserContextId, hasTouch: true }));180    if (this._options.userAgent)181      promises.push(this._browser.session.send("Browser.setUserAgentOverride", { browserContextId, userAgent: this._options.userAgent }));182    if (this._options.bypassCSP)183      promises.push(this._browser.session.send("Browser.setBypassCSP", { browserContextId, bypassCSP: true }));184    if (this._options.ignoreHTTPSErrors || this._options.internalIgnoreHTTPSErrors)185      promises.push(this._browser.session.send("Browser.setIgnoreHTTPSErrors", { browserContextId, ignoreHTTPSErrors: true }));186    if (this._options.javaScriptEnabled === false)187      promises.push(this._browser.session.send("Browser.setJavaScriptDisabled", { browserContextId, javaScriptDisabled: true }));188    if (this._options.locale)189      promises.push(this._browser.session.send("Browser.setLocaleOverride", { browserContextId, locale: this._options.locale }));190    if (this._options.timezoneId)191      promises.push(this._browser.session.send("Browser.setTimezoneOverride", { browserContextId, timezoneId: this._options.timezoneId }));192    if (this._options.extraHTTPHeaders || this._options.locale)193      promises.push(this.doUpdateExtraHTTPHeaders());194    if (this._options.httpCredentials)195      promises.push(this.setHTTPCredentials(this._options.httpCredentials));196    if (this._options.geolocation)197      promises.push(this.setGeolocation(this._options.geolocation));198    if (this._options.offline)199      promises.push(this.doUpdateOffline());200    promises.push(this.doUpdateDefaultEmulatedMedia());201    if (this._options.recordVideo) {202      promises.push(this._ensureVideosPath().then(() => {203        return this._browser.session.send("Browser.setVideoRecordingOptions", {204          // validateBrowserContextOptions ensures correct video size.205          options: {206            ...this._options.recordVideo.size,207            dir: this._options.recordVideo.dir208          },209          browserContextId: this._browserContextId210        });211      }));212    }213    const proxy = this._options.proxyOverride || this._options.proxy;214    if (proxy) {215      promises.push(this._browser.session.send("Browser.setContextProxy", {216        browserContextId: this._browserContextId,217        ...toJugglerProxyOptions(proxy)218      }));219    }220    await Promise.all(promises);221  }222  _ffPages() {223    return Array.from(this._browser._ffPages.values()).filter((ffPage) => ffPage._browserContext === this);224  }225  possiblyUninitializedPages() {226    return this._ffPages().map((ffPage) => ffPage._page);227  }228  async doCreateNewPage() {229    const { targetId } = await this._browser.session.send("Browser.newPage", {230      browserContextId: this._browserContextId231    }).catch((e) => {232      if (e.message.includes("Failed to override timezone"))233        throw new Error(`Invalid timezone ID: ${this._options.timezoneId}`);234      throw e;235    });236    return this._browser._ffPages.get(targetId)._page;237  }238  async doGetCookies(urls) {239    const { cookies } = await this._browser.session.send("Browser.getCookies", { browserContextId: this._browserContextId });240    return network.filterCookies(cookies.map((c) => {241      const { name, value, domain, path, expires, httpOnly, secure, sameSite } = c;242      return {243        name,244        value,245        domain,246        path,247        expires,248        httpOnly,249        secure,250        sameSite251      };252    }), urls);253  }254  async addCookies(cookies) {255    const cc = network.rewriteCookies(cookies).map((c) => {256      const { name, value, url, domain, path, expires, httpOnly, secure, sameSite } = c;257      return {258        name,259        value,260        url,261        domain,262        path,263        expires: expires === -1 ? void 0 : expires,264        httpOnly,265        secure,266        sameSite267      };268    });269    await this._browser.session.send("Browser.setCookies", { browserContextId: this._browserContextId, cookies: cc });270  }271  async doClearCookies() {272    await this._browser.session.send("Browser.clearCookies", { browserContextId: this._browserContextId });273  }274  async doGrantPermissions(origin, permissions) {275    const webPermissionToProtocol = /* @__PURE__ */ new Map([276      ["geolocation", "geo"],277      ["persistent-storage", "persistent-storage"],278      ["push", "push"],279      ["notifications", "desktop-notification"]280    ]);281    const filtered = permissions.map((permission) => {282      const protocolPermission = webPermissionToProtocol.get(permission);283      if (!protocolPermission)284        throw new Error("Unknown permission: " + permission);285      return protocolPermission;286    });287    await this._browser.session.send("Browser.grantPermissions", { origin, browserContextId: this._browserContextId, permissions: filtered });288  }289  async doClearPermissions() {290    await this._browser.session.send("Browser.resetPermissions", { browserContextId: this._browserContextId });291  }292  async setGeolocation(geolocation) {293    (0, import_browserContext.verifyGeolocation)(geolocation);294    this._options.geolocation = geolocation;295    await this._browser.session.send("Browser.setGeolocationOverride", { browserContextId: this._browserContextId, geolocation: geolocation || null });296  }297  async doUpdateExtraHTTPHeaders() {298    let allHeaders = this._options.extraHTTPHeaders || [];299    if (this._options.locale)300      allHeaders = network.mergeHeaders([allHeaders, network.singleHeader("Accept-Language", this._options.locale)]);301    await this._browser.session.send("Browser.setExtraHTTPHeaders", { browserContextId: this._browserContextId, headers: allHeaders });302  }303  async setUserAgent(userAgent) {304    await this._browser.session.send("Browser.setUserAgentOverride", { browserContextId: this._browserContextId, userAgent: userAgent || null });305  }306  async doUpdateOffline() {307    await this._browser.session.send("Browser.setOnlineOverride", { browserContextId: this._browserContextId, override: this._options.offline ? "offline" : "online" });308  }309  async doSetHTTPCredentials(httpCredentials) {310    this._options.httpCredentials = httpCredentials;311    let credentials = null;312    if (httpCredentials) {313      const { username, password, origin } = httpCredentials;314      credentials = { username, password, origin };315    }316    await this._browser.session.send("Browser.setHTTPCredentials", { browserContextId: this._browserContextId, credentials });317  }318  async doAddInitScript(initScript) {319    await this._updateInitScripts();320  }321  async doRemoveInitScripts(initScripts) {322    await this._updateInitScripts();323  }324  async _updateInitScripts() {325    const bindingScripts = [...this._pageBindings.values()].map((binding) => binding.initScript.source);326    if (this.bindingsInitScript)327      bindingScripts.unshift(this.bindingsInitScript.source);328    const initScripts = this.initScripts.map((script) => script.source);329    await this._browser.session.send("Browser.setInitScripts", { browserContextId: this._browserContextId, scripts: [...bindingScripts, ...initScripts].map((script) => ({ script })) });330  }331  async doUpdateRequestInterception() {332    await Promise.all([333      this._browser.session.send("Browser.setRequestInterception", { browserContextId: this._browserContextId, enabled: this.requestInterceptors.length > 0 }),334      this._browser.session.send("Browser.setCacheDisabled", { browserContextId: this._browserContextId, cacheDisabled: this.requestInterceptors.length > 0 })335    ]);336  }337  async doUpdateDefaultViewport() {338    if (!this._options.viewport)339      return;340    const viewport = {341      viewportSize: { width: this._options.viewport.width, height: this._options.viewport.height },342      deviceScaleFactor: this._options.deviceScaleFactor || 1343    };344    await this._browser.session.send("Browser.setDefaultViewport", { browserContextId: this._browserContextId, viewport });345  }346  async doUpdateDefaultEmulatedMedia() {347    if (this._options.colorScheme !== "no-override") {348      await this._browser.session.send("Browser.setColorScheme", {349        browserContextId: this._browserContextId,350        colorScheme: this._options.colorScheme !== void 0 ? this._options.colorScheme : "light"351      });352    }353    if (this._options.reducedMotion !== "no-override") {354      await this._browser.session.send("Browser.setReducedMotion", {355        browserContextId: this._browserContextId,356        reducedMotion: this._options.reducedMotion !== void 0 ? this._options.reducedMotion : "no-preference"357      });358    }359    if (this._options.forcedColors !== "no-override") {360      await this._browser.session.send("Browser.setForcedColors", {361        browserContextId: this._browserContextId,362        forcedColors: this._options.forcedColors !== void 0 ? this._options.forcedColors : "none"363      });364    }365    if (this._options.contrast !== "no-override") {366      await this._browser.session.send("Browser.setContrast", {367        browserContextId: this._browserContextId,368        contrast: this._options.contrast !== void 0 ? this._options.contrast : "no-preference"369      });370    }371  }372  async doExposePlaywrightBinding() {373    this._browser.session.send("Browser.addBinding", { browserContextId: this._browserContextId, name: import_page.PageBinding.kBindingName, script: "" });374  }375  onClosePersistent() {376  }377  async clearCache() {378    await this._browser.session.send("Browser.clearCache");379  }380  async doClose(reason) {381    if (!this._browserContextId) {382      if (this._options.recordVideo) {383        await this._browser.session.send("Browser.setVideoRecordingOptions", {384          options: void 0,385          browserContextId: this._browserContextId386        });387      }388      await this._browser.close({ reason });389    } else {390      await this._browser.session.send("Browser.removeBrowserContext", { browserContextId: this._browserContextId });391      this._browser._contexts.delete(this._browserContextId);392    }393  }394  async cancelDownload(uuid) {395    await this._browser.session.send("Browser.cancelDownload", { uuid });396  }397}398function toJugglerProxyOptions(proxy) {399  const proxyServer = new URL(proxy.server);400  let port = parseInt(proxyServer.port, 10);401  let type = "http";402  if (proxyServer.protocol === "socks5:")403    type = "socks";404  else if (proxyServer.protocol === "socks4:")405    type = "socks4";406  else if (proxyServer.protocol === "https:")407    type = "https";408  if (proxyServer.port === "") {409    if (proxyServer.protocol === "http:")410      port = 80;411    else if (proxyServer.protocol === "https:")412      port = 443;413  }414  return {415    type,416    bypass: proxy.bypass ? proxy.bypass.split(",").map((domain) => domain.trim()) : [],417    host: proxyServer.hostname,418    port,419    username: proxy.username,420    password: proxy.password421  };422}423const kBandaidFirefoxUserPrefs = {};424// Annotate the CommonJS export names for ESM import in node:4250 && (module.exports = {426  FFBrowser,427  FFBrowserContext428});429 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai