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 context_exports = {};30__export(context_exports, {31 Context: () => Context,32 InputRecorder: () => InputRecorder33});34module.exports = __toCommonJS(context_exports);35var import_fs = __toESM(require("fs"));36var import_path = __toESM(require("path"));37var import_utilsBundle = require("playwright-core/lib/utilsBundle");38var import_log = require("../log");39var import_tab = require("./tab");40var import_config = require("./config");41var codegen = __toESM(require("./codegen"));42var import_utils = require("./tools/utils");43const testDebug = (0, import_utilsBundle.debug)("pw:mcp:test");44class Context {45 constructor(options) {46 this._tabs = [];47 this._abortController = new AbortController();48 this.config = options.config;49 this.sessionLog = options.sessionLog;50 this.options = options;51 this._browserContextFactory = options.browserContextFactory;52 this._clientInfo = options.clientInfo;53 testDebug("create context");54 Context._allContexts.add(this);55 }56 static {57 this._allContexts = /* @__PURE__ */ new Set();58 }59 static async disposeAll() {60 await Promise.all([...Context._allContexts].map((context) => context.dispose()));61 }62 tabs() {63 return this._tabs;64 }65 currentTab() {66 return this._currentTab;67 }68 currentTabOrDie() {69 if (!this._currentTab)70 throw new Error('No open pages available. Use the "browser_navigate" tool to navigate to a page first.');71 return this._currentTab;72 }73 async newTab() {74 const { browserContext } = await this._ensureBrowserContext();75 const page = await browserContext.newPage();76 this._currentTab = this._tabs.find((t) => t.page === page);77 return this._currentTab;78 }79 async selectTab(index) {80 const tab = this._tabs[index];81 if (!tab)82 throw new Error(`Tab ${index} not found`);83 await tab.page.bringToFront();84 this._currentTab = tab;85 return tab;86 }87 async ensureTab() {88 const { browserContext } = await this._ensureBrowserContext();89 if (!this._currentTab)90 await browserContext.newPage();91 return this._currentTab;92 }93 async closeTab(index) {94 const tab = index === void 0 ? this._currentTab : this._tabs[index];95 if (!tab)96 throw new Error(`Tab ${index} not found`);97 const url = tab.page.url();98 await tab.page.close();99 return url;100 }101 async outputFile(fileName, options) {102 return (0, import_config.outputFile)(this.config, this._clientInfo, fileName, options);103 }104 _onPageCreated(page) {105 const tab = new import_tab.Tab(this, page, (tab2) => this._onPageClosed(tab2));106 this._tabs.push(tab);107 if (!this._currentTab)108 this._currentTab = tab;109 }110 _onPageClosed(tab) {111 const index = this._tabs.indexOf(tab);112 if (index === -1)113 return;114 this._tabs.splice(index, 1);115 if (this._currentTab === tab)116 this._currentTab = this._tabs[Math.min(index, this._tabs.length - 1)];117 if (!this._tabs.length)118 void this.closeBrowserContext();119 }120 async closeBrowserContext() {121 if (!this._closeBrowserContextPromise)122 this._closeBrowserContextPromise = this._closeBrowserContextImpl().catch(import_log.logUnhandledError);123 await this._closeBrowserContextPromise;124 this._closeBrowserContextPromise = void 0;125 }126 isRunningTool() {127 return this._runningToolName !== void 0;128 }129 setRunningTool(name) {130 this._runningToolName = name;131 }132 async _closeBrowserContextImpl() {133 if (!this._browserContextPromise)134 return;135 testDebug("close context");136 const promise = this._browserContextPromise;137 this._browserContextPromise = void 0;138 await promise.then(async ({ browserContext, close }) => {139 if (this.config.saveTrace)140 await browserContext.tracing.stop();141 const videos = this.config.saveVideo ? browserContext.pages().map((page) => page.video()).filter((video) => !!video) : [];142 await close(async () => {143 for (const video of videos) {144 const name = await this.outputFile((0, import_utils.dateAsFileName)("webm"), { origin: "code", reason: "Saving video" });145 await import_fs.default.promises.mkdir(import_path.default.dirname(name), { recursive: true });146 const p = await video.path();147 if (import_fs.default.existsSync(p)) {148 try {149 await import_fs.default.promises.rename(p, name);150 } catch (e) {151 if (e.code !== "EXDEV")152 (0, import_log.logUnhandledError)(e);153 try {154 await import_fs.default.promises.copyFile(p, name);155 await import_fs.default.promises.unlink(p);156 } catch (e2) {157 (0, import_log.logUnhandledError)(e2);158 }159 }160 }161 }162 });163 });164 }165 async dispose() {166 this._abortController.abort("MCP context disposed");167 await this.closeBrowserContext();168 Context._allContexts.delete(this);169 }170 async _setupRequestInterception(context) {171 if (this.config.network?.allowedOrigins?.length) {172 await context.route("**", (route) => route.abort("blockedbyclient"));173 for (const origin of this.config.network.allowedOrigins)174 await context.route(originOrHostGlob(origin), (route) => route.continue());175 }176 if (this.config.network?.blockedOrigins?.length) {177 for (const origin of this.config.network.blockedOrigins)178 await context.route(originOrHostGlob(origin), (route) => route.abort("blockedbyclient"));179 }180 }181 async ensureBrowserContext() {182 const { browserContext } = await this._ensureBrowserContext();183 return browserContext;184 }185 _ensureBrowserContext() {186 if (!this._browserContextPromise) {187 this._browserContextPromise = this._setupBrowserContext();188 this._browserContextPromise.catch(() => {189 this._browserContextPromise = void 0;190 });191 }192 return this._browserContextPromise;193 }194 async _setupBrowserContext() {195 if (this._closeBrowserContextPromise)196 throw new Error("Another browser context is being closed.");197 const result = await this._browserContextFactory.createContext(this._clientInfo, this._abortController.signal, this._runningToolName);198 const { browserContext } = result;199 await this._setupRequestInterception(browserContext);200 if (this.sessionLog)201 await InputRecorder.create(this, browserContext);202 for (const page of browserContext.pages())203 this._onPageCreated(page);204 browserContext.on("page", (page) => this._onPageCreated(page));205 if (this.config.saveTrace) {206 await browserContext.tracing.start({207 name: "trace-" + Date.now(),208 screenshots: true,209 snapshots: true,210 _live: true211 });212 }213 return result;214 }215 lookupSecret(secretName) {216 if (!this.config.secrets?.[secretName])217 return { value: secretName, code: codegen.quote(secretName) };218 return {219 value: this.config.secrets[secretName],220 code: `process.env['${secretName}']`221 };222 }223}224function originOrHostGlob(originOrHost) {225 try {226 const url = new URL(originOrHost);227 if (url.origin !== "null")228 return `${url.origin}/**`;229 } catch {230 }231 return `*://${originOrHost}/**`;232}233class InputRecorder {234 constructor(context, browserContext) {235 this._context = context;236 this._browserContext = browserContext;237 }238 static async create(context, browserContext) {239 const recorder = new InputRecorder(context, browserContext);240 await recorder._initialize();241 return recorder;242 }243 async _initialize() {244 const sessionLog = this._context.sessionLog;245 await this._browserContext._enableRecorder({246 mode: "recording",247 recorderMode: "api"248 }, {249 actionAdded: (page, data, code) => {250 if (this._context.isRunningTool())251 return;252 const tab = import_tab.Tab.forPage(page);253 if (tab)254 sessionLog.logUserAction(data.action, tab, code, false);255 },256 actionUpdated: (page, data, code) => {257 if (this._context.isRunningTool())258 return;259 const tab = import_tab.Tab.forPage(page);260 if (tab)261 sessionLog.logUserAction(data.action, tab, code, true);262 },263 signalAdded: (page, data) => {264 if (this._context.isRunningTool())265 return;266 if (data.signal.name !== "navigation")267 return;268 const tab = import_tab.Tab.forPage(page);269 const navigateAction = {270 name: "navigate",271 url: data.signal.url,272 signals: []273 };274 if (tab)275 sessionLog.logUserAction(navigateAction, tab, `await page.goto('${data.signal.url}');`, false);276 }277 });278 }279}280// Annotate the CommonJS export names for ESM import in node:2810 && (module.exports = {282 Context,283 InputRecorder284});285 