UNPKG

@2501-ai/cli

Version:

[![npm version](https://img.shields.io/npm/v/@2501-ai/cli.svg)](https://www.npmjs.com/package/@2501-ai/cli) [![HumanEval Score](https://img.shields.io/badge/HumanEval-96.95%25-brightgreen.svg)](https://www.2501.ai/research/full-humaneval-benchmark) [![Lic

28 lines (27 loc) 902 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isLooping = void 0; const crypto_1 = require("crypto"); const REPETITION_THRESHOLD = 15; const actionHashes = new Map(); function hashAction(action) { return (0, crypto_1.createHash)('sha256') .update(JSON.stringify(Object.assign(Object.assign({}, action), { id: '' }))) .digest('hex'); } function isLooping(actions) { let isLooping = false; for (const action of actions) { const actionHash = hashAction(action); if (actionHashes.has(actionHash)) { const count = actionHashes.get(actionHash); actionHashes.set(actionHash, count + 1); isLooping || (isLooping = count + 1 >= REPETITION_THRESHOLD); } else { actionHashes.set(actionHash, 1); } } return isLooping; } exports.isLooping = isLooping;