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 mdb_exports = {};30__export(mdb_exports, {31 MDBBackend: () => MDBBackend,32 runMainBackend: () => runMainBackend,33 runOnPauseBackendLoop: () => runOnPauseBackendLoop34});35module.exports = __toCommonJS(mdb_exports);36var import_utilsBundle = require("playwright-core/lib/utilsBundle");37var import_utils = require("playwright-core/lib/utils");38var import_tool = require("./tool");39var mcpBundle = __toESM(require("./bundle"));40var mcpServer = __toESM(require("./server"));41var mcpHttp = __toESM(require("./http"));42const mdbDebug = (0, import_utilsBundle.debug)("pw:mcp:mdb");43const errorsDebug = (0, import_utilsBundle.debug)("pw:mcp:errors");44const z = mcpBundle.z;45class MDBBackend {46 constructor(mainBackend) {47 this._progress = [];48 this._mainBackend = mainBackend;49 this._progressCallback = (params) => {50 if (params.message)51 this._progress.push({ type: "text", text: params.message });52 };53 }54 async initialize(server, clientInfo) {55 if (!this._clientInfo) {56 this._clientInfo = clientInfo;57 await this._mainBackend.initialize?.(server, clientInfo);58 }59 }60 async listTools() {61 return await this._mainBackend.listTools();62 }63 async callTool(name, args) {64 if (name === pushToolsSchema.name) {65 await this._createOnPauseClient(pushToolsSchema.inputSchema.parse(args || {}));66 return { content: [{ type: "text", text: "Tools pushed" }] };67 }68 if (this._onPauseClient?.tools.find((tool) => tool.name === name)) {69 const result2 = await this._onPauseClient.client.callTool({70 name,71 arguments: args72 });73 await this._mainBackend.afterCallTool?.(name, args, result2);74 return result2;75 }76 await this._onPauseClient?.transport.terminateSession().catch(errorsDebug);77 await this._onPauseClient?.client.close().catch(errorsDebug);78 this._onPauseClient = void 0;79 const resultPromise = new import_utils.ManualPromise();80 const interruptPromise = new import_utils.ManualPromise();81 this._interruptPromise = interruptPromise;82 this._mainBackend.callTool(name, args, this._progressCallback).then((result2) => {83 resultPromise.resolve(result2);84 }).catch((e) => {85 resultPromise.resolve({ content: [{ type: "text", text: String(e) }], isError: true });86 });87 const result = await Promise.race([interruptPromise, resultPromise]);88 if (interruptPromise.isDone())89 mdbDebug("client call intercepted", result);90 else91 mdbDebug("client call result", result);92 result.content.unshift(...this._progress);93 this._progress.length = 0;94 return result;95 }96 async _createOnPauseClient(params) {97 if (this._onPauseClient)98 await this._onPauseClient.client.close().catch(errorsDebug);99 this._onPauseClient = await this._createClient(params.mcpUrl);100 this._interruptPromise?.resolve({101 content: [{102 type: "text",103 text: params.introMessage || ""104 }]105 });106 this._interruptPromise = void 0;107 }108 async _createClient(url) {109 const client = new mcpBundle.Client({ name: "Interrupting client", version: "0.0.0" }, { capabilities: { roots: {} } });110 client.setRequestHandler(mcpBundle.ListRootsRequestSchema, () => ({ roots: this._clientInfo?.roots || [] }));111 client.setRequestHandler(mcpBundle.PingRequestSchema, () => ({}));112 client.setNotificationHandler(mcpBundle.ProgressNotificationSchema, (notification) => {113 if (notification.method === "notifications/progress") {114 const { message } = notification.params;115 if (message)116 this._progress.push({ type: "text", text: message });117 }118 });119 const transport = new mcpBundle.StreamableHTTPClientTransport(new URL(url));120 await client.connect(transport);121 const { tools } = await client.listTools();122 return { client, tools, transport };123 }124}125const pushToolsSchema = (0, import_tool.defineToolSchema)({126 name: "mdb_push_tools",127 title: "Push MCP tools to the tools stack",128 description: "Push MCP tools to the tools stack",129 inputSchema: z.object({130 mcpUrl: z.string(),131 introMessage: z.string().optional()132 }),133 type: "readOnly"134});135async function runMainBackend(backendFactory, options) {136 const mdbBackend = new MDBBackend(backendFactory.create());137 const factory = {138 ...backendFactory,139 create: () => mdbBackend140 };141 const url = await startAsHttp(factory, { port: options?.port || 0 });142 process.env.PLAYWRIGHT_DEBUGGER_MCP = url;143 if (options?.port !== void 0)144 return url;145 await mcpServer.connect(factory, new mcpBundle.StdioServerTransport(), false);146}147async function runOnPauseBackendLoop(backend, introMessage) {148 const wrappedBackend = new ServerBackendWithCloseListener(backend);149 const factory = {150 name: "on-pause-backend",151 nameInConfig: "on-pause-backend",152 version: "0.0.0",153 create: () => wrappedBackend154 };155 const httpServer = await mcpHttp.startHttpServer({ port: 0 });156 await mcpHttp.installHttpTransport(httpServer, factory);157 const url = mcpHttp.httpAddressToString(httpServer.address());158 const client = new mcpBundle.Client({ name: "Pushing client", version: "0.0.0" });159 client.setRequestHandler(mcpBundle.PingRequestSchema, () => ({}));160 const transport = new mcpBundle.StreamableHTTPClientTransport(new URL(process.env.PLAYWRIGHT_DEBUGGER_MCP));161 await client.connect(transport);162 const pushToolsResult = await client.callTool({163 name: pushToolsSchema.name,164 arguments: {165 mcpUrl: url,166 introMessage167 }168 });169 if (pushToolsResult.isError)170 errorsDebug("Failed to push tools", pushToolsResult.content);171 await transport.terminateSession();172 await client.close();173 await wrappedBackend.waitForClosed();174 httpServer.close();175}176async function startAsHttp(backendFactory, options) {177 const httpServer = await mcpHttp.startHttpServer(options);178 await mcpHttp.installHttpTransport(httpServer, backendFactory);179 return mcpHttp.httpAddressToString(httpServer.address());180}181class ServerBackendWithCloseListener {182 constructor(backend) {183 this._serverClosedPromise = new import_utils.ManualPromise();184 this._backend = backend;185 }186 async initialize(server, clientInfo) {187 await this._backend.initialize?.(server, clientInfo);188 }189 async listTools() {190 return this._backend.listTools();191 }192 async callTool(name, args, progress) {193 return this._backend.callTool(name, args, progress);194 }195 serverClosed(server) {196 this._backend.serverClosed?.(server);197 this._serverClosedPromise.resolve();198 }199 async waitForClosed() {200 await this._serverClosedPromise;201 }202}203// Annotate the CommonJS export names for ESM import in node:2040 && (module.exports = {205 MDBBackend,206 runMainBackend,207 runOnPauseBackendLoop208});209 