onbuzz 4.9.13 → 4.10.0
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/node_modules/glob/README.md +31 -5
- package/node_modules/glob/dist/commonjs/glob.d.ts +8 -0
- package/node_modules/glob/dist/commonjs/glob.d.ts.map +1 -1
- package/node_modules/glob/dist/commonjs/glob.js +2 -1
- package/node_modules/glob/dist/commonjs/glob.js.map +1 -1
- package/node_modules/glob/dist/commonjs/index.min.js +3 -3
- package/node_modules/glob/dist/commonjs/index.min.js.map +4 -4
- package/node_modules/glob/dist/commonjs/pattern.d.ts +3 -0
- package/node_modules/glob/dist/commonjs/pattern.d.ts.map +1 -1
- package/node_modules/glob/dist/commonjs/pattern.js +4 -0
- package/node_modules/glob/dist/commonjs/pattern.js.map +1 -1
- package/node_modules/glob/dist/esm/glob.d.ts +8 -0
- package/node_modules/glob/dist/esm/glob.d.ts.map +1 -1
- package/node_modules/glob/dist/esm/glob.js +2 -1
- package/node_modules/glob/dist/esm/glob.js.map +1 -1
- package/node_modules/glob/dist/esm/index.min.js +3 -3
- package/node_modules/glob/dist/esm/index.min.js.map +4 -4
- package/node_modules/glob/dist/esm/pattern.d.ts +3 -0
- package/node_modules/glob/dist/esm/pattern.d.ts.map +1 -1
- package/node_modules/glob/dist/esm/pattern.js +4 -0
- package/node_modules/glob/dist/esm/pattern.js.map +1 -1
- package/node_modules/{@isaacs → glob/node_modules}/balanced-match/README.md +7 -10
- package/node_modules/{@isaacs → glob/node_modules}/balanced-match/package.json +7 -18
- package/node_modules/{@isaacs → glob/node_modules}/brace-expansion/README.md +3 -6
- package/node_modules/{@isaacs → glob/node_modules}/brace-expansion/dist/commonjs/index.js +6 -4
- package/node_modules/glob/node_modules/brace-expansion/dist/commonjs/index.js.map +1 -0
- package/node_modules/{@isaacs → glob/node_modules}/brace-expansion/dist/esm/index.js +6 -4
- package/node_modules/glob/node_modules/brace-expansion/dist/esm/index.js.map +1 -0
- package/node_modules/{@isaacs → glob/node_modules}/brace-expansion/package.json +11 -7
- package/node_modules/glob/node_modules/minimatch/README.md +76 -1
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/ast.d.ts +4 -2
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/ast.d.ts.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/ast.js +309 -55
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/ast.js.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/brace-expressions.js +2 -4
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/brace-expressions.js.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/escape.d.ts +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/escape.d.ts.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/escape.js +4 -4
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/escape.js.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/index.d.ts +81 -1
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/index.d.ts.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js +232 -134
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/unescape.d.ts +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/unescape.d.ts.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/unescape.js +8 -8
- package/node_modules/glob/node_modules/minimatch/dist/commonjs/unescape.js.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/esm/assert-valid-pattern.js.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/esm/ast.d.ts +4 -2
- package/node_modules/glob/node_modules/minimatch/dist/esm/ast.d.ts.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/esm/ast.js +309 -55
- package/node_modules/glob/node_modules/minimatch/dist/esm/ast.js.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/esm/brace-expressions.d.ts.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/esm/brace-expressions.js +2 -4
- package/node_modules/glob/node_modules/minimatch/dist/esm/brace-expressions.js.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/esm/escape.d.ts +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/esm/escape.d.ts.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/esm/escape.js +4 -4
- package/node_modules/glob/node_modules/minimatch/dist/esm/escape.js.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/esm/index.d.ts +81 -1
- package/node_modules/glob/node_modules/minimatch/dist/esm/index.d.ts.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/esm/index.js +232 -134
- package/node_modules/glob/node_modules/minimatch/dist/esm/index.js.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/esm/unescape.d.ts +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/esm/unescape.d.ts.map +1 -1
- package/node_modules/glob/node_modules/minimatch/dist/esm/unescape.js +8 -8
- package/node_modules/glob/node_modules/minimatch/dist/esm/unescape.js.map +1 -1
- package/node_modules/glob/node_modules/minimatch/package.json +17 -11
- package/node_modules/glob/package.json +10 -13
- package/node_modules/minipass/LICENSE.md +55 -0
- package/node_modules/minipass/dist/commonjs/index.d.ts +12 -16
- package/node_modules/minipass/dist/commonjs/index.d.ts.map +1 -1
- package/node_modules/minipass/dist/commonjs/index.js +13 -3
- package/node_modules/minipass/dist/commonjs/index.js.map +1 -1
- package/node_modules/minipass/dist/esm/index.d.ts +12 -16
- package/node_modules/minipass/dist/esm/index.d.ts.map +1 -1
- package/node_modules/minipass/dist/esm/index.js +3 -1
- package/node_modules/minipass/dist/esm/index.js.map +1 -1
- package/node_modules/minipass/package.json +9 -14
- package/node_modules/path-scurry/node_modules/lru-cache/README.md +96 -10
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel-browser.d.ts.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel-browser.js.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel.d.ts +5 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel.js +7 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/index.d.ts +1400 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/index.d.ts.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/index.js +1726 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/index.js.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/index.min.js +2 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/index.min.js.map +7 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/perf.d.ts +12 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/perf.d.ts.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/perf.js +10 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/perf.js.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/diagnostics-channel-cjs.cjs.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/diagnostics-channel-cjs.d.cts.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/diagnostics-channel.d.ts +5 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/diagnostics-channel.js +7 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.d.ts +109 -32
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.d.ts.map +1 -1
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.js +334 -197
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.js.map +1 -1
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.min.js +1 -1
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.min.js.map +4 -4
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel-node.d.ts.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel-node.js.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel.d.ts +5 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel.js +9 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/index.d.ts +1400 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/index.d.ts.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/index.js +1726 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/index.js.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/index.min.js +2 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/index.min.js.map +7 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/perf.d.ts +12 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/perf.d.ts.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/perf.js +10 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/perf.js.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/perf.d.ts +12 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/perf.d.ts.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/perf.js +10 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/perf.js.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/diagnostics-channel-browser.d.ts.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/diagnostics-channel-browser.js.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.d.ts +5 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.js +4 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/index.d.ts +1400 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/index.d.ts.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/index.js +1722 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/index.js.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/index.min.js +2 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/index.min.js.map +7 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/perf.d.ts +12 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/perf.d.ts.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/perf.js +7 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/perf.js.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/diagnostics-channel-esm.d.mts.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/diagnostics-channel-esm.mjs.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/diagnostics-channel.d.ts +5 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/diagnostics-channel.js +19 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.d.ts +109 -32
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.d.ts.map +1 -1
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.js +333 -196
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.js.map +1 -1
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.min.js +1 -1
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.min.js.map +4 -4
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/diagnostics-channel-node.d.ts.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/diagnostics-channel-node.js.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/diagnostics-channel.d.ts +5 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/diagnostics-channel.js +6 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/index.d.ts +1400 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/index.d.ts.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/index.js +1722 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/index.js.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/index.min.js +2 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/index.min.js.map +7 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/perf.d.ts +12 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/perf.d.ts.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/perf.js +7 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/perf.js.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/perf.d.ts +12 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/perf.d.ts.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/perf.js +7 -0
- package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/perf.js.map +1 -0
- package/node_modules/path-scurry/node_modules/lru-cache/package.json +71 -18
- package/node_modules/path-scurry/package.json +8 -24
- package/package.json +1 -1
- package/scripts/debug-balance-probe.mjs +35 -35
- package/scripts/push-image.sh +43 -43
- package/scripts/setup-acr.sh +65 -65
- package/scripts/verify-optional-deps.js +96 -1
- package/src/__tests__/composioCliFlags.test.js +239 -239
- package/src/analyzers/CSSAnalyzer.js +298 -297
- package/src/analyzers/ConfigValidator.js +691 -690
- package/src/analyzers/ESLintAnalyzer.js +320 -320
- package/src/analyzers/JavaScriptAnalyzer.js +260 -261
- package/src/analyzers/PrettierFormatter.js +246 -247
- package/src/analyzers/PythonAnalyzer.js +283 -283
- package/src/analyzers/SecurityAnalyzer.js +729 -729
- package/src/analyzers/SparrowAnalyzer.js +341 -341
- package/src/analyzers/TypeScriptAnalyzer.js +247 -247
- package/src/analyzers/__tests__/CSSAnalyzer.test.js +41 -41
- package/src/analyzers/__tests__/ConfigValidator.test.js +362 -362
- package/src/analyzers/__tests__/JavaScriptAnalyzer.test.js +40 -40
- package/src/analyzers/__tests__/PythonAnalyzer.test.js +205 -208
- package/src/analyzers/__tests__/SecurityAnalyzer.test.js +303 -303
- package/src/analyzers/__tests__/TypeScriptAnalyzer.test.js +187 -187
- package/src/analyzers/codeCloneDetector/analyzer.js +344 -344
- package/src/analyzers/codeCloneDetector/detector.js +250 -250
- package/src/analyzers/codeCloneDetector/index.js +194 -192
- package/src/analyzers/codeCloneDetector/parser.js +199 -199
- package/src/core/__tests__/agentPool.test.js +866 -866
- package/src/core/__tests__/agentPoolAutoResume.test.js +209 -209
- package/src/core/__tests__/agentPoolWakeOnMessage.test.js +315 -315
- package/src/core/__tests__/agentScheduler.emptyResponseChatStall.test.js +213 -213
- package/src/core/__tests__/agentScheduler.errorCategorisation.test.js +246 -246
- package/src/core/__tests__/agentScheduler.firstChunkTimeout.test.js +138 -138
- package/src/core/__tests__/agentScheduler.modeTransitions.test.js +233 -233
- package/src/core/__tests__/agentScheduler.nativePromptPick.test.js +319 -319
- package/src/core/__tests__/agentScheduler.taskLifecycleInstruction.test.js +78 -78
- package/src/core/__tests__/agentScheduler.visualizer.test.js +258 -258
- package/src/core/__tests__/flowCheckpointStore.test.js +140 -140
- package/src/core/__tests__/flowEndToEnd.test.js +565 -565
- package/src/core/__tests__/flowFieldMapping.test.js +188 -189
- package/src/core/__tests__/flowLintClientMirror.test.js +96 -98
- package/src/core/__tests__/flowSavePayload.test.js +170 -169
- package/src/core/__tests__/flowTemplates.test.js +311 -311
- package/src/core/__tests__/flowVersionStore.test.js +123 -123
- package/src/core/__tests__/messageProcessor.test.js +669 -669
- package/src/core/__tests__/stateManager.test.js +0 -1
- package/src/core/agentPool.js +2474 -2475
- package/src/core/agentScheduler.js +1 -4
- package/src/core/contextManager.js +708 -708
- package/src/core/flowExecutor.js +1510 -1510
- package/src/core/flowFieldMapping.js +136 -138
- package/src/core/messageProcessor.js +953 -954
- package/src/core/orchestrator.js +593 -595
- package/src/core/stateManager.js +1765 -1752
- package/src/index.js +1221 -1221
- package/src/interfaces/__tests__/archivedAgentDelete.test.js +207 -207
- package/src/interfaces/__tests__/bulkAgentRoute.test.js +361 -361
- package/src/interfaces/__tests__/imageServing.test.js +228 -228
- package/src/interfaces/__tests__/remoteSessionAuth.test.js +308 -308
- package/src/interfaces/__tests__/videoJobsRoutes.test.js +178 -179
- package/src/interfaces/__tests__/webServer.marketplace.test.js +629 -629
- package/src/interfaces/schedulerRoutes.js +50 -50
- package/src/interfaces/terminal/__tests__/smoke/connection.test.js +341 -350
- package/src/interfaces/terminal/__tests__/smoke/enhancements.test.js +156 -156
- package/src/interfaces/terminal/__tests__/smoke/imports.test.js +325 -330
- package/src/interfaces/terminal/__tests__/smoke/tools.test.js +385 -388
- package/src/interfaces/terminal/api/session.js +265 -266
- package/src/interfaces/terminal/api/websocket.js +496 -497
- package/src/interfaces/terminal/components/AgentCreator.js +691 -705
- package/src/interfaces/terminal/components/AgentEditor.js +676 -678
- package/src/interfaces/terminal/components/AgentSwitcher.js +331 -330
- package/src/interfaces/terminal/components/ErrorPanel.js +263 -264
- package/src/interfaces/terminal/components/Header.js +28 -28
- package/src/interfaces/terminal/components/Layout.js +598 -603
- package/src/interfaces/terminal/components/MessageList.js +280 -281
- package/src/interfaces/terminal/components/SettingsPanel.js +410 -415
- package/src/interfaces/terminal/components/StatusBar.js +2 -0
- package/src/interfaces/terminal/index.js +168 -168
- package/src/interfaces/terminal/state/useAgentControl.js +496 -496
- package/src/interfaces/terminal/state/useAgents.js +537 -537
- package/src/interfaces/terminal/state/useMessages.js +629 -630
- package/src/interfaces/terminal/state/useTools.js +554 -554
- package/src/interfaces/terminal/utils/debugLogger.js +44 -44
- package/src/interfaces/terminal/utils/settingsStorage.js +232 -232
- package/src/interfaces/webServer.js +7578 -7579
- package/src/interfaces/webServer.js.bak +7046 -7046
- package/src/modules/fileExplorer/__tests__/zipDownload.test.js +237 -237
- package/src/modules/fileExplorer/controller.js +470 -469
- package/src/modules/fileExplorer/routes.js +285 -286
- package/src/modules/widget/__tests__/isDisabled.test.js +41 -41
- package/src/modules/widget/__tests__/routes.test.js +677 -678
- package/src/modules/widget/__tests__/runtime.test.js +401 -401
- package/src/modules/widget/__tests__/versioning.test.js +309 -309
- package/src/modules/widget/__tests__/webComponentRuntime.test.js +565 -565
- package/src/modules/widget/__tests__/widgetTool.test.js +316 -316
- package/src/modules/widget/routes.js +435 -435
- package/src/modules/widget/runtime/bundle.js +640 -640
- package/src/modules/widget/runtime/webComponentBundle.js +470 -470
- package/src/modules/widget/schema.js +182 -181
- package/src/modules/widget/widgetTool.js +1389 -1389
- package/src/services/__tests__/agentActivityService.test.js +401 -402
- package/src/services/__tests__/benchmarkService.test.js +184 -184
- package/src/services/__tests__/contextInjectionService.test.js +246 -246
- package/src/services/__tests__/conversationQuery.test.js +721 -723
- package/src/services/__tests__/credentialVault.test.js +469 -469
- package/src/services/__tests__/discordService.integration.test.js +638 -639
- package/src/services/__tests__/flowContextService.test.js +590 -590
- package/src/services/__tests__/memoryService.test.js +1 -1
- package/src/services/__tests__/messageSource.test.js +380 -380
- package/src/services/__tests__/modelRouterNaming.test.js +111 -111
- package/src/services/__tests__/projectDetector.test.js +34 -34
- package/src/services/__tests__/promptService.test.js +242 -242
- package/src/services/__tests__/telegramService.test.js +941 -941
- package/src/services/__tests__/tokenCountingService.test.js +48 -48
- package/src/services/agentActivityService.js +419 -420
- package/src/services/aiService.js +2997 -3001
- package/src/services/apiKeyManager.js +359 -359
- package/src/services/benchmarkService.js +196 -196
- package/src/services/codebaseKnowledgeService.js +2 -2
- package/src/services/composioService.js +738 -738
- package/src/services/conversationCompactionService.js +1258 -1257
- package/src/services/credentialVault.js +685 -685
- package/src/services/discordService.js +792 -793
- package/src/services/embeddings/__tests__/azureCustomProvider.test.js +232 -232
- package/src/services/embeddings/__tests__/embeddingService.test.js +417 -417
- package/src/services/embeddings/__tests__/localProvider.test.js +263 -263
- package/src/services/embeddings/autoRecall.js +218 -219
- package/src/services/embeddings/indexers/__tests__/agentIndexer.test.js +232 -232
- package/src/services/embeddings/indexers/__tests__/memoryIndexer.test.js +418 -418
- package/src/services/embeddings/indexers/__tests__/reminisceIndexer.test.js +356 -357
- package/src/services/embeddings/indexers/__tests__/skillsIndexer.test.js +145 -145
- package/src/services/embeddings/indexers/__tests__/taskIndexer.test.js +146 -146
- package/src/services/embeddings/indexers/composioIndexer.js +279 -279
- package/src/services/embeddings/providerInterface.js +206 -206
- package/src/services/embeddings/providers/localProvider.js +11 -7
- package/src/services/embeddings/providers/openaiProvider.js +101 -101
- package/src/services/embeddings/vectorStore/inMemoryJsonStore.js +356 -356
- package/src/services/errorHandler.js +809 -809
- package/src/services/flowContextService.js +586 -586
- package/src/services/grounding/MockAdapter.js +125 -125
- package/src/services/modelRouterService.js +26 -31
- package/src/services/modelsService.js +322 -322
- package/src/services/ollamaService.js +452 -452
- package/src/services/projectDetector.js +403 -404
- package/src/services/promptService.js +418 -418
- package/src/services/qualityInspector.js +795 -795
- package/src/services/scheduleService.js +726 -726
- package/src/services/serviceRegistry.js +386 -386
- package/src/services/telegrafBot.js +174 -174
- package/src/services/telegramService.js +1972 -1972
- package/src/services/visualEditorBridge.js +1033 -1033
- package/src/services/visualEditorServer.js +1769 -1774
- package/src/services/whatsappService.js +667 -668
- package/src/tools/__tests__/agentCommunicationTool.findAgent.test.js +226 -226
- package/src/tools/__tests__/agentCommunicationTool.test.js +3 -3
- package/src/tools/__tests__/agentDelayTool.test.js +342 -342
- package/src/tools/__tests__/baseTool.test.js +3 -3
- package/src/tools/__tests__/codeMapTool.test.js +915 -915
- package/src/tools/__tests__/fileContentReplaceTool.test.js +309 -309
- package/src/tools/__tests__/fileTreeTool.test.js +274 -274
- package/src/tools/__tests__/filesystemTool.test.js +815 -815
- package/src/tools/__tests__/foundryWebSearchTool.test.js +252 -252
- package/src/tools/__tests__/imageTool.validator.test.js +194 -194
- package/src/tools/__tests__/jobDoneTool.test.js +580 -581
- package/src/tools/__tests__/memoryTool.forgetStale.test.js +272 -272
- package/src/tools/__tests__/memoryTool.reminisce.test.js +2 -2
- package/src/tools/__tests__/memoryTool.reminisceSemanticSearch.test.js +301 -301
- package/src/tools/__tests__/memoryTool.semanticSearch.test.js +405 -405
- package/src/tools/__tests__/memoryTool.teamPool.test.js +293 -293
- package/src/tools/__tests__/memoryTool.test.js +1 -1
- package/src/tools/__tests__/seekTool.test.js +282 -282
- package/src/tools/__tests__/skillsTool.search.test.js +164 -164
- package/src/tools/__tests__/skillsTool.test.js +226 -226
- package/src/tools/__tests__/staticAnalysisTool.test.js +509 -509
- package/src/tools/__tests__/taskManagerTool.discipline.test.js +137 -137
- package/src/tools/__tests__/taskManagerTool.search.test.js +143 -143
- package/src/tools/__tests__/taskManagerTool.test.js +866 -866
- package/src/tools/__tests__/terminalTool.test.js +448 -448
- package/src/tools/__tests__/toolShapeForgiveness.test.js +259 -260
- package/src/tools/__tests__/userPromptTool.test.js +297 -297
- package/src/tools/__tests__/videoTool.jobs.test.js +147 -147
- package/src/tools/__tests__/webTool.e2e.test.js +609 -603
- package/src/tools/__tests__/webTool.unit.test.js +195 -195
- package/src/tools/__tests__/webTool.visionModel.test.js +75 -75
- package/src/tools/agentCommunicationTool.js +8 -10
- package/src/tools/agentDelayTool.js +496 -497
- package/src/tools/asyncToolManager.js +602 -603
- package/src/tools/baseTool.js +12 -11
- package/src/tools/cloneDetectionTool.js +576 -581
- package/src/tools/codeMapTool.js +0 -6
- package/src/tools/composioTool.js +617 -617
- package/src/tools/dependencyResolverTool.js +1211 -1212
- package/src/tools/desktop/DesktopTool.js +629 -638
- package/src/tools/desktop/__tests__/DesktopTool.e2e.test.js +306 -306
- package/src/tools/desktop/__tests__/DesktopTool.test.js +507 -507
- package/src/tools/desktop/__tests__/osController.test.js +364 -364
- package/src/tools/desktop/osController.js +491 -491
- package/src/tools/docxTool.js +623 -623
- package/src/tools/excelTool.js +636 -636
- package/src/tools/fileContentReplaceTool.js +5 -7
- package/src/tools/fileSystemTool.js +12 -19
- package/src/tools/fileTreeTool.js +840 -840
- package/src/tools/foundryWebSearchTool.js +273 -273
- package/src/tools/helpTool.js +198 -198
- package/src/tools/imageTool.js +1397 -1397
- package/src/tools/importAnalyzerTool.js +1056 -1056
- package/src/tools/jobDoneTool.js +495 -495
- package/src/tools/memoryTool.js +1 -1
- package/src/tools/office/pres/__tests__/presSystem.test.js +365 -365
- package/src/tools/office/pres/archetypes/agenda.js +61 -61
- package/src/tools/office/pres/archetypes/bentoGrid.js +218 -219
- package/src/tools/office/pres/archetypes/bigStat.js +140 -142
- package/src/tools/office/pres/archetypes/closing.js +70 -70
- package/src/tools/office/pres/archetypes/hero.js +70 -70
- package/src/tools/office/pres/archetypes/productHero.js +93 -94
- package/src/tools/office/pres/archetypes/table.js +73 -74
- package/src/tools/office/pres/backgrounds/orb.js +66 -66
- package/src/tools/office/pres/components.js +422 -423
- package/src/tools/officeTool.js +441 -441
- package/src/tools/pdfTool.js +625 -627
- package/src/tools/platformControlTool.js +1081 -1081
- package/src/tools/seekTool.js +917 -918
- package/src/tools/skillsTool.js +1 -1
- package/src/tools/staticAnalysisTool.js +2143 -2146
- package/src/tools/taskManagerTool.js +3324 -3324
- package/src/tools/terminalTool.js +2615 -2618
- package/src/tools/videoTool.js +1303 -1303
- package/src/tools/visionTool.js +508 -508
- package/src/tools/visualEditorTool.js +1289 -1290
- package/src/tools/webTool.js +3368 -3368
- package/src/tools/whatsappTool.js +464 -464
- package/src/types/__tests__/agent.test.js +499 -499
- package/src/types/__tests__/contextReference.test.js +606 -606
- package/src/types/__tests__/conversation.test.js +555 -555
- package/src/types/__tests__/toolCommand.test.js +584 -584
- package/src/types/contextReference.js +974 -971
- package/src/types/conversation.js +729 -729
- package/src/types/toolCommand.js +746 -746
- package/src/utilities/__tests__/attachmentValidator.test.js +80 -80
- package/src/utilities/__tests__/auditReport.test.js +328 -328
- package/src/utilities/__tests__/directoryAccessManager.test.js +388 -388
- package/src/utilities/__tests__/jsonRepair.test.js +103 -104
- package/src/utilities/__tests__/modeTransitionReasons.test.js +105 -105
- package/src/utilities/__tests__/platformUtils.test.js +80 -87
- package/src/utilities/__tests__/structuredFileValidator.test.js +261 -263
- package/src/utilities/__tests__/toolConstants.test.js +92 -94
- package/src/utilities/__tests__/useIsTouchDevice.detect.test.js +114 -114
- package/src/utilities/__tests__/webUiUtilSync.test.js +117 -117
- package/src/utilities/attachmentValidator.js +284 -288
- package/src/utilities/authCache.js.backup-1779570472481 +121 -121
- package/src/utilities/browserStealth.js +631 -630
- package/src/utilities/configManager.js +616 -617
- package/src/utilities/directoryAccessManager.js +564 -565
- package/src/utilities/fileProcessor.js +308 -307
- package/src/utilities/humanBehavior.js +454 -453
- package/src/utilities/logger.js +479 -479
- package/src/utilities/structuredFileValidator.js +696 -699
- package/src/utilities/tagParser.js +5 -10
- package/src/utilities/userDataDir.js +308 -308
- package/node_modules/@isaacs/brace-expansion/dist/commonjs/index.js.map +0 -1
- package/node_modules/@isaacs/brace-expansion/dist/esm/index.js.map +0 -1
- package/node_modules/minipass/LICENSE +0 -15
- /package/node_modules/{@isaacs → glob/node_modules}/balanced-match/LICENSE.md +0 -0
- /package/node_modules/{@isaacs → glob/node_modules}/balanced-match/dist/commonjs/index.d.ts +0 -0
- /package/node_modules/{@isaacs → glob/node_modules}/balanced-match/dist/commonjs/index.d.ts.map +0 -0
- /package/node_modules/{@isaacs → glob/node_modules}/balanced-match/dist/commonjs/index.js +0 -0
- /package/node_modules/{@isaacs → glob/node_modules}/balanced-match/dist/commonjs/index.js.map +0 -0
- /package/node_modules/{@isaacs → glob/node_modules}/balanced-match/dist/commonjs/package.json +0 -0
- /package/node_modules/{@isaacs → glob/node_modules}/balanced-match/dist/esm/index.d.ts +0 -0
- /package/node_modules/{@isaacs → glob/node_modules}/balanced-match/dist/esm/index.d.ts.map +0 -0
- /package/node_modules/{@isaacs → glob/node_modules}/balanced-match/dist/esm/index.js +0 -0
- /package/node_modules/{@isaacs → glob/node_modules}/balanced-match/dist/esm/index.js.map +0 -0
- /package/node_modules/{@isaacs → glob/node_modules}/balanced-match/dist/esm/package.json +0 -0
- /package/node_modules/{@isaacs → glob/node_modules}/brace-expansion/LICENSE +0 -0
- /package/node_modules/{@isaacs → glob/node_modules}/brace-expansion/dist/commonjs/index.d.ts +0 -0
- /package/node_modules/{@isaacs → glob/node_modules}/brace-expansion/dist/commonjs/index.d.ts.map +0 -0
- /package/node_modules/{@isaacs → glob/node_modules}/brace-expansion/dist/commonjs/package.json +0 -0
- /package/node_modules/{@isaacs → glob/node_modules}/brace-expansion/dist/esm/index.d.ts +0 -0
- /package/node_modules/{@isaacs → glob/node_modules}/brace-expansion/dist/esm/index.d.ts.map +0 -0
- /package/node_modules/{@isaacs → glob/node_modules}/brace-expansion/dist/esm/package.json +0 -0
|
@@ -1,75 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module LRUCache
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
performance
|
|
8
|
-
: Date;
|
|
4
|
+
import { metrics, tracing } from './diagnostics-channel.js';
|
|
5
|
+
import { defaultPerf } from './perf.js';
|
|
6
|
+
const hasSubscribers = () => metrics.hasSubscribers || tracing.hasSubscribers;
|
|
9
7
|
const warned = new Set();
|
|
10
8
|
/* c8 ignore start */
|
|
11
9
|
const PROCESS = (typeof process === 'object' && !!process ?
|
|
12
10
|
process
|
|
13
11
|
: {});
|
|
14
|
-
/* c8 ignore
|
|
12
|
+
/* c8 ignore stop */
|
|
15
13
|
const emitWarning = (msg, type, code, fn) => {
|
|
16
|
-
typeof PROCESS.emitWarning === 'function'
|
|
17
|
-
PROCESS.emitWarning(msg, type, code, fn)
|
|
18
|
-
|
|
14
|
+
if (typeof PROCESS.emitWarning === 'function') {
|
|
15
|
+
PROCESS.emitWarning(msg, type, code, fn);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
//oxlint-disable-next-line no-console
|
|
19
|
+
console.error(`[${code}] ${type}: ${msg}`);
|
|
20
|
+
}
|
|
19
21
|
};
|
|
20
|
-
let AC = globalThis.AbortController;
|
|
21
|
-
let AS = globalThis.AbortSignal;
|
|
22
|
-
/* c8 ignore start */
|
|
23
|
-
if (typeof AC === 'undefined') {
|
|
24
|
-
//@ts-ignore
|
|
25
|
-
AS = class AbortSignal {
|
|
26
|
-
onabort;
|
|
27
|
-
_onabort = [];
|
|
28
|
-
reason;
|
|
29
|
-
aborted = false;
|
|
30
|
-
addEventListener(_, fn) {
|
|
31
|
-
this._onabort.push(fn);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
//@ts-ignore
|
|
35
|
-
AC = class AbortController {
|
|
36
|
-
constructor() {
|
|
37
|
-
warnACPolyfill();
|
|
38
|
-
}
|
|
39
|
-
signal = new AS();
|
|
40
|
-
abort(reason) {
|
|
41
|
-
if (this.signal.aborted)
|
|
42
|
-
return;
|
|
43
|
-
//@ts-ignore
|
|
44
|
-
this.signal.reason = reason;
|
|
45
|
-
//@ts-ignore
|
|
46
|
-
this.signal.aborted = true;
|
|
47
|
-
//@ts-ignore
|
|
48
|
-
for (const fn of this.signal._onabort) {
|
|
49
|
-
fn(reason);
|
|
50
|
-
}
|
|
51
|
-
this.signal.onabort?.(reason);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== '1';
|
|
55
|
-
const warnACPolyfill = () => {
|
|
56
|
-
if (!printACPolyfillWarning)
|
|
57
|
-
return;
|
|
58
|
-
printACPolyfillWarning = false;
|
|
59
|
-
emitWarning('AbortController is not defined. If using lru-cache in ' +
|
|
60
|
-
'node 14, load an AbortController polyfill from the ' +
|
|
61
|
-
'`node-abort-controller` package. A minimal polyfill is ' +
|
|
62
|
-
'provided for use by LRUCache.fetch(), but it should not be ' +
|
|
63
|
-
'relied upon in other contexts (eg, passing it to other APIs that ' +
|
|
64
|
-
'use AbortController/AbortSignal might have undesirable effects). ' +
|
|
65
|
-
'You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.', 'NO_ABORT_CONTROLLER', 'ENOTSUP', warnACPolyfill);
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
/* c8 ignore stop */
|
|
69
22
|
const shouldWarn = (code) => !warned.has(code);
|
|
70
23
|
const TYPE = Symbol('type');
|
|
71
|
-
const isPosInt = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n);
|
|
72
|
-
/* c8 ignore start */
|
|
24
|
+
const isPosInt = (n) => !!n && n === Math.floor(n) && n > 0 && isFinite(n);
|
|
73
25
|
// This is a little bit ridiculous, tbh.
|
|
74
26
|
// The maximum array length is 2^32-1 or thereabouts on most JS impls.
|
|
75
27
|
// And well before that point, you're caching the entire world, I mean,
|
|
@@ -78,6 +30,7 @@ const isPosInt = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n);
|
|
|
78
30
|
// zeroes at init time is brutal when you get that big.
|
|
79
31
|
// But why not be complete?
|
|
80
32
|
// Maybe in the future, these limits will have expanded.
|
|
33
|
+
/* c8 ignore start */
|
|
81
34
|
const getUintArray = (max) => !isPosInt(max) ? null
|
|
82
35
|
: max <= Math.pow(2, 8) ? Uint8Array
|
|
83
36
|
: max <= Math.pow(2, 16) ? Uint16Array
|
|
@@ -92,7 +45,9 @@ class ZeroArray extends Array {
|
|
|
92
45
|
}
|
|
93
46
|
}
|
|
94
47
|
class Stack {
|
|
48
|
+
/* c8 ignore start - not sure why this is showing up uncovered?? */
|
|
95
49
|
heap;
|
|
50
|
+
/* c8 ignore stop */
|
|
96
51
|
length;
|
|
97
52
|
// private constructor
|
|
98
53
|
static #constructing = false;
|
|
@@ -212,6 +167,8 @@ export class LRUCache {
|
|
|
212
167
|
* {@link LRUCache.OptionsBase.ignoreFetchAbort}
|
|
213
168
|
*/
|
|
214
169
|
ignoreFetchAbort;
|
|
170
|
+
/** {@link LRUCache.OptionsBase.backgroundFetchSize} */
|
|
171
|
+
backgroundFetchSize;
|
|
215
172
|
// computed properties
|
|
216
173
|
#size;
|
|
217
174
|
#calculatedSize;
|
|
@@ -322,7 +279,8 @@ export class LRUCache {
|
|
|
322
279
|
return this.#disposeAfter;
|
|
323
280
|
}
|
|
324
281
|
constructor(options) {
|
|
325
|
-
const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, onInsert, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, perf, } = options;
|
|
282
|
+
const { max = 0, ttl, ttlResolution = 1, ttlAutopurge, updateAgeOnGet, updateAgeOnHas, allowStale, dispose, onInsert, disposeAfter, noDisposeOnSet, noUpdateTTL, maxSize = 0, maxEntrySize = 0, sizeCalculation, fetchMethod, memoMethod, noDeleteOnFetchRejection, noDeleteOnStaleGet, allowStaleOnFetchRejection, allowStaleOnFetchAbort, ignoreFetchAbort, backgroundFetchSize = 1, perf, } = options;
|
|
283
|
+
this.backgroundFetchSize = backgroundFetchSize;
|
|
326
284
|
if (perf !== undefined) {
|
|
327
285
|
if (typeof perf?.now !== 'function') {
|
|
328
286
|
throw new TypeError('perf option must have a now() method if specified');
|
|
@@ -358,8 +316,8 @@ export class LRUCache {
|
|
|
358
316
|
this.#fetchMethod = fetchMethod;
|
|
359
317
|
this.#hasFetchMethod = !!fetchMethod;
|
|
360
318
|
this.#keyMap = new Map();
|
|
361
|
-
this.#keyList =
|
|
362
|
-
this.#valList =
|
|
319
|
+
this.#keyList = Array.from({ length: max }).fill(undefined);
|
|
320
|
+
this.#valList = Array.from({ length: max }).fill(undefined);
|
|
363
321
|
this.#next = new UintArray(max);
|
|
364
322
|
this.#prev = new UintArray(max);
|
|
365
323
|
this.#head = 0;
|
|
@@ -443,44 +401,55 @@ export class LRUCache {
|
|
|
443
401
|
this.#ttls = ttls;
|
|
444
402
|
this.#starts = starts;
|
|
445
403
|
const purgeTimers = this.ttlAutopurge ?
|
|
446
|
-
|
|
404
|
+
Array.from({
|
|
405
|
+
length: this.#max,
|
|
406
|
+
})
|
|
447
407
|
: undefined;
|
|
448
408
|
this.#autopurgeTimers = purgeTimers;
|
|
449
409
|
this.#setItemTTL = (index, ttl, start = this.#perf.now()) => {
|
|
450
410
|
starts[index] = ttl !== 0 ? start : 0;
|
|
451
411
|
ttls[index] = ttl;
|
|
452
|
-
|
|
453
|
-
// previously had a ttl purge timer running, so it doesn't
|
|
454
|
-
// fire unnecessarily.
|
|
455
|
-
if (purgeTimers?.[index]) {
|
|
456
|
-
clearTimeout(purgeTimers[index]);
|
|
457
|
-
purgeTimers[index] = undefined;
|
|
458
|
-
}
|
|
459
|
-
if (ttl !== 0 && purgeTimers) {
|
|
460
|
-
const t = setTimeout(() => {
|
|
461
|
-
if (this.#isStale(index)) {
|
|
462
|
-
this.#delete(this.#keyList[index], 'expire');
|
|
463
|
-
}
|
|
464
|
-
}, ttl + 1);
|
|
465
|
-
// unref() not supported on all platforms
|
|
466
|
-
/* c8 ignore start */
|
|
467
|
-
if (t.unref) {
|
|
468
|
-
t.unref();
|
|
469
|
-
}
|
|
470
|
-
/* c8 ignore stop */
|
|
471
|
-
purgeTimers[index] = t;
|
|
472
|
-
}
|
|
412
|
+
setPurgetTimer(index, ttl);
|
|
473
413
|
};
|
|
474
414
|
this.#updateItemAge = index => {
|
|
475
415
|
starts[index] = ttls[index] !== 0 ? this.#perf.now() : 0;
|
|
416
|
+
setPurgetTimer(index, ttls[index]);
|
|
476
417
|
};
|
|
418
|
+
// clear out the purge timer if we're setting TTL to 0, and
|
|
419
|
+
// previously had a ttl purge timer running, so it doesn't
|
|
420
|
+
// fire unnecessarily. Don't need to do this if we're not doing
|
|
421
|
+
// autopurge.
|
|
422
|
+
const setPurgetTimer = !this.ttlAutopurge ?
|
|
423
|
+
() => { }
|
|
424
|
+
: (index, ttl) => {
|
|
425
|
+
if (purgeTimers?.[index]) {
|
|
426
|
+
clearTimeout(purgeTimers[index]);
|
|
427
|
+
purgeTimers[index] = undefined;
|
|
428
|
+
}
|
|
429
|
+
if (ttl && ttl !== 0 && purgeTimers) {
|
|
430
|
+
const t = setTimeout(() => {
|
|
431
|
+
if (this.#isStale(index)) {
|
|
432
|
+
this.#delete(this.#keyList[index], 'expire');
|
|
433
|
+
}
|
|
434
|
+
}, ttl + 1);
|
|
435
|
+
// unref() not supported on all platforms
|
|
436
|
+
/* c8 ignore start */
|
|
437
|
+
if (t.unref) {
|
|
438
|
+
t.unref();
|
|
439
|
+
}
|
|
440
|
+
/* c8 ignore stop */
|
|
441
|
+
purgeTimers[index] = t;
|
|
442
|
+
}
|
|
443
|
+
};
|
|
477
444
|
this.#statusTTL = (status, index) => {
|
|
478
445
|
if (ttls[index]) {
|
|
479
446
|
const ttl = ttls[index];
|
|
480
447
|
const start = starts[index];
|
|
481
|
-
/* c8 ignore
|
|
482
|
-
if (!ttl || !start)
|
|
448
|
+
/* c8 ignore start */
|
|
449
|
+
if (!ttl || !start) {
|
|
483
450
|
return;
|
|
451
|
+
}
|
|
452
|
+
/* c8 ignore stop */
|
|
484
453
|
status.ttl = ttl;
|
|
485
454
|
status.start = start;
|
|
486
455
|
status.now = cachedNow || getNow();
|
|
@@ -539,12 +508,15 @@ export class LRUCache {
|
|
|
539
508
|
sizes[index] = 0;
|
|
540
509
|
};
|
|
541
510
|
this.#requireSize = (k, v, size, sizeCalculation) => {
|
|
542
|
-
// provisionally accept background fetches.
|
|
543
|
-
// actual value size will be checked when they return.
|
|
544
|
-
if (this.#isBackgroundFetch(v)) {
|
|
545
|
-
return 0;
|
|
546
|
-
}
|
|
547
511
|
if (!isPosInt(size)) {
|
|
512
|
+
// provisionally accept background fetches.
|
|
513
|
+
// actual value size will be checked when they return.
|
|
514
|
+
if (this.#isBackgroundFetch(v)) {
|
|
515
|
+
// NB: this cannot occur if v.__staleWhileFetching is set,
|
|
516
|
+
// because in that case, it would take on the size of the
|
|
517
|
+
// existing entry that it temporarily replaces.
|
|
518
|
+
return this.backgroundFetchSize;
|
|
519
|
+
}
|
|
548
520
|
if (sizeCalculation) {
|
|
549
521
|
if (typeof sizeCalculation !== 'function') {
|
|
550
522
|
throw new TypeError('sizeCalculation must be a function');
|
|
@@ -587,10 +559,7 @@ export class LRUCache {
|
|
|
587
559
|
};
|
|
588
560
|
*#indexes({ allowStale = this.allowStale } = {}) {
|
|
589
561
|
if (this.#size) {
|
|
590
|
-
for (let i = this.#tail;
|
|
591
|
-
if (!this.#isValidIndex(i)) {
|
|
592
|
-
break;
|
|
593
|
-
}
|
|
562
|
+
for (let i = this.#tail; this.#isValidIndex(i);) {
|
|
594
563
|
if (allowStale || !this.#isStale(i)) {
|
|
595
564
|
yield i;
|
|
596
565
|
}
|
|
@@ -605,10 +574,7 @@ export class LRUCache {
|
|
|
605
574
|
}
|
|
606
575
|
*#rindexes({ allowStale = this.allowStale } = {}) {
|
|
607
576
|
if (this.#size) {
|
|
608
|
-
for (let i = this.#head;
|
|
609
|
-
if (!this.#isValidIndex(i)) {
|
|
610
|
-
break;
|
|
611
|
-
}
|
|
577
|
+
for (let i = this.#head; this.#isValidIndex(i);) {
|
|
612
578
|
if (allowStale || !this.#isStale(i)) {
|
|
613
579
|
yield i;
|
|
614
580
|
}
|
|
@@ -729,7 +695,7 @@ export class LRUCache {
|
|
|
729
695
|
if (value === undefined)
|
|
730
696
|
continue;
|
|
731
697
|
if (fn(value, this.#keyList[i], this)) {
|
|
732
|
-
return this
|
|
698
|
+
return this.#get(this.#keyList[i], getOptions);
|
|
733
699
|
}
|
|
734
700
|
}
|
|
735
701
|
}
|
|
@@ -802,7 +768,7 @@ export class LRUCache {
|
|
|
802
768
|
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
803
769
|
if (value === undefined)
|
|
804
770
|
return undefined;
|
|
805
|
-
/* c8 ignore
|
|
771
|
+
/* c8 ignore stop */
|
|
806
772
|
const entry = { value };
|
|
807
773
|
if (this.#ttls && this.#starts) {
|
|
808
774
|
const ttl = this.#ttls[i];
|
|
@@ -876,7 +842,7 @@ export class LRUCache {
|
|
|
876
842
|
const age = Date.now() - entry.start;
|
|
877
843
|
entry.start = this.#perf.now() - age;
|
|
878
844
|
}
|
|
879
|
-
this
|
|
845
|
+
this.#set(key, entry.value, entry);
|
|
880
846
|
}
|
|
881
847
|
}
|
|
882
848
|
/**
|
|
@@ -910,22 +876,43 @@ export class LRUCache {
|
|
|
910
876
|
* `cache.delete(key)`. `undefined` is never stored in the cache.
|
|
911
877
|
*/
|
|
912
878
|
set(k, v, setOptions = {}) {
|
|
879
|
+
const { status = metrics.hasSubscribers ? {} : undefined } = setOptions;
|
|
880
|
+
setOptions.status = status;
|
|
881
|
+
if (status) {
|
|
882
|
+
status.op = 'set';
|
|
883
|
+
status.key = k;
|
|
884
|
+
if (v !== undefined)
|
|
885
|
+
status.value = v;
|
|
886
|
+
status.cache = this;
|
|
887
|
+
}
|
|
888
|
+
const result = this.#set(k, v, setOptions);
|
|
889
|
+
if (status && metrics.hasSubscribers) {
|
|
890
|
+
metrics.publish(status);
|
|
891
|
+
}
|
|
892
|
+
return result;
|
|
893
|
+
}
|
|
894
|
+
#set(k, v, setOptions, bf) {
|
|
895
|
+
const { ttl = this.ttl, start, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status, } = setOptions;
|
|
896
|
+
const isBF = this.#isBackgroundFetch(v);
|
|
913
897
|
if (v === undefined) {
|
|
898
|
+
if (status)
|
|
899
|
+
status.set = 'deleted';
|
|
914
900
|
this.delete(k);
|
|
915
901
|
return this;
|
|
916
902
|
}
|
|
917
|
-
const { ttl = this.ttl, start, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status, } = setOptions;
|
|
918
903
|
let { noUpdateTTL = this.noUpdateTTL } = setOptions;
|
|
919
|
-
|
|
904
|
+
if (status && !isBF)
|
|
905
|
+
status.value = v;
|
|
906
|
+
const size = this.#requireSize(k, v, setOptions.size || 0, sizeCalculation, status);
|
|
920
907
|
// if the item doesn't fit, don't do anything
|
|
921
908
|
// NB: maxEntrySize set to maxSize by default
|
|
922
909
|
if (this.maxEntrySize && size > this.maxEntrySize) {
|
|
910
|
+
// have to delete, in case something is there already.
|
|
911
|
+
this.#delete(k, 'set');
|
|
923
912
|
if (status) {
|
|
924
913
|
status.set = 'miss';
|
|
925
914
|
status.maxEntrySizeExceeded = true;
|
|
926
915
|
}
|
|
927
|
-
// have to delete, in case something is there already.
|
|
928
|
-
this.#delete(k, 'set');
|
|
929
916
|
return this;
|
|
930
917
|
}
|
|
931
918
|
let index = this.#size === 0 ? undefined : this.#keyMap.get(k);
|
|
@@ -946,52 +933,68 @@ export class LRUCache {
|
|
|
946
933
|
if (status)
|
|
947
934
|
status.set = 'add';
|
|
948
935
|
noUpdateTTL = false;
|
|
949
|
-
if (this.#hasOnInsert) {
|
|
936
|
+
if (this.#hasOnInsert && !isBF) {
|
|
950
937
|
this.#onInsert?.(v, k, 'add');
|
|
951
938
|
}
|
|
952
939
|
}
|
|
953
940
|
else {
|
|
954
941
|
// update
|
|
942
|
+
// might be updating a background fetch!
|
|
955
943
|
this.#moveToTail(index);
|
|
956
944
|
const oldVal = this.#valList[index];
|
|
957
945
|
if (v !== oldVal) {
|
|
958
|
-
if (
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
946
|
+
if (!noDisposeOnSet) {
|
|
947
|
+
if (this.#isBackgroundFetch(oldVal)) {
|
|
948
|
+
if (oldVal !== bf) {
|
|
949
|
+
// setting over a background fetch, not merely resolving it.
|
|
950
|
+
oldVal.__abortController.abort(new Error('replaced'));
|
|
951
|
+
}
|
|
952
|
+
const { __staleWhileFetching: s } = oldVal;
|
|
953
|
+
if (s !== undefined && s !== v) {
|
|
954
|
+
if (this.#hasDispose) {
|
|
955
|
+
this.#dispose?.(s, k, 'set');
|
|
956
|
+
}
|
|
957
|
+
if (this.#hasDisposeAfter) {
|
|
958
|
+
this.#disposed?.push([s, k, 'set']);
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
else {
|
|
962
963
|
if (this.#hasDispose) {
|
|
963
|
-
this.#dispose?.(
|
|
964
|
+
this.#dispose?.(oldVal, k, 'set');
|
|
964
965
|
}
|
|
965
966
|
if (this.#hasDisposeAfter) {
|
|
966
|
-
this.#disposed?.push([
|
|
967
|
+
this.#disposed?.push([oldVal, k, 'set']);
|
|
967
968
|
}
|
|
968
969
|
}
|
|
969
970
|
}
|
|
970
|
-
else if (!noDisposeOnSet) {
|
|
971
|
-
if (this.#hasDispose) {
|
|
972
|
-
this.#dispose?.(oldVal, k, 'set');
|
|
973
|
-
}
|
|
974
|
-
if (this.#hasDisposeAfter) {
|
|
975
|
-
this.#disposed?.push([oldVal, k, 'set']);
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
971
|
this.#removeItemSize(index);
|
|
979
972
|
this.#addItemSize(index, size, status);
|
|
980
973
|
this.#valList[index] = v;
|
|
981
|
-
if (
|
|
982
|
-
status.set = 'replace';
|
|
974
|
+
if (!isBF) {
|
|
983
975
|
const oldValue = oldVal && this.#isBackgroundFetch(oldVal) ?
|
|
984
976
|
oldVal.__staleWhileFetching
|
|
985
977
|
: oldVal;
|
|
986
|
-
|
|
987
|
-
|
|
978
|
+
const setType = oldValue === undefined ? 'add'
|
|
979
|
+
: v !== oldValue ? 'replace'
|
|
980
|
+
: 'update';
|
|
981
|
+
if (status) {
|
|
982
|
+
status.set = setType;
|
|
983
|
+
if (oldValue !== undefined)
|
|
984
|
+
status.oldValue = oldValue;
|
|
985
|
+
}
|
|
986
|
+
if (this.#hasOnInsert) {
|
|
987
|
+
this.onInsert?.(v, k, setType);
|
|
988
|
+
}
|
|
988
989
|
}
|
|
989
990
|
}
|
|
990
|
-
else if (
|
|
991
|
-
status
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
this
|
|
991
|
+
else if (!isBF) {
|
|
992
|
+
if (status) {
|
|
993
|
+
status.set = 'update';
|
|
994
|
+
}
|
|
995
|
+
if (this.#hasOnInsert) {
|
|
996
|
+
this.onInsert?.(v, k, 'update');
|
|
997
|
+
}
|
|
995
998
|
}
|
|
996
999
|
}
|
|
997
1000
|
if (ttl !== 0 && !this.#ttls) {
|
|
@@ -1046,15 +1049,18 @@ export class LRUCache {
|
|
|
1046
1049
|
const head = this.#head;
|
|
1047
1050
|
const k = this.#keyList[head];
|
|
1048
1051
|
const v = this.#valList[head];
|
|
1049
|
-
|
|
1052
|
+
const isBF = this.#isBackgroundFetch(v);
|
|
1053
|
+
if (isBF) {
|
|
1050
1054
|
v.__abortController.abort(new Error('evicted'));
|
|
1051
1055
|
}
|
|
1052
|
-
|
|
1056
|
+
const oldValue = isBF ? v.__staleWhileFetching : v;
|
|
1057
|
+
if ((this.#hasDispose || this.#hasDisposeAfter) &&
|
|
1058
|
+
oldValue !== undefined) {
|
|
1053
1059
|
if (this.#hasDispose) {
|
|
1054
|
-
this.#dispose?.(
|
|
1060
|
+
this.#dispose?.(oldValue, k, 'evict');
|
|
1055
1061
|
}
|
|
1056
1062
|
if (this.#hasDisposeAfter) {
|
|
1057
|
-
this.#disposed?.push([
|
|
1063
|
+
this.#disposed?.push([oldValue, k, 'evict']);
|
|
1058
1064
|
}
|
|
1059
1065
|
}
|
|
1060
1066
|
this.#removeItemSize(head);
|
|
@@ -1096,6 +1102,19 @@ export class LRUCache {
|
|
|
1096
1102
|
* {@link LRUCache.OptionsBase.updateAgeOnHas} is set.
|
|
1097
1103
|
*/
|
|
1098
1104
|
has(k, hasOptions = {}) {
|
|
1105
|
+
const { status = metrics.hasSubscribers ? {} : undefined } = hasOptions;
|
|
1106
|
+
hasOptions.status = status;
|
|
1107
|
+
if (status) {
|
|
1108
|
+
status.op = 'has';
|
|
1109
|
+
status.key = k;
|
|
1110
|
+
status.cache = this;
|
|
1111
|
+
}
|
|
1112
|
+
const result = this.#has(k, hasOptions);
|
|
1113
|
+
if (metrics.hasSubscribers)
|
|
1114
|
+
metrics.publish(status);
|
|
1115
|
+
return result;
|
|
1116
|
+
}
|
|
1117
|
+
#has(k, hasOptions = {}) {
|
|
1099
1118
|
const { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions;
|
|
1100
1119
|
const index = this.#keyMap.get(k);
|
|
1101
1120
|
if (index !== undefined) {
|
|
@@ -1132,21 +1151,46 @@ export class LRUCache {
|
|
|
1132
1151
|
* {@link LRUCache.OptionsBase.allowStale} is set.
|
|
1133
1152
|
*/
|
|
1134
1153
|
peek(k, peekOptions = {}) {
|
|
1135
|
-
const {
|
|
1154
|
+
const { status = hasSubscribers() ? {} : undefined } = peekOptions;
|
|
1155
|
+
if (status) {
|
|
1156
|
+
status.op = 'peek';
|
|
1157
|
+
status.key = k;
|
|
1158
|
+
status.cache = this;
|
|
1159
|
+
}
|
|
1160
|
+
peekOptions.status = status;
|
|
1161
|
+
const result = this.#peek(k, peekOptions);
|
|
1162
|
+
if (metrics.hasSubscribers) {
|
|
1163
|
+
metrics.publish(status);
|
|
1164
|
+
}
|
|
1165
|
+
return result;
|
|
1166
|
+
}
|
|
1167
|
+
#peek(k, peekOptions) {
|
|
1168
|
+
const { status, allowStale = this.allowStale } = peekOptions;
|
|
1136
1169
|
const index = this.#keyMap.get(k);
|
|
1137
1170
|
if (index === undefined || (!allowStale && this.#isStale(index))) {
|
|
1138
|
-
|
|
1171
|
+
if (status)
|
|
1172
|
+
status.peek = index === undefined ? 'miss' : 'stale';
|
|
1173
|
+
return undefined;
|
|
1139
1174
|
}
|
|
1140
1175
|
const v = this.#valList[index];
|
|
1141
|
-
|
|
1142
|
-
|
|
1176
|
+
const val = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
1177
|
+
if (status) {
|
|
1178
|
+
if (val !== undefined) {
|
|
1179
|
+
status.peek = 'hit';
|
|
1180
|
+
status.value = val;
|
|
1181
|
+
}
|
|
1182
|
+
else {
|
|
1183
|
+
status.peek = 'miss';
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
return val;
|
|
1143
1187
|
}
|
|
1144
1188
|
#backgroundFetch(k, index, options, context) {
|
|
1145
1189
|
const v = index === undefined ? undefined : this.#valList[index];
|
|
1146
1190
|
if (this.#isBackgroundFetch(v)) {
|
|
1147
1191
|
return v;
|
|
1148
1192
|
}
|
|
1149
|
-
const ac = new
|
|
1193
|
+
const ac = new AbortController();
|
|
1150
1194
|
const { signal } = options;
|
|
1151
1195
|
// when/if our AC signals, then stop listening to theirs.
|
|
1152
1196
|
signal?.addEventListener('abort', () => ac.abort(signal.reason), {
|
|
@@ -1182,7 +1226,7 @@ export class LRUCache {
|
|
|
1182
1226
|
// cache and ignore the abort, or if it's still pending on this specific
|
|
1183
1227
|
// background request, then write it to the cache.
|
|
1184
1228
|
const vl = this.#valList[index];
|
|
1185
|
-
if (vl === p || (
|
|
1229
|
+
if (vl === p || (vl === undefined && ignoreAbort && updateCache)) {
|
|
1186
1230
|
if (v === undefined) {
|
|
1187
1231
|
if (bf.__staleWhileFetching !== undefined) {
|
|
1188
1232
|
this.#valList[index] = bf.__staleWhileFetching;
|
|
@@ -1194,7 +1238,7 @@ export class LRUCache {
|
|
|
1194
1238
|
else {
|
|
1195
1239
|
if (options.status)
|
|
1196
1240
|
options.status.fetchUpdated = true;
|
|
1197
|
-
this
|
|
1241
|
+
this.#set(k, v, fetchOpts.options, bf);
|
|
1198
1242
|
}
|
|
1199
1243
|
}
|
|
1200
1244
|
return v;
|
|
@@ -1216,8 +1260,7 @@ export class LRUCache {
|
|
|
1216
1260
|
if (this.#valList[index] === p) {
|
|
1217
1261
|
// if we allow stale on fetch rejections, then we need to ensure that
|
|
1218
1262
|
// the stale value is not removed from the cache when the fetch fails.
|
|
1219
|
-
const del = !noDelete ||
|
|
1220
|
-
!proceed && bf.__staleWhileFetching === undefined;
|
|
1263
|
+
const del = !noDelete || (!proceed && bf.__staleWhileFetching === undefined);
|
|
1221
1264
|
if (del) {
|
|
1222
1265
|
this.#delete(k, 'fetch');
|
|
1223
1266
|
}
|
|
@@ -1241,9 +1284,6 @@ export class LRUCache {
|
|
|
1241
1284
|
};
|
|
1242
1285
|
const pcall = (res, rej) => {
|
|
1243
1286
|
const fmp = this.#fetchMethod?.(k, v, fetchOpts);
|
|
1244
|
-
if (fmp && fmp instanceof Promise) {
|
|
1245
|
-
fmp.then(v => res(v === undefined ? undefined : v), rej);
|
|
1246
|
-
}
|
|
1247
1287
|
// ignored, we go until we finish, regardless.
|
|
1248
1288
|
// defer check until we are actually aborting,
|
|
1249
1289
|
// so fetchMethod can override.
|
|
@@ -1256,6 +1296,12 @@ export class LRUCache {
|
|
|
1256
1296
|
}
|
|
1257
1297
|
}
|
|
1258
1298
|
});
|
|
1299
|
+
if (fmp && fmp instanceof Promise) {
|
|
1300
|
+
fmp.then(v => res(v === undefined ? undefined : v), rej);
|
|
1301
|
+
}
|
|
1302
|
+
else if (fmp !== undefined) {
|
|
1303
|
+
res(fmp);
|
|
1304
|
+
}
|
|
1259
1305
|
};
|
|
1260
1306
|
if (options.status)
|
|
1261
1307
|
options.status.fetchDispatched = true;
|
|
@@ -1267,10 +1313,14 @@ export class LRUCache {
|
|
|
1267
1313
|
});
|
|
1268
1314
|
if (index === undefined) {
|
|
1269
1315
|
// internal, don't expose status.
|
|
1270
|
-
this
|
|
1316
|
+
this.#set(k, bf, { ...fetchOpts.options, status: undefined });
|
|
1271
1317
|
index = this.#keyMap.get(k);
|
|
1272
1318
|
}
|
|
1273
1319
|
else {
|
|
1320
|
+
// do not call #set, because we do not want to adjust its place
|
|
1321
|
+
// in the lru queue, as it has not yet been "used". Also, we don't
|
|
1322
|
+
// need to worry about evicting for size, because a background fetch
|
|
1323
|
+
// over a stale value is treated as the same size as its stale value.
|
|
1274
1324
|
this.#valList[index] = bf;
|
|
1275
1325
|
}
|
|
1276
1326
|
return bf;
|
|
@@ -1282,9 +1332,23 @@ export class LRUCache {
|
|
|
1282
1332
|
return (!!b &&
|
|
1283
1333
|
b instanceof Promise &&
|
|
1284
1334
|
b.hasOwnProperty('__staleWhileFetching') &&
|
|
1285
|
-
b.__abortController instanceof
|
|
1335
|
+
b.__abortController instanceof AbortController);
|
|
1286
1336
|
}
|
|
1287
|
-
|
|
1337
|
+
fetch(k, fetchOptions = {}) {
|
|
1338
|
+
const ths = tracing.hasSubscribers;
|
|
1339
|
+
const { status = hasSubscribers() ? {} : undefined } = fetchOptions;
|
|
1340
|
+
fetchOptions.status = status;
|
|
1341
|
+
if (status && fetchOptions.context) {
|
|
1342
|
+
status.context = fetchOptions.context;
|
|
1343
|
+
}
|
|
1344
|
+
const p = this.#fetch(k, fetchOptions);
|
|
1345
|
+
if (status && ths) {
|
|
1346
|
+
status.trace = true;
|
|
1347
|
+
tracing.tracePromise(() => p, status).catch(() => { });
|
|
1348
|
+
}
|
|
1349
|
+
return p;
|
|
1350
|
+
}
|
|
1351
|
+
async #fetch(k, fetchOptions = {}) {
|
|
1288
1352
|
const {
|
|
1289
1353
|
// get options
|
|
1290
1354
|
allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet,
|
|
@@ -1292,10 +1356,17 @@ export class LRUCache {
|
|
|
1292
1356
|
ttl = this.ttl, noDisposeOnSet = this.noDisposeOnSet, size = 0, sizeCalculation = this.sizeCalculation, noUpdateTTL = this.noUpdateTTL,
|
|
1293
1357
|
// fetch exclusive options
|
|
1294
1358
|
noDeleteOnFetchRejection = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection = this.allowStaleOnFetchRejection, ignoreFetchAbort = this.ignoreFetchAbort, allowStaleOnFetchAbort = this.allowStaleOnFetchAbort, context, forceRefresh = false, status, signal, } = fetchOptions;
|
|
1359
|
+
if (status) {
|
|
1360
|
+
status.op = 'fetch';
|
|
1361
|
+
status.key = k;
|
|
1362
|
+
if (forceRefresh)
|
|
1363
|
+
status.forceRefresh = true;
|
|
1364
|
+
status.cache = this;
|
|
1365
|
+
}
|
|
1295
1366
|
if (!this.#hasFetchMethod) {
|
|
1296
1367
|
if (status)
|
|
1297
1368
|
status.fetch = 'get';
|
|
1298
|
-
return this
|
|
1369
|
+
return this.#get(k, {
|
|
1299
1370
|
allowStale,
|
|
1300
1371
|
updateAgeOnGet,
|
|
1301
1372
|
noDeleteOnStaleGet,
|
|
@@ -1364,26 +1435,68 @@ export class LRUCache {
|
|
|
1364
1435
|
return staleVal ? p.__staleWhileFetching : (p.__returned = p);
|
|
1365
1436
|
}
|
|
1366
1437
|
}
|
|
1367
|
-
|
|
1368
|
-
const
|
|
1438
|
+
forceFetch(k, fetchOptions = {}) {
|
|
1439
|
+
const ths = tracing.hasSubscribers;
|
|
1440
|
+
const { status = hasSubscribers() ? {} : undefined } = fetchOptions;
|
|
1441
|
+
fetchOptions.status = status;
|
|
1442
|
+
if (status && fetchOptions.context) {
|
|
1443
|
+
status.context = fetchOptions.context;
|
|
1444
|
+
}
|
|
1445
|
+
const p = this.#forceFetch(k, fetchOptions);
|
|
1446
|
+
if (status && ths) {
|
|
1447
|
+
status.trace = true;
|
|
1448
|
+
tracing.tracePromise(() => p, status).catch(() => { });
|
|
1449
|
+
}
|
|
1450
|
+
return p;
|
|
1451
|
+
}
|
|
1452
|
+
async #forceFetch(k, fetchOptions = {}) {
|
|
1453
|
+
const v = await this.#fetch(k, fetchOptions);
|
|
1369
1454
|
if (v === undefined)
|
|
1370
1455
|
throw new Error('fetch() returned undefined');
|
|
1371
1456
|
return v;
|
|
1372
1457
|
}
|
|
1373
1458
|
memo(k, memoOptions = {}) {
|
|
1459
|
+
const { status = metrics.hasSubscribers ? {} : undefined } = memoOptions;
|
|
1460
|
+
memoOptions.status = status;
|
|
1461
|
+
if (status) {
|
|
1462
|
+
status.op = 'memo';
|
|
1463
|
+
status.key = k;
|
|
1464
|
+
if (memoOptions.context) {
|
|
1465
|
+
status.context = memoOptions.context;
|
|
1466
|
+
}
|
|
1467
|
+
status.cache = this;
|
|
1468
|
+
}
|
|
1469
|
+
const result = this.#memo(k, memoOptions);
|
|
1470
|
+
if (status)
|
|
1471
|
+
status.value = result;
|
|
1472
|
+
if (metrics.hasSubscribers)
|
|
1473
|
+
metrics.publish(status);
|
|
1474
|
+
return result;
|
|
1475
|
+
}
|
|
1476
|
+
#memo(k, memoOptions = {}) {
|
|
1374
1477
|
const memoMethod = this.#memoMethod;
|
|
1375
1478
|
if (!memoMethod) {
|
|
1376
1479
|
throw new Error('no memoMethod provided to constructor');
|
|
1377
1480
|
}
|
|
1378
|
-
const { context, forceRefresh, ...options } = memoOptions;
|
|
1379
|
-
|
|
1380
|
-
|
|
1481
|
+
const { context, status, forceRefresh, ...options } = memoOptions;
|
|
1482
|
+
if (status && forceRefresh)
|
|
1483
|
+
status.forceRefresh = true;
|
|
1484
|
+
const v = this.#get(k, options);
|
|
1485
|
+
const refresh = forceRefresh || v === undefined;
|
|
1486
|
+
if (status) {
|
|
1487
|
+
status.memo = refresh ? 'miss' : 'hit';
|
|
1488
|
+
if (!refresh)
|
|
1489
|
+
status.value = v;
|
|
1490
|
+
}
|
|
1491
|
+
if (!refresh)
|
|
1381
1492
|
return v;
|
|
1382
1493
|
const vv = memoMethod(k, v, {
|
|
1383
1494
|
options,
|
|
1384
1495
|
context,
|
|
1385
1496
|
});
|
|
1386
|
-
|
|
1497
|
+
if (status)
|
|
1498
|
+
status.value = vv;
|
|
1499
|
+
this.#set(k, vv, options);
|
|
1387
1500
|
return vv;
|
|
1388
1501
|
}
|
|
1389
1502
|
/**
|
|
@@ -1393,55 +1506,71 @@ export class LRUCache {
|
|
|
1393
1506
|
* If the key is not found, get() will return `undefined`.
|
|
1394
1507
|
*/
|
|
1395
1508
|
get(k, getOptions = {}) {
|
|
1509
|
+
const { status = metrics.hasSubscribers ? {} : undefined } = getOptions;
|
|
1510
|
+
getOptions.status = status;
|
|
1511
|
+
if (status) {
|
|
1512
|
+
status.op = 'get';
|
|
1513
|
+
status.key = k;
|
|
1514
|
+
status.cache = this;
|
|
1515
|
+
}
|
|
1516
|
+
const result = this.#get(k, getOptions);
|
|
1517
|
+
if (status) {
|
|
1518
|
+
if (result !== undefined)
|
|
1519
|
+
status.value = result;
|
|
1520
|
+
if (metrics.hasSubscribers)
|
|
1521
|
+
metrics.publish(status);
|
|
1522
|
+
}
|
|
1523
|
+
return result;
|
|
1524
|
+
}
|
|
1525
|
+
#get(k, getOptions = {}) {
|
|
1396
1526
|
const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status, } = getOptions;
|
|
1397
1527
|
const index = this.#keyMap.get(k);
|
|
1398
|
-
if (index
|
|
1399
|
-
const value = this.#valList[index];
|
|
1400
|
-
const fetching = this.#isBackgroundFetch(value);
|
|
1528
|
+
if (index === undefined) {
|
|
1401
1529
|
if (status)
|
|
1402
|
-
|
|
1403
|
-
|
|
1530
|
+
status.get = 'miss';
|
|
1531
|
+
return undefined;
|
|
1532
|
+
}
|
|
1533
|
+
const value = this.#valList[index];
|
|
1534
|
+
const fetching = this.#isBackgroundFetch(value);
|
|
1535
|
+
if (status)
|
|
1536
|
+
this.#statusTTL(status, index);
|
|
1537
|
+
if (this.#isStale(index)) {
|
|
1538
|
+
// delete only if not an in-flight background fetch
|
|
1539
|
+
if (!fetching) {
|
|
1540
|
+
if (!noDeleteOnStaleGet) {
|
|
1541
|
+
this.#delete(k, 'expire');
|
|
1542
|
+
}
|
|
1404
1543
|
if (status)
|
|
1405
1544
|
status.get = 'stale';
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
if (!noDeleteOnStaleGet) {
|
|
1409
|
-
this.#delete(k, 'expire');
|
|
1410
|
-
}
|
|
1411
|
-
if (status && allowStale)
|
|
1412
|
-
status.returnedStale = true;
|
|
1413
|
-
return allowStale ? value : undefined;
|
|
1414
|
-
}
|
|
1415
|
-
else {
|
|
1416
|
-
if (status &&
|
|
1417
|
-
allowStale &&
|
|
1418
|
-
value.__staleWhileFetching !== undefined) {
|
|
1545
|
+
if (allowStale) {
|
|
1546
|
+
if (status)
|
|
1419
1547
|
status.returnedStale = true;
|
|
1420
|
-
|
|
1421
|
-
return allowStale ? value.__staleWhileFetching : undefined;
|
|
1548
|
+
return value;
|
|
1422
1549
|
}
|
|
1550
|
+
return undefined;
|
|
1423
1551
|
}
|
|
1424
|
-
|
|
1552
|
+
if (status)
|
|
1553
|
+
status.get = 'stale-fetching';
|
|
1554
|
+
if (allowStale && value.__staleWhileFetching !== undefined) {
|
|
1425
1555
|
if (status)
|
|
1426
|
-
status.
|
|
1427
|
-
|
|
1428
|
-
// it's not stale, which means this isn't a staleWhileRefetching.
|
|
1429
|
-
// If it's not stale, and fetching, AND has a __staleWhileFetching
|
|
1430
|
-
// value, then that means the user fetched with {forceRefresh:true},
|
|
1431
|
-
// so it's safe to return that value.
|
|
1432
|
-
if (fetching) {
|
|
1433
|
-
return value.__staleWhileFetching;
|
|
1434
|
-
}
|
|
1435
|
-
this.#moveToTail(index);
|
|
1436
|
-
if (updateAgeOnGet) {
|
|
1437
|
-
this.#updateItemAge(index);
|
|
1438
|
-
}
|
|
1439
|
-
return value;
|
|
1556
|
+
status.returnedStale = true;
|
|
1557
|
+
return value.__staleWhileFetching;
|
|
1440
1558
|
}
|
|
1559
|
+
return undefined;
|
|
1441
1560
|
}
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1561
|
+
// not stale
|
|
1562
|
+
if (status)
|
|
1563
|
+
status.get = fetching ? 'fetching' : 'hit';
|
|
1564
|
+
// if we're currently fetching it, we don't actually have it yet
|
|
1565
|
+
// it's not stale, which means this isn't a staleWhileRefetching.
|
|
1566
|
+
// If it's not stale, and fetching, AND has a __staleWhileFetching
|
|
1567
|
+
// value, then that means the user fetched with {forceRefresh:true},
|
|
1568
|
+
// so it's safe to return that value.
|
|
1569
|
+
this.#moveToTail(index);
|
|
1570
|
+
if (updateAgeOnGet) {
|
|
1571
|
+
this.#updateItemAge(index);
|
|
1572
|
+
}
|
|
1573
|
+
return fetching ? value.__staleWhileFetching : value;
|
|
1445
1574
|
}
|
|
1446
1575
|
#connect(p, n) {
|
|
1447
1576
|
this.#prev[n] = p;
|
|
@@ -1476,6 +1605,14 @@ export class LRUCache {
|
|
|
1476
1605
|
return this.#delete(k, 'delete');
|
|
1477
1606
|
}
|
|
1478
1607
|
#delete(k, reason) {
|
|
1608
|
+
if (metrics.hasSubscribers) {
|
|
1609
|
+
metrics.publish({
|
|
1610
|
+
op: 'delete',
|
|
1611
|
+
delete: reason,
|
|
1612
|
+
key: k,
|
|
1613
|
+
cache: this,
|
|
1614
|
+
});
|
|
1615
|
+
}
|
|
1479
1616
|
let deleted = false;
|
|
1480
1617
|
if (this.#size !== 0) {
|
|
1481
1618
|
const index = this.#keyMap.get(k);
|
|
@@ -1554,7 +1691,7 @@ export class LRUCache {
|
|
|
1554
1691
|
}
|
|
1555
1692
|
}
|
|
1556
1693
|
this.#keyMap.clear();
|
|
1557
|
-
this.#valList.fill(undefined);
|
|
1694
|
+
void this.#valList.fill(undefined);
|
|
1558
1695
|
this.#keyList.fill(undefined);
|
|
1559
1696
|
if (this.#ttls && this.#starts) {
|
|
1560
1697
|
this.#ttls.fill(0);
|