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 bidiPage_exports = {};30__export(bidiPage_exports, {31 BidiPage: () => BidiPage,32 kPlaywrightBindingChannel: () => kPlaywrightBindingChannel33});34module.exports = __toCommonJS(bidiPage_exports);35var import_eventsHelper = require("../utils/eventsHelper");36var dialog = __toESM(require("../dialog"));37var dom = __toESM(require("../dom"));38var import_bidiBrowser = require("./bidiBrowser");39var import_page = require("../page");40var import_bidiExecutionContext = require("./bidiExecutionContext");41var import_bidiInput = require("./bidiInput");42var import_bidiNetworkManager = require("./bidiNetworkManager");43var import_bidiPdf = require("./bidiPdf");44var bidi = __toESM(require("./third_party/bidiProtocol"));45const UTILITY_WORLD_NAME = "__playwright_utility_world__";46const kPlaywrightBindingChannel = "playwrightChannel";47class BidiPage {48 constructor(browserContext, bidiSession, opener) {49 this._realmToWorkerContext = /* @__PURE__ */ new Map();50 this._sessionListeners = [];51 this._initScriptIds = /* @__PURE__ */ new Map();52 this._session = bidiSession;53 this._opener = opener;54 this.rawKeyboard = new import_bidiInput.RawKeyboardImpl(bidiSession);55 this.rawMouse = new import_bidiInput.RawMouseImpl(bidiSession);56 this.rawTouchscreen = new import_bidiInput.RawTouchscreenImpl(bidiSession);57 this._realmToContext = /* @__PURE__ */ new Map();58 this._page = new import_page.Page(this, browserContext);59 this._browserContext = browserContext;60 this._networkManager = new import_bidiNetworkManager.BidiNetworkManager(this._session, this._page);61 this._pdf = new import_bidiPdf.BidiPDF(this._session);62 this._page.on(import_page.Page.Events.FrameDetached, (frame) => this._removeContextsForFrame(frame, false));63 this._sessionListeners = [64 import_eventsHelper.eventsHelper.addEventListener(bidiSession, "script.realmCreated", this._onRealmCreated.bind(this)),65 import_eventsHelper.eventsHelper.addEventListener(bidiSession, "script.message", this._onScriptMessage.bind(this)),66 import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.contextDestroyed", this._onBrowsingContextDestroyed.bind(this)),67 import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.navigationStarted", this._onNavigationStarted.bind(this)),68 import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.navigationCommitted", this._onNavigationCommitted.bind(this)),69 import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.navigationAborted", this._onNavigationAborted.bind(this)),70 import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.navigationFailed", this._onNavigationFailed.bind(this)),71 import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.fragmentNavigated", this._onFragmentNavigated.bind(this)),72 import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.historyUpdated", this._onHistoryUpdated.bind(this)),73 import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.domContentLoaded", this._onDomContentLoaded.bind(this)),74 import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.load", this._onLoad.bind(this)),75 import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.downloadWillBegin", this._onDownloadWillBegin.bind(this)),76 import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.downloadEnd", this._onDownloadEnded.bind(this)),77 import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.userPromptOpened", this._onUserPromptOpened.bind(this)),78 import_eventsHelper.eventsHelper.addEventListener(bidiSession, "log.entryAdded", this._onLogEntryAdded.bind(this))79 ];80 this._initialize().then(81 () => this._page.reportAsNew(this._opener?._page),82 (error) => this._page.reportAsNew(this._opener?._page, error)83 );84 }85 async _initialize() {86 this._onFrameAttached(this._session.sessionId, null);87 await Promise.all([88 this.updateHttpCredentials(),89 this.updateRequestInterception()90 // If the page is created by the Playwright client's call, some initialization91 // may be pending. Wait for it to complete before reporting the page as new.92 ]);93 }94 didClose() {95 this._session.dispose();96 import_eventsHelper.eventsHelper.removeEventListeners(this._sessionListeners);97 this._page._didClose();98 }99 _onFrameAttached(frameId, parentFrameId) {100 return this._page.frameManager.frameAttached(frameId, parentFrameId);101 }102 _removeContextsForFrame(frame, notifyFrame) {103 for (const [contextId, context] of this._realmToContext) {104 if (context.frame === frame) {105 this._realmToContext.delete(contextId);106 if (notifyFrame)107 frame._contextDestroyed(context);108 }109 }110 }111 _onRealmCreated(realmInfo) {112 if (realmInfo.type === "dedicated-worker") {113 const delegate2 = new import_bidiExecutionContext.BidiExecutionContext(this._session, realmInfo);114 const worker = new import_page.Worker(this._page, realmInfo.origin);115 this._realmToWorkerContext.set(realmInfo.realm, worker.createExecutionContext(delegate2));116 this._page.addWorker(realmInfo.realm, worker);117 return;118 }119 if (this._realmToContext.has(realmInfo.realm))120 return;121 if (realmInfo.type !== "window")122 return;123 const frame = this._page.frameManager.frame(realmInfo.context);124 if (!frame)125 return;126 let worldName;127 if (!realmInfo.sandbox) {128 worldName = "main";129 this._touchUtilityWorld(realmInfo.context);130 } else if (realmInfo.sandbox === UTILITY_WORLD_NAME) {131 worldName = "utility";132 } else {133 return;134 }135 const delegate = new import_bidiExecutionContext.BidiExecutionContext(this._session, realmInfo);136 const context = new dom.FrameExecutionContext(delegate, frame, worldName);137 frame._contextCreated(worldName, context);138 this._realmToContext.set(realmInfo.realm, context);139 }140 async _touchUtilityWorld(context) {141 await this._session.sendMayFail("script.evaluate", {142 expression: "1 + 1",143 target: {144 context,145 sandbox: UTILITY_WORLD_NAME146 },147 serializationOptions: {148 maxObjectDepth: 10,149 maxDomDepth: 10150 },151 awaitPromise: true,152 userActivation: true153 });154 }155 _onRealmDestroyed(params) {156 const context = this._realmToContext.get(params.realm);157 if (context) {158 this._realmToContext.delete(params.realm);159 context.frame._contextDestroyed(context);160 return true;161 }162 const existed = this._realmToWorkerContext.delete(params.realm);163 if (existed) {164 this._page.removeWorker(params.realm);165 return true;166 }167 return false;168 }169 // TODO: route the message directly to the browser170 _onBrowsingContextDestroyed(params) {171 this._browserContext._browser._onBrowsingContextDestroyed(params);172 }173 _onNavigationStarted(params) {174 const frameId = params.context;175 this._page.frameManager.frameRequestedNavigation(frameId, params.navigation);176 }177 _onNavigationCommitted(params) {178 const frameId = params.context;179 this._page.frameManager.frameCommittedNewDocumentNavigation(180 frameId,181 params.url,182 "",183 params.navigation,184 /* initial */185 false186 );187 }188 _onDomContentLoaded(params) {189 const frameId = params.context;190 this._page.frameManager.frameLifecycleEvent(frameId, "domcontentloaded");191 }192 _onLoad(params) {193 this._page.frameManager.frameLifecycleEvent(params.context, "load");194 }195 _onNavigationAborted(params) {196 this._page.frameManager.frameAbortedNavigation(params.context, "Navigation aborted", params.navigation || void 0);197 }198 _onNavigationFailed(params) {199 this._page.frameManager.frameAbortedNavigation(params.context, "Navigation failed", params.navigation || void 0);200 }201 _onFragmentNavigated(params) {202 this._page.frameManager.frameCommittedSameDocumentNavigation(params.context, params.url);203 }204 _onHistoryUpdated(params) {205 this._page.frameManager.frameCommittedSameDocumentNavigation(params.context, params.url);206 }207 _onUserPromptOpened(event) {208 this._page.browserContext.dialogManager.dialogDidOpen(new dialog.Dialog(209 this._page,210 event.type,211 event.message,212 async (accept, userText) => {213 await this._session.send("browsingContext.handleUserPrompt", { context: event.context, accept, userText });214 },215 event.defaultValue216 ));217 }218 _onDownloadWillBegin(event) {219 if (!event.navigation)220 return;221 this._page.frameManager.frameAbortedNavigation(event.context, "Download is starting");222 let originPage = this._page.initializedOrUndefined();223 if (!originPage && this._opener)224 originPage = this._opener._page.initializedOrUndefined();225 if (!originPage)226 return;227 this._browserContext._browser._downloadCreated(originPage, event.navigation, event.url, event.suggestedFilename);228 }229 _onDownloadEnded(event) {230 if (!event.navigation)231 return;232 this._browserContext._browser._downloadFinished(event.navigation, event.status === "canceled" ? "canceled" : void 0);233 }234 _onLogEntryAdded(params) {235 if (params.type === "javascript" && params.level === "error") {236 let errorName = "";237 let errorMessage;238 if (params.text?.includes(": ")) {239 const index = params.text.indexOf(": ");240 errorName = params.text.substring(0, index);241 errorMessage = params.text.substring(index + 2);242 } else {243 errorMessage = params.text ?? void 0;244 }245 const error = new Error(errorMessage);246 error.name = errorName;247 error.stack = `${params.text}248${params.stackTrace?.callFrames.map((f) => {249 const location2 = `${f.url}:${f.lineNumber + 1}:${f.columnNumber + 1}`;250 return f.functionName ? ` at ${f.functionName} (${location2})` : ` at ${location2}`;251 }).join("\n")}`;252 this._page.addPageError(error);253 return;254 }255 if (params.type !== "console")256 return;257 const entry = params;258 const context = this._realmToContext.get(params.source.realm) ?? this._realmToWorkerContext.get(params.source.realm);259 if (!context)260 return;261 const callFrame = params.stackTrace?.callFrames[0];262 const location = callFrame ?? { url: "", lineNumber: 1, columnNumber: 1 };263 this._page.addConsoleMessage(entry.method, entry.args.map((arg) => (0, import_bidiExecutionContext.createHandle)(context, arg)), location, params.text || void 0);264 }265 async navigateFrame(frame, url, referrer) {266 const { navigation } = await this._session.send("browsingContext.navigate", {267 context: frame._id,268 url269 });270 return { newDocumentId: navigation || void 0 };271 }272 async updateExtraHTTPHeaders() {273 }274 async updateEmulateMedia() {275 }276 async updateUserAgent() {277 }278 async bringToFront() {279 await this._session.send("browsingContext.activate", {280 context: this._session.sessionId281 });282 }283 async updateEmulatedViewportSize() {284 const options = this._browserContext._options;285 const emulatedSize = this._page.emulatedSize();286 if (!emulatedSize)287 return;288 const viewportSize = emulatedSize.viewport;289 await Promise.all([290 this._session.send("browsingContext.setViewport", {291 context: this._session.sessionId,292 viewport: {293 width: viewportSize.width,294 height: viewportSize.height295 },296 devicePixelRatio: options.deviceScaleFactor || 1297 }),298 this._session.send("emulation.setScreenOrientationOverride", {299 contexts: [this._session.sessionId],300 screenOrientation: (0, import_bidiBrowser.getScreenOrientation)(!!options.isMobile, viewportSize)301 })302 ]);303 }304 async updateRequestInterception() {305 await this._networkManager.setRequestInterception(this._page.needsRequestInterception());306 }307 async updateOffline() {308 }309 async updateHttpCredentials() {310 await this._networkManager.setCredentials(this._browserContext._options.httpCredentials);311 }312 async updateFileChooserInterception() {313 }314 async reload() {315 await this._session.send("browsingContext.reload", {316 context: this._session.sessionId,317 // ignoreCache: true,318 wait: bidi.BrowsingContext.ReadinessState.Interactive319 });320 }321 async goBack() {322 return await this._session.send("browsingContext.traverseHistory", {323 context: this._session.sessionId,324 delta: -1325 }).then(() => true).catch(() => false);326 }327 async goForward() {328 return await this._session.send("browsingContext.traverseHistory", {329 context: this._session.sessionId,330 delta: 1331 }).then(() => true).catch(() => false);332 }333 async requestGC() {334 throw new Error("Method not implemented.");335 }336 async _onScriptMessage(event) {337 if (event.channel !== kPlaywrightBindingChannel)338 return;339 const pageOrError = await this._page.waitForInitializedOrError();340 if (pageOrError instanceof Error)341 return;342 const context = this._realmToContext.get(event.source.realm);343 if (!context)344 return;345 if (event.data.type !== "string")346 return;347 await this._page.onBindingCalled(event.data.value, context);348 }349 async addInitScript(initScript) {350 const { script } = await this._session.send("script.addPreloadScript", {351 // TODO: remove function call from the source.352 functionDeclaration: `() => { return ${initScript.source} }`,353 // TODO: push to iframes?354 contexts: [this._session.sessionId]355 });356 this._initScriptIds.set(initScript, script);357 }358 async removeInitScripts(initScripts) {359 const ids = [];360 for (const script of initScripts) {361 const id = this._initScriptIds.get(script);362 if (id)363 ids.push(id);364 this._initScriptIds.delete(script);365 }366 await Promise.all(ids.map((script) => this._session.send("script.removePreloadScript", { script })));367 }368 async closePage(runBeforeUnload) {369 if (runBeforeUnload) {370 this._session.sendMayFail("browsingContext.close", {371 context: this._session.sessionId,372 promptUnload: runBeforeUnload373 });374 } else {375 await this._session.send("browsingContext.close", {376 context: this._session.sessionId,377 promptUnload: runBeforeUnload378 });379 }380 }381 async setBackgroundColor(color) {382 }383 async takeScreenshot(progress, format, documentRect, viewportRect, quality, fitsViewport, scale) {384 const rect = documentRect || viewportRect;385 const { data } = await progress.race(this._session.send("browsingContext.captureScreenshot", {386 context: this._session.sessionId,387 format: {388 type: `image/${format === "png" ? "png" : "jpeg"}`,389 quality: quality ? quality / 100 : 0.8390 },391 origin: documentRect ? "document" : "viewport",392 clip: {393 type: "box",394 ...rect395 }396 }));397 return Buffer.from(data, "base64");398 }399 async getContentFrame(handle) {400 const executionContext = toBidiExecutionContext(handle._context);401 const frameId = await executionContext.contentFrameIdForFrame(handle);402 if (!frameId)403 return null;404 return this._page.frameManager.frame(frameId);405 }406 async getOwnerFrame(handle) {407 const windowHandle = await handle.evaluateHandle((node) => {408 const doc = node.ownerDocument ?? node;409 return doc.defaultView;410 });411 if (!windowHandle)412 return null;413 const executionContext = toBidiExecutionContext(handle._context);414 return executionContext.frameIdForWindowHandle(windowHandle);415 }416 async getBoundingBox(handle) {417 const box = await handle.evaluate((element) => {418 if (!(element instanceof Element))419 return null;420 const rect = element.getBoundingClientRect();421 return { x: rect.x, y: rect.y, width: rect.width, height: rect.height };422 });423 if (!box)424 return null;425 const position = await this._framePosition(handle._frame);426 if (!position)427 return null;428 box.x += position.x;429 box.y += position.y;430 return box;431 }432 // TODO: move to Frame.433 async _framePosition(frame) {434 if (frame === this._page.mainFrame())435 return { x: 0, y: 0 };436 const element = await frame.frameElement();437 const box = await element.boundingBox();438 if (!box)439 return null;440 const style = await element.evaluateInUtility(([injected, iframe]) => injected.describeIFrameStyle(iframe), {}).catch((e) => "error:notconnected");441 if (style === "error:notconnected" || style === "transformed")442 return null;443 box.x += style.left;444 box.y += style.top;445 return box;446 }447 async scrollRectIntoViewIfNeeded(handle, rect) {448 return await handle.evaluateInUtility(([injected, node]) => {449 node.scrollIntoView({450 block: "center",451 inline: "center",452 behavior: "instant"453 });454 }, null).then(() => "done").catch((e) => {455 if (e instanceof Error && e.message.includes("Node is detached from document"))456 return "error:notconnected";457 if (e instanceof Error && e.message.includes("Node does not have a layout object"))458 return "error:notvisible";459 throw e;460 });461 }462 async setScreencastOptions(options) {463 }464 rafCountForStablePosition() {465 return 1;466 }467 async getContentQuads(handle) {468 const quads = await handle.evaluateInUtility(([injected, node]) => {469 if (!node.isConnected)470 return "error:notconnected";471 const rects = node.getClientRects();472 if (!rects)473 return null;474 return [...rects].map((rect) => [475 { x: rect.left, y: rect.top },476 { x: rect.right, y: rect.top },477 { x: rect.right, y: rect.bottom },478 { x: rect.left, y: rect.bottom }479 ]);480 }, null);481 if (!quads || quads === "error:notconnected")482 return quads;483 const position = await this._framePosition(handle._frame);484 if (!position)485 return null;486 quads.forEach((quad) => quad.forEach((point) => {487 point.x += position.x;488 point.y += position.y;489 }));490 return quads;491 }492 async setInputFilePaths(handle, paths) {493 const fromContext = toBidiExecutionContext(handle._context);494 await this._session.send("input.setFiles", {495 context: this._session.sessionId,496 element: await fromContext.nodeIdForElementHandle(handle),497 files: paths498 });499 }500 async adoptElementHandle(handle, to) {501 const fromContext = toBidiExecutionContext(handle._context);502 const nodeId = await fromContext.nodeIdForElementHandle(handle);503 const executionContext = toBidiExecutionContext(to);504 return await executionContext.remoteObjectForNodeId(to, nodeId);505 }506 async getAccessibilityTree(needle) {507 throw new Error("Method not implemented.");508 }509 async inputActionEpilogue() {510 }511 async resetForReuse(progress) {512 }513 async pdf(options) {514 return this._pdf.generate(options);515 }516 async getFrameElement(frame) {517 const parent = frame.parentFrame();518 if (!parent)519 throw new Error("Frame has been detached.");520 const parentContext = await parent._mainContext();521 const list = await parentContext.evaluateHandle(() => {522 return [...document.querySelectorAll("iframe,frame")];523 });524 const length = await list.evaluate((list2) => list2.length);525 let foundElement = null;526 for (let i = 0; i < length; i++) {527 const element = await list.evaluateHandle((list2, i2) => list2[i2], i);528 const candidate = await element.contentFrame();529 if (frame === candidate) {530 foundElement = element;531 break;532 } else {533 element.dispose();534 }535 }536 list.dispose();537 if (!foundElement)538 throw new Error("Frame has been detached.");539 return foundElement;540 }541 shouldToggleStyleSheetToSyncAnimations() {542 return true;543 }544}545function toBidiExecutionContext(executionContext) {546 return executionContext.delegate;547}548// Annotate the CommonJS export names for ESM import in node:5490 && (module.exports = {550 BidiPage,551 kPlaywrightBindingChannel552});553 