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 tracing_exports = {};30__export(tracing_exports, {31 Tracing: () => Tracing32});33module.exports = __toCommonJS(tracing_exports);34var import_fs = __toESM(require("fs"));35var import_os = __toESM(require("os"));36var import_path = __toESM(require("path"));37var import_snapshotter = require("./snapshotter");38var import_protocolMetainfo = require("../../../utils/isomorphic/protocolMetainfo");39var import_assert = require("../../../utils/isomorphic/assert");40var import_time = require("../../../utils/isomorphic/time");41var import_eventsHelper = require("../../utils/eventsHelper");42var import_crypto = require("../../utils/crypto");43var import_artifact = require("../../artifact");44var import_browserContext = require("../../browserContext");45var import_dispatcher = require("../../dispatchers/dispatcher");46var import_errors = require("../../errors");47var import_fileUtils = require("../../utils/fileUtils");48var import_harTracer = require("../../har/harTracer");49var import_instrumentation = require("../../instrumentation");50var import_page = require("../../page");51var import_progress = require("../../progress");52const version = 8;53const kScreencastOptions = { width: 800, height: 600, quality: 90 };54class Tracing extends import_instrumentation.SdkObject {55 constructor(context, tracesDir) {56 super(context, "tracing");57 this._fs = new import_fileUtils.SerializedFS();58 this._screencastListeners = [];59 this._eventListeners = [];60 this._isStopping = false;61 this._allResources = /* @__PURE__ */ new Set();62 this._pendingHarEntries = /* @__PURE__ */ new Set();63 this._context = context;64 this._precreatedTracesDir = tracesDir;65 this._harTracer = new import_harTracer.HarTracer(context, null, this, {66 content: "attach",67 includeTraceInfo: true,68 recordRequestOverrides: false,69 waitForContentOnStop: false70 });71 const testIdAttributeName = "selectors" in context ? context.selectors().testIdAttributeName() : void 0;72 this._contextCreatedEvent = {73 version,74 type: "context-options",75 origin: "library",76 browserName: "",77 options: {},78 platform: process.platform,79 wallTime: 0,80 monotonicTime: 0,81 sdkLanguage: this._sdkLanguage(),82 testIdAttributeName,83 contextId: context.guid84 };85 if (context instanceof import_browserContext.BrowserContext) {86 this._snapshotter = new import_snapshotter.Snapshotter(context, this);87 (0, import_assert.assert)(tracesDir, "tracesDir must be specified for BrowserContext");88 this._contextCreatedEvent.browserName = context._browser.options.name;89 this._contextCreatedEvent.channel = context._browser.options.channel;90 this._contextCreatedEvent.options = context._options;91 }92 }93 _sdkLanguage() {94 return this._context instanceof import_browserContext.BrowserContext ? this._context._browser.sdkLanguage() : this._context.attribution.playwright.options.sdkLanguage;95 }96 async resetForReuse(progress) {97 await this.stopChunk(progress, { mode: "discard" }).catch(() => {98 });99 await this.stop(progress);100 if (this._snapshotter)101 await progress.race(this._snapshotter.resetForReuse());102 }103 start(options) {104 if (this._isStopping)105 throw new Error("Cannot start tracing while stopping");106 if (this._state)107 throw new Error("Tracing has been already started");108 this._contextCreatedEvent.sdkLanguage = this._sdkLanguage();109 const traceName = options.name || (0, import_crypto.createGuid)();110 const tracesDir = this._createTracesDirIfNeeded();111 this._state = {112 options,113 traceName,114 tracesDir,115 traceFile: import_path.default.join(tracesDir, traceName + ".trace"),116 networkFile: import_path.default.join(tracesDir, traceName + ".network"),117 resourcesDir: import_path.default.join(tracesDir, "resources"),118 chunkOrdinal: 0,119 traceSha1s: /* @__PURE__ */ new Set(),120 networkSha1s: /* @__PURE__ */ new Set(),121 recording: false,122 callIds: /* @__PURE__ */ new Set(),123 groupStack: []124 };125 this._fs.mkdir(this._state.resourcesDir);126 this._fs.writeFile(this._state.networkFile, "");127 if (options.snapshots)128 this._harTracer.start({ omitScripts: !options.live });129 }130 async startChunk(progress, options = {}) {131 if (this._state && this._state.recording)132 await this.stopChunk(progress, { mode: "discard" });133 if (!this._state)134 throw new Error("Must start tracing before starting a new chunk");135 if (this._isStopping)136 throw new Error("Cannot start a trace chunk while stopping");137 this._state.recording = true;138 this._state.callIds.clear();139 const preserveNetworkResources = this._context instanceof import_browserContext.BrowserContext;140 if (options.name && options.name !== this._state.traceName)141 this._changeTraceName(this._state, options.name, preserveNetworkResources);142 else143 this._allocateNewTraceFile(this._state);144 if (!preserveNetworkResources)145 this._fs.writeFile(this._state.networkFile, "");146 this._fs.mkdir(import_path.default.dirname(this._state.traceFile));147 const event = {148 ...this._contextCreatedEvent,149 title: options.title,150 wallTime: Date.now(),151 monotonicTime: (0, import_time.monotonicTime)()152 };153 this._appendTraceEvent(event);154 this._context.instrumentation.addListener(this, this._context);155 this._eventListeners.push(156 import_eventsHelper.eventsHelper.addEventListener(this._context, import_browserContext.BrowserContext.Events.Console, this._onConsoleMessage.bind(this)),157 import_eventsHelper.eventsHelper.addEventListener(this._context, import_browserContext.BrowserContext.Events.PageError, this._onPageError.bind(this))158 );159 if (this._state.options.screenshots)160 this._startScreencast();161 if (this._state.options.snapshots)162 await this._snapshotter?.start();163 return { traceName: this._state.traceName };164 }165 _currentGroupId() {166 return this._state?.groupStack.length ? this._state.groupStack[this._state.groupStack.length - 1] : void 0;167 }168 group(name, location, metadata) {169 if (!this._state)170 return;171 const stackFrames = [];172 const { file, line, column } = location ?? metadata.location ?? {};173 if (file) {174 stackFrames.push({175 file,176 line: line ?? 0,177 column: column ?? 0178 });179 }180 const event = {181 type: "before",182 callId: metadata.id,183 startTime: metadata.startTime,184 title: name,185 class: "Tracing",186 method: "tracingGroup",187 params: {},188 stepId: metadata.stepId,189 stack: stackFrames190 };191 if (this._currentGroupId())192 event.parentId = this._currentGroupId();193 this._state.groupStack.push(event.callId);194 this._appendTraceEvent(event);195 }196 groupEnd() {197 if (!this._state)198 return;199 const callId = this._state.groupStack.pop();200 if (!callId)201 return;202 const event = {203 type: "after",204 callId,205 endTime: (0, import_time.monotonicTime)()206 };207 this._appendTraceEvent(event);208 }209 _startScreencast() {210 if (!(this._context instanceof import_browserContext.BrowserContext))211 return;212 for (const page of this._context.pages())213 this._startScreencastInPage(page);214 this._screencastListeners.push(215 import_eventsHelper.eventsHelper.addEventListener(this._context, import_browserContext.BrowserContext.Events.Page, this._startScreencastInPage.bind(this))216 );217 }218 _stopScreencast() {219 import_eventsHelper.eventsHelper.removeEventListeners(this._screencastListeners);220 if (!(this._context instanceof import_browserContext.BrowserContext))221 return;222 for (const page of this._context.pages())223 page.setScreencastOptions(null);224 }225 _allocateNewTraceFile(state) {226 const suffix = state.chunkOrdinal ? `-chunk${state.chunkOrdinal}` : ``;227 state.chunkOrdinal++;228 state.traceFile = import_path.default.join(state.tracesDir, `${state.traceName}${suffix}.trace`);229 }230 _changeTraceName(state, name, preserveNetworkResources) {231 state.traceName = name;232 state.chunkOrdinal = 0;233 this._allocateNewTraceFile(state);234 const newNetworkFile = import_path.default.join(state.tracesDir, name + ".network");235 if (preserveNetworkResources)236 this._fs.copyFile(state.networkFile, newNetworkFile);237 state.networkFile = newNetworkFile;238 }239 async stop(progress) {240 if (!this._state)241 return;242 if (this._isStopping)243 throw new Error(`Tracing is already stopping`);244 if (this._state.recording)245 throw new Error(`Must stop trace file before stopping tracing`);246 this._closeAllGroups();247 this._harTracer.stop();248 this.flushHarEntries();249 const promise = progress ? progress.race(this._fs.syncAndGetError()) : this._fs.syncAndGetError();250 await promise.finally(() => {251 this._state = void 0;252 });253 }254 async deleteTmpTracesDir() {255 if (this._tracesTmpDir)256 await (0, import_fileUtils.removeFolders)([this._tracesTmpDir]);257 }258 _createTracesDirIfNeeded() {259 if (this._precreatedTracesDir)260 return this._precreatedTracesDir;261 this._tracesTmpDir = import_fs.default.mkdtempSync(import_path.default.join(import_os.default.tmpdir(), "playwright-tracing-"));262 return this._tracesTmpDir;263 }264 abort() {265 this._snapshotter?.dispose();266 this._harTracer.stop();267 }268 async flush() {269 this.abort();270 await this._fs.syncAndGetError();271 }272 _closeAllGroups() {273 while (this._currentGroupId())274 this.groupEnd();275 }276 async stopChunk(progress, params) {277 if (this._isStopping)278 throw new Error(`Tracing is already stopping`);279 this._isStopping = true;280 if (!this._state || !this._state.recording) {281 this._isStopping = false;282 if (params.mode !== "discard")283 throw new Error(`Must start tracing before stopping`);284 return {};285 }286 this._closeAllGroups();287 this._context.instrumentation.removeListener(this);288 import_eventsHelper.eventsHelper.removeEventListeners(this._eventListeners);289 if (this._state.options.screenshots)290 this._stopScreencast();291 if (this._state.options.snapshots)292 this._snapshotter?.stop();293 this.flushHarEntries();294 const newNetworkFile = import_path.default.join(this._state.tracesDir, this._state.traceName + `-pwnetcopy-${this._state.chunkOrdinal}.network`);295 const entries = [];296 entries.push({ name: "trace.trace", value: this._state.traceFile });297 entries.push({ name: "trace.network", value: newNetworkFile });298 for (const sha1 of /* @__PURE__ */ new Set([...this._state.traceSha1s, ...this._state.networkSha1s]))299 entries.push({ name: import_path.default.join("resources", sha1), value: import_path.default.join(this._state.resourcesDir, sha1) });300 this._state.traceSha1s = /* @__PURE__ */ new Set();301 if (params.mode === "discard") {302 this._isStopping = false;303 this._state.recording = false;304 return {};305 }306 this._fs.copyFile(this._state.networkFile, newNetworkFile);307 const zipFileName = this._state.traceFile + ".zip";308 if (params.mode === "archive")309 this._fs.zip(entries, zipFileName);310 const promise = progress ? progress.race(this._fs.syncAndGetError()) : this._fs.syncAndGetError();311 const error = await promise.catch((e) => e);312 this._isStopping = false;313 if (this._state)314 this._state.recording = false;315 if (error) {316 if (!(0, import_progress.isAbortError)(error) && this._context instanceof import_browserContext.BrowserContext && !this._context._browser.isConnected())317 return {};318 throw error;319 }320 if (params.mode === "entries")321 return { entries };322 const artifact = new import_artifact.Artifact(this._context, zipFileName);323 artifact.reportFinished();324 return { artifact };325 }326 async _captureSnapshot(snapshotName, sdkObject, metadata) {327 if (!this._snapshotter)328 return;329 if (!sdkObject.attribution.page)330 return;331 if (!this._snapshotter.started())332 return;333 if (!shouldCaptureSnapshot(metadata))334 return;335 await this._snapshotter.captureSnapshot(sdkObject.attribution.page, metadata.id, snapshotName).catch(() => {336 });337 }338 onBeforeCall(sdkObject, metadata) {339 const event = createBeforeActionTraceEvent(metadata, this._currentGroupId());340 if (!event)341 return Promise.resolve();342 sdkObject.attribution.page?.temporarilyDisableTracingScreencastThrottling();343 event.beforeSnapshot = `before@${metadata.id}`;344 this._state?.callIds.add(metadata.id);345 this._appendTraceEvent(event);346 return this._captureSnapshot(event.beforeSnapshot, sdkObject, metadata);347 }348 onBeforeInputAction(sdkObject, metadata) {349 if (!this._state?.callIds.has(metadata.id))350 return Promise.resolve();351 const event = createInputActionTraceEvent(metadata);352 if (!event)353 return Promise.resolve();354 sdkObject.attribution.page?.temporarilyDisableTracingScreencastThrottling();355 event.inputSnapshot = `input@${metadata.id}`;356 this._appendTraceEvent(event);357 return this._captureSnapshot(event.inputSnapshot, sdkObject, metadata);358 }359 onCallLog(sdkObject, metadata, logName, message) {360 if (!this._state?.callIds.has(metadata.id))361 return;362 if (metadata.internal)363 return;364 if (logName !== "api")365 return;366 const event = createActionLogTraceEvent(metadata, message);367 if (event)368 this._appendTraceEvent(event);369 }370 async onAfterCall(sdkObject, metadata) {371 if (!this._state?.callIds.has(metadata.id))372 return;373 this._state?.callIds.delete(metadata.id);374 const event = createAfterActionTraceEvent(metadata);375 if (!event)376 return;377 sdkObject.attribution.page?.temporarilyDisableTracingScreencastThrottling();378 event.afterSnapshot = `after@${metadata.id}`;379 this._appendTraceEvent(event);380 return this._captureSnapshot(event.afterSnapshot, sdkObject, metadata);381 }382 onEntryStarted(entry) {383 this._pendingHarEntries.add(entry);384 }385 onEntryFinished(entry) {386 this._pendingHarEntries.delete(entry);387 const event = { type: "resource-snapshot", snapshot: entry };388 const visited = visitTraceEvent(event, this._state.networkSha1s);389 this._fs.appendFile(390 this._state.networkFile,391 JSON.stringify(visited) + "\n",392 true393 /* flush */394 );395 }396 flushHarEntries() {397 const harLines = [];398 for (const entry of this._pendingHarEntries) {399 const event = { type: "resource-snapshot", snapshot: entry };400 const visited = visitTraceEvent(event, this._state.networkSha1s);401 harLines.push(JSON.stringify(visited));402 }403 this._pendingHarEntries.clear();404 if (harLines.length)405 this._fs.appendFile(406 this._state.networkFile,407 harLines.join("\n") + "\n",408 true409 /* flush */410 );411 }412 onContentBlob(sha1, buffer) {413 this._appendResource(sha1, buffer);414 }415 onSnapshotterBlob(blob) {416 this._appendResource(blob.sha1, blob.buffer);417 }418 onFrameSnapshot(snapshot) {419 this._appendTraceEvent({ type: "frame-snapshot", snapshot });420 }421 _onConsoleMessage(message) {422 const event = {423 type: "console",424 messageType: message.type(),425 text: message.text(),426 args: message.args().map((a) => ({ preview: a.toString(), value: a.rawValue() })),427 location: message.location(),428 time: (0, import_time.monotonicTime)(),429 pageId: message.page()?.guid430 };431 this._appendTraceEvent(event);432 }433 onDialog(dialog) {434 const event = {435 type: "event",436 time: (0, import_time.monotonicTime)(),437 class: "BrowserContext",438 method: "dialog",439 params: { pageId: dialog.page().guid, type: dialog.type(), message: dialog.message(), defaultValue: dialog.defaultValue() }440 };441 this._appendTraceEvent(event);442 }443 onDownload(page, download) {444 const event = {445 type: "event",446 time: (0, import_time.monotonicTime)(),447 class: "BrowserContext",448 method: "download",449 params: { pageId: page.guid, url: download.url, suggestedFilename: download.suggestedFilename() }450 };451 this._appendTraceEvent(event);452 }453 onPageOpen(page) {454 const event = {455 type: "event",456 time: (0, import_time.monotonicTime)(),457 class: "BrowserContext",458 method: "page",459 params: { pageId: page.guid, openerPageId: page.opener()?.guid }460 };461 this._appendTraceEvent(event);462 }463 onPageClose(page) {464 const event = {465 type: "event",466 time: (0, import_time.monotonicTime)(),467 class: "BrowserContext",468 method: "pageClosed",469 params: { pageId: page.guid }470 };471 this._appendTraceEvent(event);472 }473 _onPageError(error, page) {474 const event = {475 type: "event",476 time: (0, import_time.monotonicTime)(),477 class: "BrowserContext",478 method: "pageError",479 params: { error: (0, import_errors.serializeError)(error) },480 pageId: page.guid481 };482 this._appendTraceEvent(event);483 }484 _startScreencastInPage(page) {485 page.setScreencastOptions(kScreencastOptions);486 const prefix = page.guid;487 this._screencastListeners.push(488 import_eventsHelper.eventsHelper.addEventListener(page, import_page.Page.Events.ScreencastFrame, (params) => {489 const suffix = params.timestamp || Date.now();490 const sha1 = `${prefix}-${suffix}.jpeg`;491 const event = {492 type: "screencast-frame",493 pageId: page.guid,494 sha1,495 width: params.width,496 height: params.height,497 timestamp: (0, import_time.monotonicTime)(),498 frameSwapWallTime: params.frameSwapWallTime499 };500 this._appendResource(sha1, params.buffer);501 this._appendTraceEvent(event);502 })503 );504 }505 _appendTraceEvent(event) {506 const visited = visitTraceEvent(event, this._state.traceSha1s);507 const flush = this._state.options.live || event.type !== "event" && event.type !== "console" && event.type !== "log";508 this._fs.appendFile(this._state.traceFile, JSON.stringify(visited) + "\n", flush);509 }510 _appendResource(sha1, buffer) {511 if (this._allResources.has(sha1))512 return;513 this._allResources.add(sha1);514 const resourcePath = import_path.default.join(this._state.resourcesDir, sha1);515 this._fs.writeFile(516 resourcePath,517 buffer,518 true519 /* skipIfExists */520 );521 }522}523function visitTraceEvent(object, sha1s) {524 if (Array.isArray(object))525 return object.map((o) => visitTraceEvent(o, sha1s));526 if (object instanceof import_dispatcher.Dispatcher)527 return `<${object._type}>`;528 if (object instanceof Buffer)529 return `<Buffer>`;530 if (object instanceof Date)531 return object;532 if (typeof object === "object") {533 const result = {};534 for (const key in object) {535 if (key === "sha1" || key === "_sha1" || key.endsWith("Sha1")) {536 const sha1 = object[key];537 if (sha1)538 sha1s.add(sha1);539 }540 result[key] = visitTraceEvent(object[key], sha1s);541 }542 return result;543 }544 return object;545}546function shouldCaptureSnapshot(metadata) {547 const metainfo = import_protocolMetainfo.methodMetainfo.get(metadata.type + "." + metadata.method);548 return !!metainfo?.snapshot;549}550function createBeforeActionTraceEvent(metadata, parentId) {551 if (metadata.internal || metadata.method.startsWith("tracing"))552 return null;553 const event = {554 type: "before",555 callId: metadata.id,556 startTime: metadata.startTime,557 title: metadata.title,558 class: metadata.type,559 method: metadata.method,560 params: metadata.params,561 stepId: metadata.stepId,562 pageId: metadata.pageId563 };564 if (parentId)565 event.parentId = parentId;566 return event;567}568function createInputActionTraceEvent(metadata) {569 if (metadata.internal || metadata.method.startsWith("tracing"))570 return null;571 return {572 type: "input",573 callId: metadata.id,574 point: metadata.point575 };576}577function createActionLogTraceEvent(metadata, message) {578 if (metadata.internal || metadata.method.startsWith("tracing"))579 return null;580 return {581 type: "log",582 callId: metadata.id,583 time: (0, import_time.monotonicTime)(),584 message585 };586}587function createAfterActionTraceEvent(metadata) {588 if (metadata.internal || metadata.method.startsWith("tracing"))589 return null;590 return {591 type: "after",592 callId: metadata.id,593 endTime: metadata.endTime,594 error: metadata.error?.error,595 result: metadata.result,596 point: metadata.point597 };598}599// Annotate the CommonJS export names for ESM import in node:6000 && (module.exports = {601 Tracing602});603 