onbuzz 3.4.0 → 3.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/bump-version.js +116 -0
- package/src/__test-utils__/fixtures/malformedJson.js +31 -0
- package/src/__test-utils__/globalSetup.js +9 -0
- package/src/__test-utils__/globalTeardown.js +12 -0
- package/src/__test-utils__/mockFactories.js +101 -0
- package/src/analyzers/__tests__/CSSAnalyzer.test.js +41 -0
- package/src/analyzers/__tests__/ConfigValidator.test.js +362 -0
- package/src/analyzers/__tests__/ESLintAnalyzer.test.js +271 -0
- package/src/analyzers/__tests__/JavaScriptAnalyzer.test.js +40 -0
- package/src/analyzers/__tests__/PrettierFormatter.test.js +197 -0
- package/src/analyzers/__tests__/PythonAnalyzer.test.js +208 -0
- package/src/analyzers/__tests__/SecurityAnalyzer.test.js +303 -0
- package/src/analyzers/__tests__/SparrowAnalyzer.test.js +270 -0
- package/src/analyzers/__tests__/TypeScriptAnalyzer.test.js +187 -0
- package/src/core/__tests__/agentPool.test.js +601 -0
- package/src/core/__tests__/agentScheduler.test.js +576 -0
- package/src/core/__tests__/contextManager.test.js +252 -0
- package/src/core/__tests__/flowExecutor.test.js +262 -0
- package/src/core/__tests__/messageProcessor.test.js +627 -0
- package/src/core/__tests__/orchestrator.test.js +257 -0
- package/src/core/__tests__/stateManager.test.js +375 -0
- package/src/core/agentPool.js +26 -4
- package/src/core/agentScheduler.js +79 -21
- package/src/core/messageProcessor.js +110 -2
- package/src/index.js +27 -11
- package/src/interfaces/__tests__/imageServing.test.js +228 -0
- package/src/interfaces/terminal/__tests__/smoke/imports.test.js +3 -5
- package/src/interfaces/webServer.js +97 -13
- package/src/services/__tests__/agentActivityService.test.js +319 -0
- package/src/services/__tests__/apiKeyManager.test.js +206 -0
- package/src/services/__tests__/benchmarkService.test.js +184 -0
- package/src/services/__tests__/budgetService.test.js +211 -0
- package/src/services/__tests__/contextInjectionService.test.js +205 -0
- package/src/services/__tests__/conversationCompactionService.test.js +280 -0
- package/src/services/__tests__/credentialVault.test.js +469 -0
- package/src/services/__tests__/errorHandler.test.js +314 -0
- package/src/services/__tests__/fileAttachmentService.test.js +278 -0
- package/src/services/__tests__/flowContextService.test.js +199 -0
- package/src/services/__tests__/memoryService.test.js +450 -0
- package/src/services/__tests__/modelRouterService.test.js +388 -0
- package/src/services/__tests__/modelsService.test.js +261 -0
- package/src/services/__tests__/portRegistry.test.js +123 -0
- package/src/services/__tests__/projectDetector.test.js +34 -0
- package/src/services/__tests__/promptService.test.js +242 -0
- package/src/services/__tests__/qualityInspector.test.js +97 -0
- package/src/services/__tests__/scheduleService.test.js +308 -0
- package/src/services/__tests__/serviceRegistry.test.js +74 -0
- package/src/services/__tests__/skillsService.test.js +402 -0
- package/src/services/__tests__/tokenCountingService.test.js +48 -0
- package/src/services/conversationCompactionService.js +2 -2
- package/src/services/visualEditorServer.js +26 -7
- package/src/tools/__tests__/agentCommunicationTool.test.js +500 -0
- package/src/tools/__tests__/agentDelayTool.test.js +342 -0
- package/src/tools/__tests__/asyncToolManager.test.js +344 -0
- package/src/tools/__tests__/baseTool.test.js +420 -0
- package/src/tools/__tests__/codeMapTool.test.js +348 -0
- package/src/tools/__tests__/fileContentReplaceTool.test.js +309 -0
- package/src/tools/__tests__/fileTreeTool.test.js +274 -0
- package/src/tools/__tests__/filesystemTool.test.js +717 -0
- package/src/tools/__tests__/helpTool.test.js +204 -0
- package/src/tools/__tests__/jobDoneTool.test.js +296 -0
- package/src/tools/__tests__/memoryTool.test.js +297 -0
- package/src/tools/__tests__/seekTool.test.js +282 -0
- package/src/tools/__tests__/skillsTool.test.js +226 -0
- package/src/tools/__tests__/staticAnalysisTool.test.js +509 -0
- package/src/tools/__tests__/taskManagerTool.test.js +725 -0
- package/src/tools/__tests__/terminalTool.test.js +384 -0
- package/src/tools/__tests__/userPromptTool.test.js +297 -0
- package/src/tools/__tests__/webTool.e2e.test.js +25 -11
- package/src/tools/imageTool.js +41 -5
- package/src/tools/webTool.js +161 -48
- package/src/types/__tests__/agent.test.js +499 -0
- package/src/types/__tests__/contextReference.test.js +606 -0
- package/src/types/__tests__/conversation.test.js +555 -0
- package/src/types/__tests__/toolCommand.test.js +584 -0
- package/src/types/contextReference.js +1 -1
- package/src/utilities/__tests__/attachmentValidator.test.js +80 -0
- package/src/utilities/__tests__/configManager.test.js +397 -0
- package/src/utilities/__tests__/constants.test.js +49 -0
- package/src/utilities/__tests__/directoryAccessManager.test.js +388 -0
- package/src/utilities/__tests__/fileProcessor.test.js +104 -0
- package/src/utilities/__tests__/jsonRepair.test.js +104 -0
- package/src/utilities/__tests__/logger.test.js +129 -0
- package/src/utilities/__tests__/platformUtils.test.js +87 -0
- package/src/utilities/__tests__/structuredFileValidator.test.js +263 -0
- package/src/utilities/__tests__/tagParser.test.js +887 -0
- package/src/utilities/__tests__/toolConstants.test.js +94 -0
- package/src/utilities/tagParser.js +2 -2
- package/web-ui/build/index.html +2 -2
- package/web-ui/build/static/1c-8PZzOTzp.js +1 -0
- package/web-ui/build/static/abap-Bcx_Au1F.js +1 -0
- package/web-ui/build/static/abnf-BKTLqpWA.js +1 -0
- package/web-ui/build/static/abnf-J05BAvJt.js +1 -0
- package/web-ui/build/static/accesslog-Cp8_lqVY.js +1 -0
- package/web-ui/build/static/actionscript-BK0UaMrm.js +1 -0
- package/web-ui/build/static/actionscript-CyqZUddh.js +1 -0
- package/web-ui/build/static/ada-BNirS6Nr.js +1 -0
- package/web-ui/build/static/ada-BSFWcT1O.js +1 -0
- package/web-ui/build/static/agda-D0NJDJg7.js +1 -0
- package/web-ui/build/static/al-rWARKtwb.js +1 -0
- package/web-ui/build/static/angelscript-fCehtOYk.js +1 -0
- package/web-ui/build/static/antlr4-Dn9jrnZN.js +1 -0
- package/web-ui/build/static/apache-DaQCsvNW.js +1 -0
- package/web-ui/build/static/apacheconf-dY4i0Xvz.js +1 -0
- package/web-ui/build/static/apex-vhS4SI46.js +1 -0
- package/web-ui/build/static/apl-CKRkxH90.js +1 -0
- package/web-ui/build/static/applescript-CWmpQIEB.js +1 -0
- package/web-ui/build/static/applescript-DBaX7Uqo.js +1 -0
- package/web-ui/build/static/aql-8s41lrIa.js +1 -0
- package/web-ui/build/static/arcade-w2_RhAcq.js +1 -0
- package/web-ui/build/static/arduino-I7BtZTu6.js +1 -0
- package/web-ui/build/static/arduino-h2LZErKQ.js +1 -0
- package/web-ui/build/static/arff-C543-5a1.js +1 -0
- package/web-ui/build/static/armasm-DyZdFOzz.js +1 -0
- package/web-ui/build/static/asciidoc-ZzENlACu.js +1 -0
- package/web-ui/build/static/asciidoc-_j9x9bUz.js +1 -0
- package/web-ui/build/static/asm6502-CsNsmBfq.js +1 -0
- package/web-ui/build/static/asmatmel-CkIVf_tD.js +1 -0
- package/web-ui/build/static/aspectj-C6AQLme_.js +1 -0
- package/web-ui/build/static/aspnet-5AkdiVyL.js +1 -0
- package/web-ui/build/static/autohotkey-BRZVABiS.js +1 -0
- package/web-ui/build/static/autohotkey-DVTmfk_f.js +1 -0
- package/web-ui/build/static/autoit-3UEcWu5a.js +1 -0
- package/web-ui/build/static/autoit-BDByIKSH.js +1 -0
- package/web-ui/build/static/avisynth-BHc4uUkP.js +1 -0
- package/web-ui/build/static/avrasm-BAPq8_aI.js +1 -0
- package/web-ui/build/static/avro-idl-BKEBYUtv.js +1 -0
- package/web-ui/build/static/awk-CBCkArRT.js +1 -0
- package/web-ui/build/static/axapta-DlOgnXSZ.js +1 -0
- package/web-ui/build/static/bash-C6Brp5OE.js +1 -0
- package/web-ui/build/static/bash-DkEO7JRq.js +1 -0
- package/web-ui/build/static/basic-DG6TYB0R.js +1 -0
- package/web-ui/build/static/basic-DRPcNfAn.js +1 -0
- package/web-ui/build/static/batch-DdjZ5KC1.js +1 -0
- package/web-ui/build/static/bbcode-DCXEEs2w.js +1 -0
- package/web-ui/build/static/bicep-CpLhfOwt.js +1 -0
- package/web-ui/build/static/birb-DNWkqgQm.js +1 -0
- package/web-ui/build/static/bison-DwxbQHJ9.js +1 -0
- package/web-ui/build/static/bnf-Cgnt7npj.js +1 -0
- package/web-ui/build/static/bnf-DSTq_eu9.js +1 -0
- package/web-ui/build/static/brainfuck-Bi8mGutW.js +1 -0
- package/web-ui/build/static/brainfuck-DOWfqVtR.js +1 -0
- package/web-ui/build/static/brightscript-D95pbP-v.js +1 -0
- package/web-ui/build/static/bro-BrDVwXeg.js +1 -0
- package/web-ui/build/static/bsl-BMoXI84g.js +1 -0
- package/web-ui/build/static/c-CKH4C7-Z.js +1 -0
- package/web-ui/build/static/c-Z0txyaeJ.js +1 -0
- package/web-ui/build/static/c-like-Dzm9dMmR.js +1 -0
- package/web-ui/build/static/cal-DoyAwiUt.js +1 -0
- package/web-ui/build/static/capnproto-DeIi9LOH.js +1 -0
- package/web-ui/build/static/ceylon-Coim6DIe.js +1 -0
- package/web-ui/build/static/cfscript-CwsndC-j.js +1 -0
- package/web-ui/build/static/chaiscript-D6Aq-PSv.js +1 -0
- package/web-ui/build/static/cil-vi56VRk_.js +1 -0
- package/web-ui/build/static/clean-BfpKrTdp.js +1 -0
- package/web-ui/build/static/clojure-DUtl6BaB.js +1 -0
- package/web-ui/build/static/clojure-DXJHtDlY.js +1 -0
- package/web-ui/build/static/clojure-repl-BxwP5C3g.js +1 -0
- package/web-ui/build/static/cmake-C9_VZ1vH.js +1 -0
- package/web-ui/build/static/cmake-dplO-PGD.js +1 -0
- package/web-ui/build/static/cobol-DsZhu02V.js +1 -0
- package/web-ui/build/static/coffeescript-Cw9jtGNP.js +1 -0
- package/web-ui/build/static/coffeescript-DvDt4T2l.js +1 -0
- package/web-ui/build/static/concurnas-Bzc_Dcdd.js +1 -0
- package/web-ui/build/static/coq-Cv-5BqGo.js +1 -0
- package/web-ui/build/static/coq-DWFe2ssK.js +1 -0
- package/web-ui/build/static/cos-D6Lc6Cah.js +1 -0
- package/web-ui/build/static/cpp-BFmLjd76.js +1 -0
- package/web-ui/build/static/cpp-DVQgbHji.js +1 -0
- package/web-ui/build/static/crmsh-Cqveth9p.js +1 -0
- package/web-ui/build/static/crystal-0syYaH4Y.js +1 -0
- package/web-ui/build/static/crystal-Noptp-kr.js +1 -0
- package/web-ui/build/static/csharp-B799cFMH.js +1 -0
- package/web-ui/build/static/csharp-_HlvMZzJ.js +1 -0
- package/web-ui/build/static/cshtml-CnwOXlhP.js +1 -0
- package/web-ui/build/static/csp-1ffxIG_-.js +1 -0
- package/web-ui/build/static/csp-Bws60bPu.js +1 -0
- package/web-ui/build/static/css-BGdwXzpm.js +1 -0
- package/web-ui/build/static/css-extras-DZCECiOa.js +1 -0
- package/web-ui/build/static/csv-FMFGT0T4.js +1 -0
- package/web-ui/build/static/cypher-DnXoEwRp.js +1 -0
- package/web-ui/build/static/d-CBrts1xB.js +1 -0
- package/web-ui/build/static/d-qrJLxk2L.js +1 -0
- package/web-ui/build/static/dart-3vBSXJVV.js +1 -0
- package/web-ui/build/static/dart-Cj5b7BV9.js +1 -0
- package/web-ui/build/static/dataweave-BuFf63rk.js +1 -0
- package/web-ui/build/static/dax-Cl-se1JI.js +1 -0
- package/web-ui/build/static/delphi-CLkRb26y.js +1 -0
- package/web-ui/build/static/dhall--TIL2Z--.js +1 -0
- package/web-ui/build/static/diff-Bn-XL2om.js +1 -0
- package/web-ui/build/static/diff-BsTwly4w.js +1 -0
- package/web-ui/build/static/django-BfRtHnTS.js +1 -0
- package/web-ui/build/static/django-Dm9O4e3A.js +1 -0
- package/web-ui/build/static/dns-BIVEp3uD.js +1 -0
- package/web-ui/build/static/dns-zone-file-CO7LnOdh.js +1 -0
- package/web-ui/build/static/docker-BhwMip1R.js +1 -0
- package/web-ui/build/static/dockerfile-8Tjw9_jF.js +1 -0
- package/web-ui/build/static/dos-CRMiAo46.js +1 -0
- package/web-ui/build/static/dot-DPpW7LrJ.js +1 -0
- package/web-ui/build/static/dsconfig-D0zbYilI.js +1 -0
- package/web-ui/build/static/dts-C_-yqWEL.js +1 -0
- package/web-ui/build/static/dust-CucJgqnE.js +1 -0
- package/web-ui/build/static/ebnf-CCHK0H6j.js +1 -0
- package/web-ui/build/static/ebnf-CDdAcveH.js +1 -0
- package/web-ui/build/static/editorconfig-f-5b95UM.js +1 -0
- package/web-ui/build/static/eiffel-MmghFce7.js +1 -0
- package/web-ui/build/static/ejs-CPMN4-jk.js +1 -0
- package/web-ui/build/static/elixir-57Ldyw8h.js +1 -0
- package/web-ui/build/static/elixir-DTxnmhIt.js +1 -0
- package/web-ui/build/static/elm-ClV9zQoT.js +1 -0
- package/web-ui/build/static/elm-pX-i6o7U.js +1 -0
- package/web-ui/build/static/erb-BPeO9smT.js +1 -0
- package/web-ui/build/static/erb-BnZQ4STz.js +1 -0
- package/web-ui/build/static/erlang-DPtI7VK_.js +1 -0
- package/web-ui/build/static/erlang-KG5mg5wN.js +1 -0
- package/web-ui/build/static/erlang-repl-BqPVXZ3Y.js +1 -0
- package/web-ui/build/static/etlua-BRc0Qbbs.js +1 -0
- package/web-ui/build/static/excel-BAlZ9Hkj.js +1 -0
- package/web-ui/build/static/excel-formula-BOW-bnHh.js +1 -0
- package/web-ui/build/static/factor-DCCsCpGM.js +1 -0
- package/web-ui/build/static/false-CnqnCzBU.js +1 -0
- package/web-ui/build/static/firestore-security-rules-DtkQ3uEq.js +1 -0
- package/web-ui/build/static/fix-CfPjl4Xr.js +1 -0
- package/web-ui/build/static/flix-BCA3BceS.js +1 -0
- package/web-ui/build/static/flow-C-5ewqYW.js +1 -0
- package/web-ui/build/static/fortran-CfDtl8An.js +1 -0
- package/web-ui/build/static/fortran-DQ_knNPt.js +1 -0
- package/web-ui/build/static/fsharp-CcVQ3IqX.js +1 -0
- package/web-ui/build/static/fsharp-olQ6ojCa.js +1 -0
- package/web-ui/build/static/ftl-DIWHDyWt.js +1 -0
- package/web-ui/build/static/gams-_NVFTSj5.js +1 -0
- package/web-ui/build/static/gap-DIG5TV2b.js +1 -0
- package/web-ui/build/static/gauss-C8rjPjTG.js +1 -0
- package/web-ui/build/static/gcode-8wJu4gcL.js +1 -0
- package/web-ui/build/static/gcode-DjHf417I.js +1 -0
- package/web-ui/build/static/gdscript-BZdmRCYu.js +1 -0
- package/web-ui/build/static/gedcom-BVFJ8C_Q.js +1 -0
- package/web-ui/build/static/gherkin-7NQkoaub.js +1 -0
- package/web-ui/build/static/gherkin-bSpNbJ48.js +1 -0
- package/web-ui/build/static/git-BRY_UXsc.js +1 -0
- package/web-ui/build/static/glsl-Ck6ShGRC.js +1 -0
- package/web-ui/build/static/glsl-jwCJ0Pmg.js +1 -0
- package/web-ui/build/static/gml-BAjG4Kr2.js +1 -0
- package/web-ui/build/static/gml-BnhKb5Da.js +1 -0
- package/web-ui/build/static/gn-Dux09iX8.js +1 -0
- package/web-ui/build/static/go-BOG-9Cqk.js +1 -0
- package/web-ui/build/static/go-BWZB_3b5.js +1 -0
- package/web-ui/build/static/go-module-BVLW7KBE.js +1 -0
- package/web-ui/build/static/golo-BD_SOfwL.js +1 -0
- package/web-ui/build/static/gradle-zSadWOD2.js +1 -0
- package/web-ui/build/static/graphql-BQlyj78B.js +1 -0
- package/web-ui/build/static/groovy-BurRMqQS.js +1 -0
- package/web-ui/build/static/groovy-SP58zwlE.js +1 -0
- package/web-ui/build/static/haml-eZ5ah5KY.js +1 -0
- package/web-ui/build/static/haml-lFC47IZb.js +1 -0
- package/web-ui/build/static/handlebars-B4UXrB-Q.js +1 -0
- package/web-ui/build/static/handlebars-CQ-Q5HnC.js +1 -0
- package/web-ui/build/static/haskell-AQrRyTSy.js +1 -0
- package/web-ui/build/static/haskell-BZTSbaB_.js +1 -0
- package/web-ui/build/static/haxe-5l1X6ESp.js +1 -0
- package/web-ui/build/static/haxe-DBn90muG.js +1 -0
- package/web-ui/build/static/hcl-CnMewPLM.js +1 -0
- package/web-ui/build/static/hlsl-RAtuBzr5.js +1 -0
- package/web-ui/build/static/hoon-CSqRU_4M.js +1 -0
- package/web-ui/build/static/hpkp-_gNbXcHt.js +1 -0
- package/web-ui/build/static/hsp-DY1V4au3.js +1 -0
- package/web-ui/build/static/hsts-j5z2jJo8.js +1 -0
- package/web-ui/build/static/htmlbars-C5EHvatr.js +1 -0
- package/web-ui/build/static/http-DgWgQrZh.js +1 -0
- package/web-ui/build/static/http-DphJL0q2.js +1 -0
- package/web-ui/build/static/hy-DnBqjPsB.js +1 -0
- package/web-ui/build/static/ichigojam-DeiCOKyF.js +1 -0
- package/web-ui/build/static/icon-CWANFWY5.js +1 -0
- package/web-ui/build/static/icu-message-format-C7w3vpgC.js +1 -0
- package/web-ui/build/static/idris-BeD8eULz.js +1 -0
- package/web-ui/build/static/iecst-BIznHXqY.js +1 -0
- package/web-ui/build/static/ignore-BcFgcNaS.js +1 -0
- package/web-ui/build/static/index-D8uVofpo.js +13 -0
- package/web-ui/build/static/index-DPFadqM6.css +1 -0
- package/web-ui/build/static/index-SkOgWEAU.js +1 -0
- package/web-ui/build/static/index-Vd3WlhtC.js +747 -0
- package/web-ui/build/static/inform7-CkQD_jz-.js +1 -0
- package/web-ui/build/static/inform7-phQiuDty.js +1 -0
- package/web-ui/build/static/ini-Bw_QAbzV.js +1 -0
- package/web-ui/build/static/ini-CB8ZxX7y.js +1 -0
- package/web-ui/build/static/io-D6IgpCmL.js +1 -0
- package/web-ui/build/static/irpf90-Ctj0koST.js +1 -0
- package/web-ui/build/static/isbl-D2mGcH87.js +1 -0
- package/web-ui/build/static/j-KvHmDBWH.js +1 -0
- package/web-ui/build/static/java-BeBIdo5i.js +1 -0
- package/web-ui/build/static/java-llFZkHLe.js +1 -0
- package/web-ui/build/static/javadoc-DXvQGu0s.js +1 -0
- package/web-ui/build/static/javadoclike-B5qdA9KZ.js +1 -0
- package/web-ui/build/static/javascript-De6HzHvc.js +1 -0
- package/web-ui/build/static/javastacktrace-C5MolKiP.js +1 -0
- package/web-ui/build/static/jboss-cli-2TXd54zo.js +1 -0
- package/web-ui/build/static/jexl-W4AVA9fi.js +1 -0
- package/web-ui/build/static/jolie-DTJKRMZN.js +1 -0
- package/web-ui/build/static/jq-BYg-QQKh.js +1 -0
- package/web-ui/build/static/js-extras-BrYWd2VE.js +1 -0
- package/web-ui/build/static/js-templates-DorYpbHq.js +1 -0
- package/web-ui/build/static/jsdoc-CRF8n9pZ.js +1 -0
- package/web-ui/build/static/json-Dlcd7rla.js +1 -0
- package/web-ui/build/static/json-rhOJZzzZ.js +1 -0
- package/web-ui/build/static/json5-hTq1nNIW.js +1 -0
- package/web-ui/build/static/jsonp-CMg9Xvol.js +1 -0
- package/web-ui/build/static/jsstacktrace-hEeYxHtB.js +1 -0
- package/web-ui/build/static/jsx-B7PtA8WD.js +1 -0
- package/web-ui/build/static/julia-CNiEEY-n.js +1 -0
- package/web-ui/build/static/julia-eE0_SJlc.js +1 -0
- package/web-ui/build/static/julia-repl-CUJTTT4C.js +1 -0
- package/web-ui/build/static/keepalived-GUWJBqyD.js +1 -0
- package/web-ui/build/static/keyman-Bdf9MJyu.js +1 -0
- package/web-ui/build/static/kotlin-Ch6Bej5W.js +1 -0
- package/web-ui/build/static/kotlin-DFJ7D7Lw.js +1 -0
- package/web-ui/build/static/kumir-DJLIjcCs.js +1 -0
- package/web-ui/build/static/kusto-BM0YTwU4.js +1 -0
- package/web-ui/build/static/lasso-Z1DVS84K.js +1 -0
- package/web-ui/build/static/latex-BWbw71RK.js +1 -0
- package/web-ui/build/static/latex-CMzqmbhw.js +1 -0
- package/web-ui/build/static/latte-C1g8_grc.js +1 -0
- package/web-ui/build/static/ldif-C6QH3OIL.js +1 -0
- package/web-ui/build/static/leaf-CbR--ZsH.js +1 -0
- package/web-ui/build/static/less-ClVrKh2Z.js +1 -0
- package/web-ui/build/static/less-DNSxm8UA.js +1 -0
- package/web-ui/build/static/lilypond-lTzf_sWt.js +1 -0
- package/web-ui/build/static/liquid-Bn91mVfC.js +1 -0
- package/web-ui/build/static/lisp-CU3bHohQ.js +1 -0
- package/web-ui/build/static/lisp-DbgzE9W8.js +1 -0
- package/web-ui/build/static/livecodeserver-Cse1Uz3H.js +1 -0
- package/web-ui/build/static/livescript-BaxbgzWP.js +1 -0
- package/web-ui/build/static/livescript-nJt61DBy.js +1 -0
- package/web-ui/build/static/llvm-DBboo6UI.js +1 -0
- package/web-ui/build/static/llvm-vIy7XYVy.js +1 -0
- package/web-ui/build/static/log-CT7nfoDW.js +1 -0
- package/web-ui/build/static/lolcode-CUKVytZh.js +1 -0
- package/web-ui/build/static/lsl-CsAOlGF2.js +1 -0
- package/web-ui/build/static/lua-BuU2FFxP.js +1 -0
- package/web-ui/build/static/lua-CiDuKQaa.js +1 -0
- package/web-ui/build/static/magma-7vR0zcmS.js +1 -0
- package/web-ui/build/static/makefile-Buiz-Msh.js +1 -0
- package/web-ui/build/static/makefile-DXW_-6OY.js +1 -0
- package/web-ui/build/static/markdown-Bk5DUoGY.js +1 -0
- package/web-ui/build/static/markdown-CRS5W_Ai.js +1 -0
- package/web-ui/build/static/markup-templating-24odpmF3.js +1 -0
- package/web-ui/build/static/mathematica-BxcwhJUp.js +1 -0
- package/web-ui/build/static/matlab-3pJYx_Fb.js +1 -0
- package/web-ui/build/static/matlab-BqlRrzMf.js +1 -0
- package/web-ui/build/static/maxima-DlCfUpcj.js +1 -0
- package/web-ui/build/static/maxscript-Cu_gCaFU.js +1 -0
- package/web-ui/build/static/mel-D7iQ-5Up.js +1 -0
- package/web-ui/build/static/mel-DzBKNpoN.js +1 -0
- package/web-ui/build/static/mercury-Dfrb-i8A.js +1 -0
- package/web-ui/build/static/mermaid-WN7V2_Eq.js +1 -0
- package/web-ui/build/static/mipsasm-CcijzL0q.js +1 -0
- package/web-ui/build/static/mizar-Bk68zACP.js +1 -0
- package/web-ui/build/static/mizar-Twc2-iZ4.js +1 -0
- package/web-ui/build/static/mojolicious-DBbo2S7X.js +1 -0
- package/web-ui/build/static/mongodb-2RsFIjgg.js +1 -0
- package/web-ui/build/static/monkey-CPXtQ0Bf.js +1 -0
- package/web-ui/build/static/monkey-DjV7Wcek.js +1 -0
- package/web-ui/build/static/moonscript-B5M5as70.js +1 -0
- package/web-ui/build/static/moonscript-D1BHW4Il.js +1 -0
- package/web-ui/build/static/n1ql-D0heNDBD.js +1 -0
- package/web-ui/build/static/n1ql-DfHqXQD7.js +1 -0
- package/web-ui/build/static/n4js-CaPf44Dz.js +1 -0
- package/web-ui/build/static/nand2tetris-hdl-D1nf9mn4.js +1 -0
- package/web-ui/build/static/naniscript-DnCnu5ZX.js +1 -0
- package/web-ui/build/static/nasm-BZrSaMsK.js +1 -0
- package/web-ui/build/static/neon-D29Grm2v.js +1 -0
- package/web-ui/build/static/nevod-DgSNbQkE.js +1 -0
- package/web-ui/build/static/nginx-BAaDGDfT.js +1 -0
- package/web-ui/build/static/nginx-BvJ1lrHX.js +1 -0
- package/web-ui/build/static/nim--9zzVe5F.js +1 -0
- package/web-ui/build/static/nim-Br1relpU.js +1 -0
- package/web-ui/build/static/nix--0ftErCy.js +1 -0
- package/web-ui/build/static/nix-104ztQqr.js +1 -0
- package/web-ui/build/static/node-repl-BUMAf7_p.js +1 -0
- package/web-ui/build/static/nsis-BaeKybNA.js +1 -0
- package/web-ui/build/static/nsis-CdZEv2iA.js +1 -0
- package/web-ui/build/static/objectivec-DBB4ymdg.js +1 -0
- package/web-ui/build/static/objectivec-kFYXC6g4.js +1 -0
- package/web-ui/build/static/ocaml-D1GXvN7c.js +1 -0
- package/web-ui/build/static/ocaml-D80jRMPE.js +1 -0
- package/web-ui/build/static/opencl-fb7BfRdO.js +1 -0
- package/web-ui/build/static/openqasm-CWUBrR2w.js +1 -0
- package/web-ui/build/static/openscad-Dim7ILSL.js +1 -0
- package/web-ui/build/static/oxygene-BSwApkwz.js +1 -0
- package/web-ui/build/static/oz-CMtRoi5F.js +1 -0
- package/web-ui/build/static/parigp-AH8cZ38D.js +1 -0
- package/web-ui/build/static/parser-bBNjuhG3.js +1 -0
- package/web-ui/build/static/parser3-DUtoWEAd.js +1 -0
- package/web-ui/build/static/pascal-Cr3DPIYT.js +1 -0
- package/web-ui/build/static/pascaligo-pWW12jfs.js +1 -0
- package/web-ui/build/static/pcaxis-DBw9rxmr.js +1 -0
- package/web-ui/build/static/peoplecode-aCpMPm_s.js +1 -0
- package/web-ui/build/static/perl-BpZ7GmJ3.js +1 -0
- package/web-ui/build/static/perl-fnHTrqJL.js +1 -0
- package/web-ui/build/static/pf-Dz352ty7.js +1 -0
- package/web-ui/build/static/pgsql-CHPUdlI_.js +1 -0
- package/web-ui/build/static/php-BRwItjmS.js +1 -0
- package/web-ui/build/static/php-CrX_kswO.js +1 -0
- package/web-ui/build/static/php-extras-BmeRXDSO.js +1 -0
- package/web-ui/build/static/php-template-B0MFJ9RR.js +1 -0
- package/web-ui/build/static/phpdoc-wAPkJj9X.js +1 -0
- package/web-ui/build/static/plaintext-CmPk1gvP.js +1 -0
- package/web-ui/build/static/plsql-pWVw0sCJ.js +1 -0
- package/web-ui/build/static/pony-B4SXhyDS.js +1 -0
- package/web-ui/build/static/powerquery-ZJ28bdRR.js +1 -0
- package/web-ui/build/static/powershell-CWg1ca6z.js +1 -0
- package/web-ui/build/static/powershell-Dnl0aBXc.js +1 -0
- package/web-ui/build/static/processing-CbYVU7hZ.js +1 -0
- package/web-ui/build/static/processing-DnroirEw.js +1 -0
- package/web-ui/build/static/profile-DLNc-MTA.js +1 -0
- package/web-ui/build/static/prolog-4KlPFQus.js +1 -0
- package/web-ui/build/static/prolog-CtUicY87.js +1 -0
- package/web-ui/build/static/promql-C_i6OJVg.js +1 -0
- package/web-ui/build/static/properties-Cj0lBOSP.js +1 -0
- package/web-ui/build/static/properties-vGFibcz9.js +1 -0
- package/web-ui/build/static/protobuf-BOIGxbSP.js +1 -0
- package/web-ui/build/static/protobuf-CQ3su-J7.js +1 -0
- package/web-ui/build/static/psl-DeG5_YUF.js +1 -0
- package/web-ui/build/static/pug-BieVVXYz.js +1 -0
- package/web-ui/build/static/puppet-Ba40SVKU.js +1 -0
- package/web-ui/build/static/puppet-D7BzrcGt.js +1 -0
- package/web-ui/build/static/pure-DZnkz1iT.js +1 -0
- package/web-ui/build/static/purebasic-CLLZW_6G.js +1 -0
- package/web-ui/build/static/purebasic-CYPZo_H6.js +1 -0
- package/web-ui/build/static/purescript-Dyjfu5Id.js +1 -0
- package/web-ui/build/static/python-BdIWKxdN.js +1 -0
- package/web-ui/build/static/python-ofKsqxv7.js +1 -0
- package/web-ui/build/static/python-repl-DiTYb1xK.js +1 -0
- package/web-ui/build/static/q-B4P0If_I.js +1 -0
- package/web-ui/build/static/q-t_17xfY8.js +1 -0
- package/web-ui/build/static/qml-B5WhiN48.js +1 -0
- package/web-ui/build/static/qml-Dq0cESXJ.js +1 -0
- package/web-ui/build/static/qore-DCx30XRf.js +1 -0
- package/web-ui/build/static/qsharp-UrBScekp.js +1 -0
- package/web-ui/build/static/r-B0Ty1RKQ.js +1 -0
- package/web-ui/build/static/r-B0za8QKS.js +1 -0
- package/web-ui/build/static/racket-Dj6WEyhS.js +1 -0
- package/web-ui/build/static/reason-dj9hJSfr.js +1 -0
- package/web-ui/build/static/reasonml-B-q5_wag.js +1 -0
- package/web-ui/build/static/regex-4HEc5C1m.js +1 -0
- package/web-ui/build/static/rego-BdQe18RK.js +1 -0
- package/web-ui/build/static/renpy-CVMA2llL.js +1 -0
- package/web-ui/build/static/rest-9B4JWVGr.js +1 -0
- package/web-ui/build/static/rib-DR-U8OaT.js +1 -0
- package/web-ui/build/static/rip-Bu2t_rFZ.js +1 -0
- package/web-ui/build/static/roboconf-CJeXD5-I.js +1 -0
- package/web-ui/build/static/roboconf-DzDTVrdM.js +1 -0
- package/web-ui/build/static/robotframework-CR7KyPpN.js +1 -0
- package/web-ui/build/static/routeros-B2741z2k.js +1 -0
- package/web-ui/build/static/rsl-B9F_ZCgv.js +1 -0
- package/web-ui/build/static/ruby-I2JTNgyY.js +1 -0
- package/web-ui/build/static/ruby-QGDPOmJX.js +1 -0
- package/web-ui/build/static/ruleslanguage-CGzXEUCO.js +1 -0
- package/web-ui/build/static/rust-BxW5-WOm.js +1 -0
- package/web-ui/build/static/rust-CSOA43di.js +1 -0
- package/web-ui/build/static/sas-Bclfx4g3.js +1 -0
- package/web-ui/build/static/sas-xbQaiYjT.js +1 -0
- package/web-ui/build/static/sass-DJPbdNwd.js +1 -0
- package/web-ui/build/static/scala-Bo18NtHQ.js +1 -0
- package/web-ui/build/static/scala-Cy0JH-SG.js +1 -0
- package/web-ui/build/static/scheme-BjcWWjIx.js +1 -0
- package/web-ui/build/static/scheme-DQdj8PzN.js +1 -0
- package/web-ui/build/static/scilab-Bn1KHdK-.js +1 -0
- package/web-ui/build/static/scss-B1twkZBz.js +1 -0
- package/web-ui/build/static/scss-DmOuMI4v.js +1 -0
- package/web-ui/build/static/shell-BUlkJG0S.js +1 -0
- package/web-ui/build/static/shell-session-Bke-svxA.js +1 -0
- package/web-ui/build/static/smali-Ch9S16HV.js +1 -0
- package/web-ui/build/static/smali-D_yDr_Aj.js +1 -0
- package/web-ui/build/static/smalltalk-B9TfQ5Md.js +1 -0
- package/web-ui/build/static/smalltalk-EwbZxZsR.js +1 -0
- package/web-ui/build/static/smarty-9kDPpeSm.js +1 -0
- package/web-ui/build/static/sml-2fEfT7rd.js +1 -0
- package/web-ui/build/static/sml-BiwoLNk7.js +1 -0
- package/web-ui/build/static/solidity-n_x8Oe0h.js +1 -0
- package/web-ui/build/static/solution-file-B2mvjI3e.js +1 -0
- package/web-ui/build/static/soy-DPkgKBIS.js +1 -0
- package/web-ui/build/static/sparql-Cy95tds0.js +1 -0
- package/web-ui/build/static/splunk-spl-Ym3z9ouN.js +1 -0
- package/web-ui/build/static/sqf-CXZTG8WE.js +1 -0
- package/web-ui/build/static/sqf-Cwi3yg7f.js +1 -0
- package/web-ui/build/static/sql-DPxSQY4S.js +1 -0
- package/web-ui/build/static/sql-peh7ijGj.js +1 -0
- package/web-ui/build/static/sql_more-0YAbAuPw.js +1 -0
- package/web-ui/build/static/squirrel-CphzjV0e.js +1 -0
- package/web-ui/build/static/stan-0-xZ95-O.js +1 -0
- package/web-ui/build/static/stan-CaI4__2g.js +1 -0
- package/web-ui/build/static/stata-BrbzrGSs.js +1 -0
- package/web-ui/build/static/step21-C_qeyVLw.js +1 -0
- package/web-ui/build/static/stylus-Btycb2sZ.js +1 -0
- package/web-ui/build/static/stylus-FoBJ7jki.js +1 -0
- package/web-ui/build/static/subunit-Dpg-m04-.js +1 -0
- package/web-ui/build/static/swift-Cr9uZmgb.js +1 -0
- package/web-ui/build/static/swift-hGLFtD7e.js +1 -0
- package/web-ui/build/static/systemd-Bls2D9Vj.js +1 -0
- package/web-ui/build/static/t4-cs-C4qDO-jJ.js +1 -0
- package/web-ui/build/static/t4-templating-BbCFPMPO.js +1 -0
- package/web-ui/build/static/t4-vb-D1zoEccT.js +1 -0
- package/web-ui/build/static/taggerscript-CWHk9Gih.js +1 -0
- package/web-ui/build/static/tap-Bjt0UnzV.js +1 -0
- package/web-ui/build/static/tap-BnHKwLQs.js +1 -0
- package/web-ui/build/static/tcl-Zo9kx4y-.js +1 -0
- package/web-ui/build/static/tcl-fzLmefkt.js +1 -0
- package/web-ui/build/static/textile-9lIlUPH5.js +1 -0
- package/web-ui/build/static/thrift-M3K6r5Cy.js +1 -0
- package/web-ui/build/static/toml-HpaKqckc.js +1 -0
- package/web-ui/build/static/tp-DFKuxrKj.js +1 -0
- package/web-ui/build/static/tremor-D4_bUtMB.js +1 -0
- package/web-ui/build/static/tsx-o1RT-T90.js +1 -0
- package/web-ui/build/static/tt2-1xDqcN_2.js +1 -0
- package/web-ui/build/static/turtle-Dlt-aGky.js +1 -0
- package/web-ui/build/static/twig-CJ_BnGSR.js +1 -0
- package/web-ui/build/static/twig-CjsiSQb6.js +1 -0
- package/web-ui/build/static/typescript-B8B9zUn-.js +1 -0
- package/web-ui/build/static/typescript-D0Jgo8O7.js +1 -0
- package/web-ui/build/static/typoscript-C8Qke4ZB.js +1 -0
- package/web-ui/build/static/unrealscript-YxJdDNZ3.js +1 -0
- package/web-ui/build/static/uorazor-CtEVnqBv.js +1 -0
- package/web-ui/build/static/uri-YdaiQl4c.js +1 -0
- package/web-ui/build/static/v-CIyttMDD.js +1 -0
- package/web-ui/build/static/vala-DGslcym_.js +1 -0
- package/web-ui/build/static/vala-GFPx3uEJ.js +1 -0
- package/web-ui/build/static/vbnet-B20itab-.js +1 -0
- package/web-ui/build/static/vbnet-BdoN6egk.js +1 -0
- package/web-ui/build/static/vbscript-PHVh6Fp_.js +1 -0
- package/web-ui/build/static/vbscript-html-woH1VZ7U.js +1 -0
- package/web-ui/build/static/velocity-DtVfCZeg.js +1 -0
- package/web-ui/build/static/verilog-Bt6edXvM.js +1 -0
- package/web-ui/build/static/verilog-k_7lr9Zq.js +1 -0
- package/web-ui/build/static/vhdl-BMzOgOeK.js +1 -0
- package/web-ui/build/static/vhdl-BcAbtPG6.js +1 -0
- package/web-ui/build/static/vim-DrinG9a4.js +1 -0
- package/web-ui/build/static/vim-WihLATJL.js +1 -0
- package/web-ui/build/static/visual-basic-CJnvgPjM.js +1 -0
- package/web-ui/build/static/warpscript-zMlbUoZs.js +1 -0
- package/web-ui/build/static/wasm-GUnfTBUL.js +1 -0
- package/web-ui/build/static/web-idl-CfaLTG_r.js +1 -0
- package/web-ui/build/static/wiki-13AlLoOc.js +1 -0
- package/web-ui/build/static/wolfram-zHocYNXW.js +1 -0
- package/web-ui/build/static/wren-Byq862Iu.js +1 -0
- package/web-ui/build/static/x86asm-CLcOnePY.js +1 -0
- package/web-ui/build/static/xeora-BVHqWOFS.js +1 -0
- package/web-ui/build/static/xl-lXi8OYfr.js +1 -0
- package/web-ui/build/static/xml-KZjGBKxi.js +1 -0
- package/web-ui/build/static/xml-doc-DrQSDcEW.js +1 -0
- package/web-ui/build/static/xojo-DosHeFXU.js +1 -0
- package/web-ui/build/static/xquery-BZN1F14Q.js +1 -0
- package/web-ui/build/static/xquery-Cnz7ZLFr.js +1 -0
- package/web-ui/build/static/yaml-BzXOcy9u.js +1 -0
- package/web-ui/build/static/yaml-C207y5bt.js +1 -0
- package/web-ui/build/static/yang-ByrBdDIg.js +1 -0
- package/web-ui/build/static/zephir-bahTa7of.js +1 -0
- package/web-ui/build/static/zig-BlFYhdtC.js +1 -0
- package/src/tools/browserTool.js +0 -897
- package/src/utilities/platformUtils.test.js +0 -98
- package/web-ui/build/static/index-SmQFfvBs.js +0 -746
- package/web-ui/build/static/index-V2ySwjHp.css +0 -1
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import { jest, describe, test, expect, beforeEach } from '@jest/globals';
|
|
2
|
+
import { createMockLogger, createMockConfig } from '../../__test-utils__/mockFactories.js';
|
|
3
|
+
|
|
4
|
+
// Mock dependencies before importing
|
|
5
|
+
jest.unstable_mockModule('../../utilities/tagParser.js', () => ({
|
|
6
|
+
default: {
|
|
7
|
+
extractContent: jest.fn((content, tag) => {
|
|
8
|
+
const regex = new RegExp(`<${tag}>(.*?)</${tag}>`, 'gs');
|
|
9
|
+
const matches = [];
|
|
10
|
+
let match;
|
|
11
|
+
while ((match = regex.exec(content)) !== null) {
|
|
12
|
+
matches.push(match[1]);
|
|
13
|
+
}
|
|
14
|
+
return matches;
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
jest.unstable_mockModule('../../utilities/constants.js', () => ({
|
|
20
|
+
TOOL_STATUS: { PENDING: 'pending', EXECUTING: 'executing', COMPLETED: 'completed', FAILED: 'failed' },
|
|
21
|
+
SYSTEM_DEFAULTS: { MAX_PAUSE_DURATION: 300, MAX_TOOL_EXECUTION_TIME: 300000 },
|
|
22
|
+
AGENT_STATUS: { ACTIVE: 'active', IDLE: 'idle', BUSY: 'busy', PAUSED: 'paused' },
|
|
23
|
+
OPERATION_STATUS: { EXECUTING: 'executing', COMPLETED: 'completed', FAILED: 'failed' },
|
|
24
|
+
ERROR_TYPES: {}
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
const { default: AgentDelayTool } = await import('../agentDelayTool.js');
|
|
28
|
+
|
|
29
|
+
describe('AgentDelayTool', () => {
|
|
30
|
+
let tool;
|
|
31
|
+
let logger;
|
|
32
|
+
let mockAgentPool;
|
|
33
|
+
|
|
34
|
+
beforeEach(() => {
|
|
35
|
+
logger = createMockLogger();
|
|
36
|
+
mockAgentPool = {
|
|
37
|
+
pauseAgent: jest.fn().mockResolvedValue({ success: true }),
|
|
38
|
+
getAgent: jest.fn().mockResolvedValue({ id: 'agent-1', delayEndTime: null }),
|
|
39
|
+
persistAgentState: jest.fn().mockResolvedValue(undefined)
|
|
40
|
+
};
|
|
41
|
+
tool = new AgentDelayTool({}, logger, mockAgentPool);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe('constructor', () => {
|
|
45
|
+
test('should set default pause durations', () => {
|
|
46
|
+
expect(tool.maxPauseDuration).toBe(300);
|
|
47
|
+
expect(tool.minPauseDuration).toBe(1);
|
|
48
|
+
expect(tool.requiresProject).toBe(false);
|
|
49
|
+
expect(tool.isAsync).toBe(false);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('should accept custom durations', () => {
|
|
53
|
+
const customTool = new AgentDelayTool({ maxDuration: 600, minDuration: 5 }, logger, null);
|
|
54
|
+
expect(customTool.maxPauseDuration).toBe(600);
|
|
55
|
+
expect(customTool.minPauseDuration).toBe(5);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('getDescription', () => {
|
|
60
|
+
test('should return description with pause range info', () => {
|
|
61
|
+
const desc = tool.getDescription();
|
|
62
|
+
expect(desc).toContain('Agent Delay Tool');
|
|
63
|
+
expect(desc).toContain('duration');
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe('getSupportedActions', () => {
|
|
68
|
+
test('should return pause and delay', () => {
|
|
69
|
+
const actions = tool.getSupportedActions();
|
|
70
|
+
expect(actions).toContain('pause');
|
|
71
|
+
expect(actions).toContain('delay');
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe('getRequiredParameters', () => {
|
|
76
|
+
test('should require duration', () => {
|
|
77
|
+
expect(tool.getRequiredParameters()).toContain('duration');
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe('parseParameters', () => {
|
|
82
|
+
test('should parse duration and reason from tags', () => {
|
|
83
|
+
const result = tool.parseParameters('<pause-duration>30</pause-duration><reason>Waiting</reason>');
|
|
84
|
+
expect(result.duration).toBe(30);
|
|
85
|
+
expect(result.reason).toBe('Waiting');
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('should default reason when not provided', () => {
|
|
89
|
+
const result = tool.parseParameters('<pause-duration>60</pause-duration>');
|
|
90
|
+
expect(result.duration).toBe(60);
|
|
91
|
+
expect(result.reason).toBe('Agent pause requested');
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test('should return null duration when not provided', () => {
|
|
95
|
+
const result = tool.parseParameters('some content');
|
|
96
|
+
expect(result.duration).toBeNull();
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
describe('validateParameterTypes', () => {
|
|
101
|
+
test('should accept valid params', () => {
|
|
102
|
+
const result = tool.validateParameterTypes({ duration: 30, reason: 'test' });
|
|
103
|
+
expect(result.valid).toBe(true);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('should reject non-number duration', () => {
|
|
107
|
+
const result = tool.validateParameterTypes({ duration: 'abc' });
|
|
108
|
+
expect(result.valid).toBe(false);
|
|
109
|
+
expect(result.errors[0]).toContain('valid number');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test('should reject non-string reason', () => {
|
|
113
|
+
const result = tool.validateParameterTypes({ duration: 30, reason: 123 });
|
|
114
|
+
expect(result.valid).toBe(false);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe('customValidateParameters', () => {
|
|
119
|
+
test('should reject null duration', () => {
|
|
120
|
+
const result = tool.customValidateParameters({ duration: null });
|
|
121
|
+
expect(result.valid).toBe(false);
|
|
122
|
+
expect(result.errors[0]).toContain('required');
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test('should reject duration below minimum', () => {
|
|
126
|
+
const result = tool.customValidateParameters({ duration: 0 });
|
|
127
|
+
expect(result.valid).toBe(false);
|
|
128
|
+
expect(result.errors[0]).toContain('at least');
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('should reject duration above maximum', () => {
|
|
132
|
+
const result = tool.customValidateParameters({ duration: 999 });
|
|
133
|
+
expect(result.valid).toBe(false);
|
|
134
|
+
expect(result.errors[0]).toContain('cannot exceed');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('should reject non-integer duration', () => {
|
|
138
|
+
const result = tool.customValidateParameters({ duration: 10.5 });
|
|
139
|
+
expect(result.valid).toBe(false);
|
|
140
|
+
expect(result.errors[0]).toContain('whole number');
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test('should reject reason over 200 chars', () => {
|
|
144
|
+
const result = tool.customValidateParameters({ duration: 30, reason: 'x'.repeat(201) });
|
|
145
|
+
expect(result.valid).toBe(false);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test('should accept valid parameters', () => {
|
|
149
|
+
const result = tool.customValidateParameters({ duration: 60, reason: 'Valid reason' });
|
|
150
|
+
expect(result.valid).toBe(true);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
describe('execute', () => {
|
|
155
|
+
test('should throw when agentId is missing', async () => {
|
|
156
|
+
await expect(tool.execute({ duration: 30, reason: 'test' }, {}))
|
|
157
|
+
.rejects.toThrow('Agent ID is required');
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
test('should throw when agentPool is not available', async () => {
|
|
161
|
+
tool.agentPool = null;
|
|
162
|
+
await expect(tool.execute({ duration: 30, reason: 'test' }, { agentId: 'agent-1' }))
|
|
163
|
+
.rejects.toThrow('Agent pool not available');
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
test('should successfully pause agent', async () => {
|
|
167
|
+
const result = await tool.execute(
|
|
168
|
+
{ duration: 30, reason: 'npm install' },
|
|
169
|
+
{ agentId: 'agent-1' }
|
|
170
|
+
);
|
|
171
|
+
expect(result.success).toBe(true);
|
|
172
|
+
expect(result.action).toBe('agent-pause');
|
|
173
|
+
expect(result.agentId).toBe('agent-1');
|
|
174
|
+
expect(result.pauseDuration).toBe(30);
|
|
175
|
+
expect(result.reason).toBe('npm install');
|
|
176
|
+
expect(result.pausedUntil).toBeDefined();
|
|
177
|
+
expect(mockAgentPool.pauseAgent).toHaveBeenCalled();
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test('should set delayEndTime on agent', async () => {
|
|
181
|
+
const mockAgent = { id: 'agent-1', delayEndTime: null };
|
|
182
|
+
mockAgentPool.getAgent.mockResolvedValue(mockAgent);
|
|
183
|
+
|
|
184
|
+
await tool.execute(
|
|
185
|
+
{ duration: 60, reason: 'build' },
|
|
186
|
+
{ agentId: 'agent-1' }
|
|
187
|
+
);
|
|
188
|
+
expect(mockAgent.delayEndTime).toBeDefined();
|
|
189
|
+
expect(mockAgentPool.persistAgentState).toHaveBeenCalledWith('agent-1');
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
test('should throw when pause fails', async () => {
|
|
193
|
+
mockAgentPool.pauseAgent.mockResolvedValue({ success: false, message: 'Agent not found' });
|
|
194
|
+
|
|
195
|
+
await expect(tool.execute(
|
|
196
|
+
{ duration: 30, reason: 'test' },
|
|
197
|
+
{ agentId: 'agent-1' }
|
|
198
|
+
)).rejects.toThrow('Failed to pause agent');
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
test('should format singular second correctly', async () => {
|
|
202
|
+
const result = await tool.execute(
|
|
203
|
+
{ duration: 1, reason: 'brief' },
|
|
204
|
+
{ agentId: 'agent-1' }
|
|
205
|
+
);
|
|
206
|
+
expect(result.message).toBe('Agent will resume activity in 1 second');
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
test('should format plural seconds correctly', async () => {
|
|
210
|
+
const result = await tool.execute(
|
|
211
|
+
{ duration: 30, reason: 'brief' },
|
|
212
|
+
{ agentId: 'agent-1' }
|
|
213
|
+
);
|
|
214
|
+
expect(result.message).toBe('Agent will resume activity in 30 seconds');
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
describe('getCapabilities', () => {
|
|
219
|
+
test('should include pause range info', () => {
|
|
220
|
+
const caps = tool.getCapabilities();
|
|
221
|
+
expect(caps.pauseRange).toBeDefined();
|
|
222
|
+
expect(caps.pauseRange.min).toBe(1);
|
|
223
|
+
expect(caps.pauseRange.max).toBe(300);
|
|
224
|
+
expect(caps.affects).toBe('agent-status');
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
describe('formatResumeTime', () => {
|
|
229
|
+
test('should format seconds', () => {
|
|
230
|
+
const futureDate = new Date(Date.now() + 30000);
|
|
231
|
+
const result = tool.formatResumeTime(futureDate);
|
|
232
|
+
expect(result).toMatch(/in \d+ seconds?/);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
test('should format minutes', () => {
|
|
236
|
+
const futureDate = new Date(Date.now() + 120000);
|
|
237
|
+
const result = tool.formatResumeTime(futureDate);
|
|
238
|
+
expect(result).toMatch(/in \d+ minutes?/);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
test('should format hours', () => {
|
|
242
|
+
const futureDate = new Date(Date.now() + 7200000);
|
|
243
|
+
const result = tool.formatResumeTime(futureDate);
|
|
244
|
+
expect(result).toMatch(/in \d+ hours?/);
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
describe('canPauseAgent', () => {
|
|
249
|
+
test('should return false when no agent pool', async () => {
|
|
250
|
+
tool.agentPool = null;
|
|
251
|
+
const result = await tool.canPauseAgent('agent-1');
|
|
252
|
+
expect(result.canPause).toBe(false);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
test('should return false when agent not found', async () => {
|
|
256
|
+
mockAgentPool.getAgent.mockResolvedValue(null);
|
|
257
|
+
const result = await tool.canPauseAgent('agent-1');
|
|
258
|
+
expect(result.canPause).toBe(false);
|
|
259
|
+
expect(result.reason).toContain('not found');
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
test('should return false when agent already paused', async () => {
|
|
263
|
+
mockAgentPool.getAgent.mockResolvedValue({ status: 'paused', pausedUntil: 'sometime' });
|
|
264
|
+
const result = await tool.canPauseAgent('agent-1');
|
|
265
|
+
expect(result.canPause).toBe(false);
|
|
266
|
+
expect(result.reason).toContain('already paused');
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
test('should return true when agent can be paused', async () => {
|
|
270
|
+
mockAgentPool.getAgent.mockResolvedValue({ status: 'active' });
|
|
271
|
+
const result = await tool.canPauseAgent('agent-1');
|
|
272
|
+
expect(result.canPause).toBe(true);
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
test('should handle errors gracefully', async () => {
|
|
276
|
+
mockAgentPool.getAgent.mockRejectedValue(new Error('DB error'));
|
|
277
|
+
const result = await tool.canPauseAgent('agent-1');
|
|
278
|
+
expect(result.canPause).toBe(false);
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
describe('getPauseRecommendations', () => {
|
|
283
|
+
test('should recommend for npm install', () => {
|
|
284
|
+
const result = tool.getPauseRecommendations({ lastCommand: 'npm install' });
|
|
285
|
+
expect(result.suggested.length).toBeGreaterThan(0);
|
|
286
|
+
expect(result.suggested[0].duration).toBe(90);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
test('should recommend for docker build', () => {
|
|
290
|
+
const result = tool.getPauseRecommendations({ lastCommand: 'docker build .' });
|
|
291
|
+
expect(result.suggested.length).toBeGreaterThan(0);
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
test('should warn about short pauses', () => {
|
|
295
|
+
const result = tool.getPauseRecommendations({ requestedDuration: 5 });
|
|
296
|
+
expect(result.warnings.length).toBeGreaterThan(0);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
test('should warn about long pauses', () => {
|
|
300
|
+
const result = tool.getPauseRecommendations({ requestedDuration: 250 });
|
|
301
|
+
expect(result.warnings.length).toBeGreaterThan(0);
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
test('should return empty for no context', () => {
|
|
305
|
+
const result = tool.getPauseRecommendations({});
|
|
306
|
+
expect(result.suggested).toEqual([]);
|
|
307
|
+
expect(result.warnings).toEqual([]);
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
describe('setAgentPool', () => {
|
|
312
|
+
test('should enable tool when pool is provided', () => {
|
|
313
|
+
const newTool = new AgentDelayTool({}, logger, null);
|
|
314
|
+
newTool.setAgentPool(mockAgentPool);
|
|
315
|
+
expect(newTool.isEnabled).toBe(true);
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
test('should disable tool when pool is null', () => {
|
|
319
|
+
tool.setAgentPool(null);
|
|
320
|
+
expect(tool.isEnabled).toBe(false);
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
describe('getUsageExamples', () => {
|
|
325
|
+
test('should return array of examples', () => {
|
|
326
|
+
const examples = tool.getUsageExamples();
|
|
327
|
+
expect(Array.isArray(examples)).toBe(true);
|
|
328
|
+
expect(examples.length).toBeGreaterThan(0);
|
|
329
|
+
expect(examples[0].title).toBeDefined();
|
|
330
|
+
expect(examples[0].command).toBeDefined();
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
describe('getParameterSchema', () => {
|
|
335
|
+
test('should return schema with duration and reason', () => {
|
|
336
|
+
const schema = tool.getParameterSchema();
|
|
337
|
+
expect(schema.properties.duration).toBeDefined();
|
|
338
|
+
expect(schema.properties.reason).toBeDefined();
|
|
339
|
+
expect(schema.required).toContain('duration');
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
});
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { jest, describe, test, expect, beforeEach, afterEach } from '@jest/globals';
|
|
2
|
+
import { createMockLogger } from '../../__test-utils__/mockFactories.js';
|
|
3
|
+
|
|
4
|
+
jest.unstable_mockModule('../../utilities/constants.js', () => ({
|
|
5
|
+
TOOL_STATUS: {
|
|
6
|
+
PENDING: 'pending',
|
|
7
|
+
EXECUTING: 'executing',
|
|
8
|
+
COMPLETED: 'completed',
|
|
9
|
+
FAILED: 'failed',
|
|
10
|
+
CANCELLED: 'cancelled',
|
|
11
|
+
TIMEOUT: 'timeout'
|
|
12
|
+
},
|
|
13
|
+
SYSTEM_DEFAULTS: { MAX_TOOL_EXECUTION_TIME: 300000 },
|
|
14
|
+
OPERATION_STATUS: {},
|
|
15
|
+
ERROR_TYPES: {}
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
const { default: AsyncToolManager } = await import('../asyncToolManager.js');
|
|
19
|
+
|
|
20
|
+
describe('AsyncToolManager', () => {
|
|
21
|
+
let manager;
|
|
22
|
+
let logger;
|
|
23
|
+
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
jest.useFakeTimers();
|
|
26
|
+
logger = createMockLogger();
|
|
27
|
+
manager = new AsyncToolManager({
|
|
28
|
+
maxConcurrentOperations: 5,
|
|
29
|
+
defaultTimeout: 10000,
|
|
30
|
+
cleanupInterval: 60000
|
|
31
|
+
}, logger);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
manager.stopMonitoring();
|
|
36
|
+
manager.removeAllListeners();
|
|
37
|
+
jest.useRealTimers();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('constructor', () => {
|
|
41
|
+
test('should set default config', () => {
|
|
42
|
+
expect(manager.maxConcurrentOperations).toBe(5);
|
|
43
|
+
expect(manager.defaultTimeout).toBe(10000);
|
|
44
|
+
expect(manager.operations).toBeInstanceOf(Map);
|
|
45
|
+
expect(manager.operationHistory).toEqual([]);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('should start monitoring on creation', () => {
|
|
49
|
+
expect(manager.monitoringInterval).not.toBeNull();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe('startOperation', () => {
|
|
54
|
+
test('should create and track a new operation', async () => {
|
|
55
|
+
const opId = await manager.startOperation('filesystem', 'agent-1', { path: '/test' });
|
|
56
|
+
expect(typeof opId).toBe('string');
|
|
57
|
+
expect(opId).toMatch(/^op-/);
|
|
58
|
+
expect(manager.operations.has(opId)).toBe(true);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('should set pending status initially', async () => {
|
|
62
|
+
const opId = await manager.startOperation('filesystem', 'agent-1', {});
|
|
63
|
+
const op = manager.operations.get(opId);
|
|
64
|
+
expect(op.status).toBe('pending');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('should throw when max concurrent operations reached', async () => {
|
|
68
|
+
// Fill up operations
|
|
69
|
+
for (let i = 0; i < 5; i++) {
|
|
70
|
+
await manager.startOperation('tool', `agent-${i}`, {});
|
|
71
|
+
}
|
|
72
|
+
await expect(manager.startOperation('tool', 'agent-extra', {}))
|
|
73
|
+
.rejects.toThrow('Maximum concurrent operations');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('should use custom timeout from context', async () => {
|
|
77
|
+
const opId = await manager.startOperation('tool', 'agent-1', {}, { timeout: 5000 });
|
|
78
|
+
const op = manager.operations.get(opId);
|
|
79
|
+
expect(op.timeout).toBe(5000);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe('updateOperation', () => {
|
|
84
|
+
test('should update operation status', async () => {
|
|
85
|
+
const opId = await manager.startOperation('tool', 'agent-1', {});
|
|
86
|
+
const result = manager.updateOperation(opId, 'executing');
|
|
87
|
+
expect(result).toBe(true);
|
|
88
|
+
expect(manager.operations.get(opId).status).toBe('executing');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('should set startedAt on executing', async () => {
|
|
92
|
+
const opId = await manager.startOperation('tool', 'agent-1', {});
|
|
93
|
+
manager.updateOperation(opId, 'executing');
|
|
94
|
+
expect(manager.operations.get(opId).startedAt).not.toBeNull();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('should set completedAt on completed', async () => {
|
|
98
|
+
const opId = await manager.startOperation('tool', 'agent-1', {});
|
|
99
|
+
manager.updateOperation(opId, 'completed', { result: 'done' });
|
|
100
|
+
expect(manager.operations.get(opId).completedAt).not.toBeNull();
|
|
101
|
+
expect(manager.operations.get(opId).result).toBe('done');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('should return false for unknown operation', () => {
|
|
105
|
+
const result = manager.updateOperation('nonexistent', 'completed');
|
|
106
|
+
expect(result).toBe(false);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test('should store error data', async () => {
|
|
110
|
+
const opId = await manager.startOperation('tool', 'agent-1', {});
|
|
111
|
+
manager.updateOperation(opId, 'failed', { error: 'Something broke' });
|
|
112
|
+
expect(manager.operations.get(opId).error).toBe('Something broke');
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test('should store progress data', async () => {
|
|
116
|
+
const opId = await manager.startOperation('tool', 'agent-1', {});
|
|
117
|
+
manager.updateOperation(opId, 'executing', { progress: 50 });
|
|
118
|
+
expect(manager.operations.get(opId).progress).toBe(50);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
describe('getOperation', () => {
|
|
123
|
+
test('should return operation details', async () => {
|
|
124
|
+
const opId = await manager.startOperation('filesystem', 'agent-1', { path: '/test' });
|
|
125
|
+
const op = manager.getOperation(opId);
|
|
126
|
+
expect(op).not.toBeNull();
|
|
127
|
+
expect(op.toolId).toBe('filesystem');
|
|
128
|
+
expect(op.agentId).toBe('agent-1');
|
|
129
|
+
expect(op.status).toBe('pending');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test('should return null for unknown operation', () => {
|
|
133
|
+
expect(manager.getOperation('nonexistent')).toBeNull();
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test('should include executionTime', async () => {
|
|
137
|
+
const opId = await manager.startOperation('tool', 'agent-1', {});
|
|
138
|
+
manager.updateOperation(opId, 'executing');
|
|
139
|
+
const op = manager.getOperation(opId);
|
|
140
|
+
expect(op.executionTime).toBeDefined();
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
describe('getAgentOperations', () => {
|
|
145
|
+
test('should return only operations for specified agent', async () => {
|
|
146
|
+
await manager.startOperation('tool1', 'agent-1', {});
|
|
147
|
+
await manager.startOperation('tool2', 'agent-1', {});
|
|
148
|
+
await manager.startOperation('tool3', 'agent-2', {});
|
|
149
|
+
|
|
150
|
+
const ops = manager.getAgentOperations('agent-1');
|
|
151
|
+
expect(ops).toHaveLength(2);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
test('returns all operations for agent', async () => {
|
|
155
|
+
const id1 = await manager.startOperation('tool1', 'agent-1', {});
|
|
156
|
+
const id2 = await manager.startOperation('tool2', 'agent-1', {});
|
|
157
|
+
const ops = manager.getAgentOperations('agent-1');
|
|
158
|
+
const ids = ops.map(op => op.id);
|
|
159
|
+
expect(ids).toContain(id1);
|
|
160
|
+
expect(ids).toContain(id2);
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
describe('cancelOperation', () => {
|
|
165
|
+
test('should cancel a pending operation', async () => {
|
|
166
|
+
const opId = await manager.startOperation('tool', 'agent-1', {});
|
|
167
|
+
const result = await manager.cancelOperation(opId, 'No longer needed');
|
|
168
|
+
expect(result).toBe(true);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test('should return false for unknown operation', async () => {
|
|
172
|
+
const result = await manager.cancelOperation('nonexistent');
|
|
173
|
+
expect(result).toBe(false);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test('should not cancel completed operation', async () => {
|
|
177
|
+
const opId = await manager.startOperation('tool', 'agent-1', {});
|
|
178
|
+
manager.updateOperation(opId, 'completed');
|
|
179
|
+
const result = await manager.cancelOperation(opId);
|
|
180
|
+
expect(result).toBe(false);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
describe('retryOperation', () => {
|
|
185
|
+
test('should retry a failed operation with retries remaining', async () => {
|
|
186
|
+
const opId = await manager.startOperation('tool', 'agent-1', {}, { maxRetries: 3 });
|
|
187
|
+
manager.updateOperation(opId, 'failed', { error: 'timeout' });
|
|
188
|
+
const result = await manager.retryOperation(opId);
|
|
189
|
+
expect(result).toBe(true);
|
|
190
|
+
expect(manager.operations.get(opId).retryCount).toBe(1);
|
|
191
|
+
expect(manager.operations.get(opId).status).toBe('pending');
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
test('should not retry when max retries exceeded', async () => {
|
|
195
|
+
const opId = await manager.startOperation('tool', 'agent-1', {}, { maxRetries: 0 });
|
|
196
|
+
manager.updateOperation(opId, 'failed');
|
|
197
|
+
const result = await manager.retryOperation(opId);
|
|
198
|
+
expect(result).toBe(false);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
test('should not retry non-failed operation', async () => {
|
|
202
|
+
const opId = await manager.startOperation('tool', 'agent-1', {});
|
|
203
|
+
const result = await manager.retryOperation(opId);
|
|
204
|
+
expect(result).toBe(false);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
test('should return false for unknown operation', async () => {
|
|
208
|
+
const result = await manager.retryOperation('nonexistent');
|
|
209
|
+
expect(result).toBe(false);
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
describe('getStatistics', () => {
|
|
214
|
+
test('should return correct stats', async () => {
|
|
215
|
+
await manager.startOperation('filesystem', 'agent-1', {});
|
|
216
|
+
await manager.startOperation('terminal', 'agent-1', {});
|
|
217
|
+
await manager.startOperation('filesystem', 'agent-2', {});
|
|
218
|
+
|
|
219
|
+
const stats = manager.getStatistics();
|
|
220
|
+
expect(stats.total).toBe(3);
|
|
221
|
+
expect(stats.byTool.filesystem).toBe(2);
|
|
222
|
+
expect(stats.byTool.terminal).toBe(1);
|
|
223
|
+
expect(stats.byAgent['agent-1']).toBe(2);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
test('should return empty stats when no operations', () => {
|
|
227
|
+
const stats = manager.getStatistics();
|
|
228
|
+
expect(stats.total).toBe(0);
|
|
229
|
+
expect(stats.averageExecutionTime).toBe(0);
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
describe('cleanupCompletedOperations', () => {
|
|
234
|
+
test('should clean up old completed operations', async () => {
|
|
235
|
+
const opId = await manager.startOperation('tool', 'agent-1', {});
|
|
236
|
+
manager.updateOperation(opId, 'completed');
|
|
237
|
+
|
|
238
|
+
// Set completedAt to past
|
|
239
|
+
manager.operations.get(opId).completedAt = new Date(Date.now() - 7200000).toISOString();
|
|
240
|
+
|
|
241
|
+
const count = await manager.cleanupCompletedOperations(3600000);
|
|
242
|
+
expect(count).toBe(1);
|
|
243
|
+
expect(manager.operations.has(opId)).toBe(false);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
test('should not clean up recent operations', async () => {
|
|
247
|
+
const opId = await manager.startOperation('tool', 'agent-1', {});
|
|
248
|
+
manager.updateOperation(opId, 'completed');
|
|
249
|
+
|
|
250
|
+
const count = await manager.cleanupCompletedOperations(3600000);
|
|
251
|
+
expect(count).toBe(0);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
describe('shutdown', () => {
|
|
256
|
+
test('should cancel active operations and stop monitoring', async () => {
|
|
257
|
+
await manager.startOperation('tool1', 'agent-1', {});
|
|
258
|
+
await manager.startOperation('tool2', 'agent-1', {});
|
|
259
|
+
|
|
260
|
+
await manager.shutdown();
|
|
261
|
+
expect(manager.isShuttingDown).toBe(true);
|
|
262
|
+
expect(manager.operations.size).toBe(0);
|
|
263
|
+
expect(manager.monitoringInterval).toBeNull();
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
describe('getOperationHistory', () => {
|
|
268
|
+
test('should return empty history initially', () => {
|
|
269
|
+
const history = manager.getOperationHistory();
|
|
270
|
+
expect(history).toEqual([]);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
test('should filter by agentId', async () => {
|
|
274
|
+
// Add to history manually
|
|
275
|
+
manager.operationHistory.push(
|
|
276
|
+
{ agentId: 'agent-1', toolId: 'tool1', createdAt: new Date().toISOString() },
|
|
277
|
+
{ agentId: 'agent-2', toolId: 'tool2', createdAt: new Date().toISOString() }
|
|
278
|
+
);
|
|
279
|
+
const history = manager.getOperationHistory({ agentId: 'agent-1' });
|
|
280
|
+
expect(history).toHaveLength(1);
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
test('should filter by toolId', () => {
|
|
284
|
+
manager.operationHistory.push(
|
|
285
|
+
{ agentId: 'agent-1', toolId: 'filesystem', createdAt: new Date().toISOString() },
|
|
286
|
+
{ agentId: 'agent-1', toolId: 'terminal', createdAt: new Date().toISOString() }
|
|
287
|
+
);
|
|
288
|
+
const history = manager.getOperationHistory({ toolId: 'filesystem' });
|
|
289
|
+
expect(history).toHaveLength(1);
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
test('should filter by status', () => {
|
|
293
|
+
manager.operationHistory.push(
|
|
294
|
+
{ agentId: 'agent-1', status: 'completed', createdAt: new Date().toISOString() },
|
|
295
|
+
{ agentId: 'agent-1', status: 'failed', createdAt: new Date().toISOString() }
|
|
296
|
+
);
|
|
297
|
+
const history = manager.getOperationHistory({ status: 'completed' });
|
|
298
|
+
expect(history).toHaveLength(1);
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
test('should respect limit', () => {
|
|
302
|
+
for (let i = 0; i < 10; i++) {
|
|
303
|
+
manager.operationHistory.push({
|
|
304
|
+
agentId: 'agent-1', createdAt: new Date().toISOString()
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
const history = manager.getOperationHistory({ limit: 3 });
|
|
308
|
+
expect(history).toHaveLength(3);
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
describe('generateOperationId', () => {
|
|
313
|
+
test('should generate unique IDs', () => {
|
|
314
|
+
const id1 = manager.generateOperationId();
|
|
315
|
+
const id2 = manager.generateOperationId();
|
|
316
|
+
expect(id1).not.toBe(id2);
|
|
317
|
+
expect(id1).toMatch(/^op-/);
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
describe('calculateExecutionTime', () => {
|
|
322
|
+
test('should return 0 when not started', () => {
|
|
323
|
+
const result = manager.calculateExecutionTime({ startedAt: null });
|
|
324
|
+
expect(result).toBe(0);
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
test('should calculate time for completed operation', () => {
|
|
328
|
+
const start = new Date('2024-01-01T00:00:00Z');
|
|
329
|
+
const end = new Date('2024-01-01T00:01:00Z');
|
|
330
|
+
const result = manager.calculateExecutionTime({
|
|
331
|
+
startedAt: start.toISOString(),
|
|
332
|
+
completedAt: end.toISOString()
|
|
333
|
+
});
|
|
334
|
+
expect(result).toBe(60000);
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
describe('stopMonitoring', () => {
|
|
339
|
+
test('should clear the interval', () => {
|
|
340
|
+
manager.stopMonitoring();
|
|
341
|
+
expect(manager.monitoringInterval).toBeNull();
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
});
|