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
recorder.js499 linesDownload Raw Back to server
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 recorder_exports = {};30__export(recorder_exports, {31  Recorder: () => Recorder,32  RecorderEvent: () => RecorderEvent33});34module.exports = __toCommonJS(recorder_exports);35var import_events = __toESM(require("events"));36var import_fs = __toESM(require("fs"));37var import_utils = require("../utils");38var import_browserContext = require("./browserContext");39var import_debugger = require("./debugger");40var import_recorderUtils = require("./recorder/recorderUtils");41var import_locatorParser = require("../utils/isomorphic/locatorParser");42var import_selectorParser = require("../utils/isomorphic/selectorParser");43var import_progress = require("./progress");44var import_recorderSignalProcessor = require("./recorder/recorderSignalProcessor");45var rawRecorderSource = __toESM(require("./../generated/pollingRecorderSource"));46var import_utils2 = require("./../utils");47var import_frames = require("./frames");48var import_page = require("./page");49var import_recorderRunner = require("./recorder/recorderRunner");50const recorderSymbol = Symbol("recorderSymbol");51const RecorderEvent = {52  PausedStateChanged: "pausedStateChanged",53  ModeChanged: "modeChanged",54  ElementPicked: "elementPicked",55  CallLogsUpdated: "callLogsUpdated",56  UserSourcesChanged: "userSourcesChanged",57  ActionAdded: "actionAdded",58  SignalAdded: "signalAdded",59  PageNavigated: "pageNavigated",60  ContextClosed: "contextClosed"61};62class Recorder extends import_events.default {63  constructor(context, params) {64    super();65    this._highlightedElement = {};66    this._overlayState = { offsetX: 0 };67    this._currentCallsMetadata = /* @__PURE__ */ new Map();68    this._userSources = /* @__PURE__ */ new Map();69    this._omitCallTracking = false;70    this._currentLanguage = "javascript";71    this._pageAliases = /* @__PURE__ */ new Map();72    this._lastPopupOrdinal = 0;73    this._lastDialogOrdinal = -1;74    this._lastDownloadOrdinal = -1;75    this._listeners = [];76    this._enabled = false;77    this._callLogs = [];78    this._context = context;79    this._params = params;80    this._mode = params.mode || "none";81    this._recorderMode = params.recorderMode ?? "default";82    this.handleSIGINT = params.handleSIGINT;83    this._signalProcessor = new import_recorderSignalProcessor.RecorderSignalProcessor({84      addAction: (actionInContext) => {85        if (this._enabled)86          this.emit(RecorderEvent.ActionAdded, actionInContext);87      },88      addSignal: (signal) => {89        if (this._enabled)90          this.emit(RecorderEvent.SignalAdded, signal);91      }92    });93    context.on(import_browserContext.BrowserContext.Events.BeforeClose, () => {94      this.emit(RecorderEvent.ContextClosed);95    });96    this._listeners.push(import_utils2.eventsHelper.addEventListener(process, "exit", () => {97      this.emit(RecorderEvent.ContextClosed);98    }));99    this._setEnabled(params.mode === "recording");100    this._omitCallTracking = !!params.omitCallTracking;101    this._debugger = context.debugger();102    context.instrumentation.addListener(this, context);103    if ((0, import_utils.isUnderTest)()) {104      this._overlayState.offsetX = 200;105    }106  }107  static forContext(context, params) {108    let recorderPromise = context[recorderSymbol];109    if (!recorderPromise) {110      recorderPromise = Recorder._create(context, params);111      context[recorderSymbol] = recorderPromise;112    }113    return recorderPromise;114  }115  static existingForContext(context) {116    return context[recorderSymbol];117  }118  static async _create(context, params = {}) {119    const recorder = new Recorder(context, params);120    await recorder._install();121    return recorder;122  }123  async _install() {124    this.emit(RecorderEvent.ModeChanged, this._mode);125    this.emit(RecorderEvent.PausedStateChanged, this._debugger.isPaused());126    this._context.once(import_browserContext.BrowserContext.Events.Close, () => {127      import_utils2.eventsHelper.removeEventListeners(this._listeners);128      this._context.instrumentation.removeListener(this);129      this.emit(RecorderEvent.ContextClosed);130    });131    const controller = new import_progress.ProgressController();132    await controller.run(async (progress) => {133      await this._context.exposeBinding(progress, "__pw_recorderState", false, async (source) => {134        let actionSelector;135        let actionPoint;136        const hasActiveScreenshotCommand = [...this._currentCallsMetadata.keys()].some(isScreenshotCommand);137        if (!hasActiveScreenshotCommand) {138          actionSelector = await this._scopeHighlightedSelectorToFrame(source.frame);139          for (const [metadata, sdkObject] of this._currentCallsMetadata) {140            if (source.page === sdkObject.attribution.page) {141              actionPoint = metadata.point || actionPoint;142              actionSelector = actionSelector || metadata.params.selector;143            }144          }145        }146        const uiState = {147          mode: this._mode,148          actionPoint,149          actionSelector,150          ariaTemplate: this._highlightedElement.ariaTemplate,151          language: this._currentLanguage,152          testIdAttributeName: this._testIdAttributeName(),153          overlay: this._overlayState154        };155        return uiState;156      });157      await this._context.exposeBinding(progress, "__pw_recorderElementPicked", false, async ({ frame }, elementInfo) => {158        const selectorChain = await (0, import_recorderUtils.generateFrameSelector)(frame);159        this.emit(RecorderEvent.ElementPicked, { selector: (0, import_recorderUtils.buildFullSelector)(selectorChain, elementInfo.selector), ariaSnapshot: elementInfo.ariaSnapshot }, true);160      });161      await this._context.exposeBinding(progress, "__pw_recorderSetMode", false, async ({ frame }, mode) => {162        if (frame.parentFrame())163          return;164        this.setMode(mode);165      });166      await this._context.exposeBinding(progress, "__pw_recorderSetOverlayState", false, async ({ frame }, state) => {167        if (frame.parentFrame())168          return;169        this._overlayState = state;170      });171      await this._context.exposeBinding(progress, "__pw_resume", false, () => {172        this._debugger.resume(false);173      });174      this._context.on(import_browserContext.BrowserContext.Events.Page, (page) => this._onPage(page));175      for (const page of this._context.pages())176        this._onPage(page);177      this._context.dialogManager.addDialogHandler((dialog) => {178        this._onDialog(dialog.page());179        return false;180      });181      await this._context.exposeBinding(182        progress,183        "__pw_recorderPerformAction",184        false,185        (source, action) => this._performAction(source.frame, action)186      );187      await this._context.exposeBinding(188        progress,189        "__pw_recorderRecordAction",190        false,191        (source, action) => this._recordAction(source.frame, action)192      );193      await this._context.extendInjectedScript(rawRecorderSource.source, { recorderMode: this._recorderMode });194    });195    if (this._debugger.isPaused())196      this._pausedStateChanged();197    this._debugger.on(import_debugger.Debugger.Events.PausedStateChanged, () => this._pausedStateChanged());198  }199  _pausedStateChanged() {200    for (const { metadata, sdkObject } of this._debugger.pausedDetails()) {201      if (!this._currentCallsMetadata.has(metadata))202        this.onBeforeCall(sdkObject, metadata);203    }204    this.emit(RecorderEvent.PausedStateChanged, this._debugger.isPaused());205    this._updateUserSources();206    this.updateCallLog([...this._currentCallsMetadata.keys()]);207  }208  mode() {209    return this._mode;210  }211  setMode(mode) {212    if (this._mode === mode)213      return;214    this._highlightedElement = {};215    this._mode = mode;216    this.emit(RecorderEvent.ModeChanged, this._mode);217    this._setEnabled(this._isRecording());218    this._debugger.setMuted(this._isRecording());219    if (this._mode !== "none" && this._mode !== "standby" && this._context.pages().length === 1)220      this._context.pages()[0].bringToFront().catch(() => {221      });222    this._refreshOverlay();223  }224  url() {225    const page = this._context.pages()[0];226    return page?.mainFrame().url();227  }228  setHighlightedSelector(selector) {229    this._highlightedElement = { selector: (0, import_locatorParser.locatorOrSelectorAsSelector)(this._currentLanguage, selector, this._context.selectors().testIdAttributeName()) };230    this._refreshOverlay();231  }232  setHighlightedAriaTemplate(ariaTemplate) {233    this._highlightedElement = { ariaTemplate };234    this._refreshOverlay();235  }236  step() {237    this._debugger.resume(true);238  }239  setLanguage(language) {240    this._currentLanguage = language;241    this._refreshOverlay();242  }243  resume() {244    this._debugger.resume(false);245  }246  pause() {247    this._debugger.pauseOnNextStatement();248  }249  paused() {250    return this._debugger.isPaused();251  }252  close() {253    this._debugger.resume(false);254  }255  hideHighlightedSelector() {256    this._highlightedElement = {};257    this._refreshOverlay();258  }259  pausedSourceId() {260    for (const { metadata } of this._debugger.pausedDetails()) {261      if (!metadata.location)262        continue;263      const source = this._userSources.get(metadata.location.file);264      if (!source)265        continue;266      return source.id;267    }268  }269  userSources() {270    return [...this._userSources.values()];271  }272  callLog() {273    return this._callLogs;274  }275  async _scopeHighlightedSelectorToFrame(frame) {276    if (!this._highlightedElement.selector)277      return;278    try {279      const mainFrame = frame._page.mainFrame();280      const resolved = await mainFrame.selectors.resolveFrameForSelector(this._highlightedElement.selector);281      if (!resolved)282        return "";283      if (resolved?.frame === mainFrame)284        return (0, import_selectorParser.stringifySelector)(resolved.info.parsed);285      if (resolved?.frame === frame)286        return (0, import_selectorParser.stringifySelector)(resolved.info.parsed);287      return "";288    } catch {289      return "";290    }291  }292  _refreshOverlay() {293    for (const page of this._context.pages()) {294      for (const frame of page.frames())295        frame.evaluateExpression("window.__pw_refreshOverlay()").catch(() => {296        });297    }298  }299  async onBeforeCall(sdkObject, metadata) {300    if (this._omitCallTracking || this._isRecording())301      return;302    this._currentCallsMetadata.set(metadata, sdkObject);303    this._updateUserSources();304    this.updateCallLog([metadata]);305    if (isScreenshotCommand(metadata))306      this.hideHighlightedSelector();307    else if (metadata.params && metadata.params.selector)308      this._highlightedElement = { selector: metadata.params.selector };309  }310  async onAfterCall(sdkObject, metadata) {311    if (this._omitCallTracking || this._isRecording())312      return;313    if (!metadata.error)314      this._currentCallsMetadata.delete(metadata);315    this._updateUserSources();316    this.updateCallLog([metadata]);317  }318  _updateUserSources() {319    for (const source of this._userSources.values()) {320      source.highlight = [];321      source.revealLine = void 0;322    }323    for (const metadata of this._currentCallsMetadata.keys()) {324      if (!metadata.location)325        continue;326      const { file, line } = metadata.location;327      let source = this._userSources.get(file);328      if (!source) {329        source = { isRecorded: false, label: file, id: file, text: this._readSource(file), highlight: [], language: languageForFile(file) };330        this._userSources.set(file, source);331      }332      if (line) {333        const paused = this._debugger.isPaused(metadata);334        source.highlight.push({ line, type: metadata.error ? "error" : paused ? "paused" : "running" });335        source.revealLine = line;336      }337    }338    this.emit(RecorderEvent.UserSourcesChanged, this.userSources(), this.pausedSourceId());339  }340  async onBeforeInputAction(sdkObject, metadata) {341  }342  async onCallLog(sdkObject, metadata, logName, message) {343    this.updateCallLog([metadata]);344  }345  updateCallLog(metadatas) {346    if (this._isRecording())347      return;348    const logs = [];349    for (const metadata of metadatas) {350      if (!metadata.method || metadata.internal)351        continue;352      let status = "done";353      if (this._currentCallsMetadata.has(metadata))354        status = "in-progress";355      if (this._debugger.isPaused(metadata))356        status = "paused";357      logs.push((0, import_recorderUtils.metadataToCallLog)(metadata, status));358    }359    this._callLogs = logs;360    this.emit(RecorderEvent.CallLogsUpdated, logs);361  }362  _isRecording() {363    return ["recording", "assertingText", "assertingVisibility", "assertingValue", "assertingSnapshot"].includes(this._mode);364  }365  _readSource(fileName) {366    try {367      return import_fs.default.readFileSync(fileName, "utf-8");368    } catch (e) {369      return "// No source available";370    }371  }372  _setEnabled(enabled) {373    this._enabled = enabled;374  }375  async _onPage(page) {376    const frame = page.mainFrame();377    page.on(import_page.Page.Events.Close, () => {378      this._signalProcessor.addAction({379        frame: this._describeMainFrame(page),380        action: {381          name: "closePage",382          signals: []383        },384        startTime: (0, import_utils2.monotonicTime)()385      });386      this._pageAliases.delete(page);387      this._filePrimaryURLChanged();388    });389    frame.on(import_frames.Frame.Events.InternalNavigation, (event) => {390      if (event.isPublic) {391        this._onFrameNavigated(frame, page);392        this._filePrimaryURLChanged();393      }394    });395    page.on(import_page.Page.Events.Download, () => this._onDownload(page));396    const suffix = this._pageAliases.size ? String(++this._lastPopupOrdinal) : "";397    const pageAlias = "page" + suffix;398    this._pageAliases.set(page, pageAlias);399    if (page.opener()) {400      this._onPopup(page.opener(), page);401    } else {402      this._signalProcessor.addAction({403        frame: this._describeMainFrame(page),404        action: {405          name: "openPage",406          url: page.mainFrame().url(),407          signals: []408        },409        startTime: (0, import_utils2.monotonicTime)()410      });411    }412    this._filePrimaryURLChanged();413  }414  _filePrimaryURLChanged() {415    const page = this._context.pages()[0];416    this.emit(RecorderEvent.PageNavigated, page?.mainFrame().url());417  }418  clear() {419    if (this._params.mode === "recording") {420      for (const page of this._context.pages())421        this._onFrameNavigated(page.mainFrame(), page);422    }423  }424  _describeMainFrame(page) {425    return {426      pageGuid: page.guid,427      pageAlias: this._pageAliases.get(page),428      framePath: []429    };430  }431  async _describeFrame(frame) {432    return {433      pageGuid: frame._page.guid,434      pageAlias: this._pageAliases.get(frame._page),435      framePath: await (0, import_recorderUtils.generateFrameSelector)(frame)436    };437  }438  _testIdAttributeName() {439    return this._params.testIdAttributeName || this._context.selectors().testIdAttributeName() || "data-testid";440  }441  async _createActionInContext(frame, action) {442    const frameDescription = await this._describeFrame(frame);443    const actionInContext = {444      frame: frameDescription,445      action,446      description: void 0,447      startTime: (0, import_utils2.monotonicTime)()448    };449    return actionInContext;450  }451  async _performAction(frame, action) {452    const actionInContext = await this._createActionInContext(frame, action);453    this._signalProcessor.addAction(actionInContext);454    if (actionInContext.action.name !== "openPage" && actionInContext.action.name !== "closePage")455      await (0, import_recorderRunner.performAction)(this._pageAliases, actionInContext);456    actionInContext.endTime = (0, import_utils2.monotonicTime)();457  }458  async _recordAction(frame, action) {459    const actionInContext = await this._createActionInContext(frame, action);460    this._signalProcessor.addAction(actionInContext);461  }462  _onFrameNavigated(frame, page) {463    const pageAlias = this._pageAliases.get(page);464    this._signalProcessor.signal(pageAlias, frame, { name: "navigation", url: frame.url() });465  }466  _onPopup(page, popup) {467    const pageAlias = this._pageAliases.get(page);468    const popupAlias = this._pageAliases.get(popup);469    this._signalProcessor.signal(pageAlias, page.mainFrame(), { name: "popup", popupAlias });470  }471  _onDownload(page) {472    const pageAlias = this._pageAliases.get(page);473    ++this._lastDownloadOrdinal;474    this._signalProcessor.signal(pageAlias, page.mainFrame(), { name: "download", downloadAlias: this._lastDownloadOrdinal ? String(this._lastDownloadOrdinal) : "" });475  }476  _onDialog(page) {477    const pageAlias = this._pageAliases.get(page);478    ++this._lastDialogOrdinal;479    this._signalProcessor.signal(pageAlias, page.mainFrame(), { name: "dialog", dialogAlias: this._lastDialogOrdinal ? String(this._lastDialogOrdinal) : "" });480  }481}482function isScreenshotCommand(metadata) {483  return metadata.method.toLowerCase().includes("screenshot");484}485function languageForFile(file) {486  if (file.endsWith(".py"))487    return "python";488  if (file.endsWith(".java"))489    return "java";490  if (file.endsWith(".cs"))491    return "csharp";492  return "javascript";493}494// Annotate the CommonJS export names for ESM import in node:4950 && (module.exports = {496  Recorder,497  RecorderEvent498});499 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai