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
|
@@ -4,75 +4,27 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.LRUCache = void 0;
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
performance
|
|
11
|
-
: Date;
|
|
7
|
+
const diagnostics_channel_js_1 = require("./diagnostics-channel.js");
|
|
8
|
+
const perf_js_1 = require("./perf.js");
|
|
9
|
+
const hasSubscribers = () => diagnostics_channel_js_1.metrics.hasSubscribers || diagnostics_channel_js_1.tracing.hasSubscribers;
|
|
12
10
|
const warned = new Set();
|
|
13
11
|
/* c8 ignore start */
|
|
14
12
|
const PROCESS = (typeof process === 'object' && !!process ?
|
|
15
13
|
process
|
|
16
14
|
: {});
|
|
17
|
-
/* c8 ignore
|
|
15
|
+
/* c8 ignore stop */
|
|
18
16
|
const emitWarning = (msg, type, code, fn) => {
|
|
19
|
-
typeof PROCESS.emitWarning === 'function'
|
|
20
|
-
PROCESS.emitWarning(msg, type, code, fn)
|
|
21
|
-
|
|
17
|
+
if (typeof PROCESS.emitWarning === 'function') {
|
|
18
|
+
PROCESS.emitWarning(msg, type, code, fn);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
//oxlint-disable-next-line no-console
|
|
22
|
+
console.error(`[${code}] ${type}: ${msg}`);
|
|
23
|
+
}
|
|
22
24
|
};
|
|
23
|
-
let AC = globalThis.AbortController;
|
|
24
|
-
let AS = globalThis.AbortSignal;
|
|
25
|
-
/* c8 ignore start */
|
|
26
|
-
if (typeof AC === 'undefined') {
|
|
27
|
-
//@ts-ignore
|
|
28
|
-
AS = class AbortSignal {
|
|
29
|
-
onabort;
|
|
30
|
-
_onabort = [];
|
|
31
|
-
reason;
|
|
32
|
-
aborted = false;
|
|
33
|
-
addEventListener(_, fn) {
|
|
34
|
-
this._onabort.push(fn);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
//@ts-ignore
|
|
38
|
-
AC = class AbortController {
|
|
39
|
-
constructor() {
|
|
40
|
-
warnACPolyfill();
|
|
41
|
-
}
|
|
42
|
-
signal = new AS();
|
|
43
|
-
abort(reason) {
|
|
44
|
-
if (this.signal.aborted)
|
|
45
|
-
return;
|
|
46
|
-
//@ts-ignore
|
|
47
|
-
this.signal.reason = reason;
|
|
48
|
-
//@ts-ignore
|
|
49
|
-
this.signal.aborted = true;
|
|
50
|
-
//@ts-ignore
|
|
51
|
-
for (const fn of this.signal._onabort) {
|
|
52
|
-
fn(reason);
|
|
53
|
-
}
|
|
54
|
-
this.signal.onabort?.(reason);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== '1';
|
|
58
|
-
const warnACPolyfill = () => {
|
|
59
|
-
if (!printACPolyfillWarning)
|
|
60
|
-
return;
|
|
61
|
-
printACPolyfillWarning = false;
|
|
62
|
-
emitWarning('AbortController is not defined. If using lru-cache in ' +
|
|
63
|
-
'node 14, load an AbortController polyfill from the ' +
|
|
64
|
-
'`node-abort-controller` package. A minimal polyfill is ' +
|
|
65
|
-
'provided for use by LRUCache.fetch(), but it should not be ' +
|
|
66
|
-
'relied upon in other contexts (eg, passing it to other APIs that ' +
|
|
67
|
-
'use AbortController/AbortSignal might have undesirable effects). ' +
|
|
68
|
-
'You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.', 'NO_ABORT_CONTROLLER', 'ENOTSUP', warnACPolyfill);
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
/* c8 ignore stop */
|
|
72
25
|
const shouldWarn = (code) => !warned.has(code);
|
|
73
26
|
const TYPE = Symbol('type');
|
|
74
|
-
const isPosInt = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n);
|
|
75
|
-
/* c8 ignore start */
|
|
27
|
+
const isPosInt = (n) => !!n && n === Math.floor(n) && n > 0 && isFinite(n);
|
|
76
28
|
// This is a little bit ridiculous, tbh.
|
|
77
29
|
// The maximum array length is 2^32-1 or thereabouts on most JS impls.
|
|
78
30
|
// And well before that point, you're caching the entire world, I mean,
|
|
@@ -81,6 +33,7 @@ const isPosInt = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n);
|
|
|
81
33
|
// zeroes at init time is brutal when you get that big.
|
|
82
34
|
// But why not be complete?
|
|
83
35
|
// Maybe in the future, these limits will have expanded.
|
|
36
|
+
/* c8 ignore start */
|
|
84
37
|
const getUintArray = (max) => !isPosInt(max) ? null
|
|
85
38
|
: max <= Math.pow(2, 8) ? Uint8Array
|
|
86
39
|
: max <= Math.pow(2, 16) ? Uint16Array
|
|
@@ -95,7 +48,9 @@ class ZeroArray extends Array {
|
|
|
95
48
|
}
|
|
96
49
|
}
|
|
97
50
|
class Stack {
|
|
51
|
+
/* c8 ignore start - not sure why this is showing up uncovered?? */
|
|
98
52
|
heap;
|
|
53
|
+
/* c8 ignore stop */
|
|
99
54
|
length;
|
|
100
55
|
// private constructor
|
|
101
56
|
static #constructing = false;
|
|
@@ -215,6 +170,8 @@ class LRUCache {
|
|
|
215
170
|
* {@link LRUCache.OptionsBase.ignoreFetchAbort}
|
|
216
171
|
*/
|
|
217
172
|
ignoreFetchAbort;
|
|
173
|
+
/** {@link LRUCache.OptionsBase.backgroundFetchSize} */
|
|
174
|
+
backgroundFetchSize;
|
|
218
175
|
// computed properties
|
|
219
176
|
#size;
|
|
220
177
|
#calculatedSize;
|
|
@@ -325,13 +282,14 @@ class LRUCache {
|
|
|
325
282
|
return this.#disposeAfter;
|
|
326
283
|
}
|
|
327
284
|
constructor(options) {
|
|
328
|
-
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;
|
|
285
|
+
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;
|
|
286
|
+
this.backgroundFetchSize = backgroundFetchSize;
|
|
329
287
|
if (perf !== undefined) {
|
|
330
288
|
if (typeof perf?.now !== 'function') {
|
|
331
289
|
throw new TypeError('perf option must have a now() method if specified');
|
|
332
290
|
}
|
|
333
291
|
}
|
|
334
|
-
this.#perf = perf ?? defaultPerf;
|
|
292
|
+
this.#perf = perf ?? perf_js_1.defaultPerf;
|
|
335
293
|
if (max !== 0 && !isPosInt(max)) {
|
|
336
294
|
throw new TypeError('max option must be a nonnegative integer');
|
|
337
295
|
}
|
|
@@ -361,8 +319,8 @@ class LRUCache {
|
|
|
361
319
|
this.#fetchMethod = fetchMethod;
|
|
362
320
|
this.#hasFetchMethod = !!fetchMethod;
|
|
363
321
|
this.#keyMap = new Map();
|
|
364
|
-
this.#keyList =
|
|
365
|
-
this.#valList =
|
|
322
|
+
this.#keyList = Array.from({ length: max }).fill(undefined);
|
|
323
|
+
this.#valList = Array.from({ length: max }).fill(undefined);
|
|
366
324
|
this.#next = new UintArray(max);
|
|
367
325
|
this.#prev = new UintArray(max);
|
|
368
326
|
this.#head = 0;
|
|
@@ -446,44 +404,55 @@ class LRUCache {
|
|
|
446
404
|
this.#ttls = ttls;
|
|
447
405
|
this.#starts = starts;
|
|
448
406
|
const purgeTimers = this.ttlAutopurge ?
|
|
449
|
-
|
|
407
|
+
Array.from({
|
|
408
|
+
length: this.#max,
|
|
409
|
+
})
|
|
450
410
|
: undefined;
|
|
451
411
|
this.#autopurgeTimers = purgeTimers;
|
|
452
412
|
this.#setItemTTL = (index, ttl, start = this.#perf.now()) => {
|
|
453
413
|
starts[index] = ttl !== 0 ? start : 0;
|
|
454
414
|
ttls[index] = ttl;
|
|
455
|
-
|
|
456
|
-
// previously had a ttl purge timer running, so it doesn't
|
|
457
|
-
// fire unnecessarily.
|
|
458
|
-
if (purgeTimers?.[index]) {
|
|
459
|
-
clearTimeout(purgeTimers[index]);
|
|
460
|
-
purgeTimers[index] = undefined;
|
|
461
|
-
}
|
|
462
|
-
if (ttl !== 0 && purgeTimers) {
|
|
463
|
-
const t = setTimeout(() => {
|
|
464
|
-
if (this.#isStale(index)) {
|
|
465
|
-
this.#delete(this.#keyList[index], 'expire');
|
|
466
|
-
}
|
|
467
|
-
}, ttl + 1);
|
|
468
|
-
// unref() not supported on all platforms
|
|
469
|
-
/* c8 ignore start */
|
|
470
|
-
if (t.unref) {
|
|
471
|
-
t.unref();
|
|
472
|
-
}
|
|
473
|
-
/* c8 ignore stop */
|
|
474
|
-
purgeTimers[index] = t;
|
|
475
|
-
}
|
|
415
|
+
setPurgetTimer(index, ttl);
|
|
476
416
|
};
|
|
477
417
|
this.#updateItemAge = index => {
|
|
478
418
|
starts[index] = ttls[index] !== 0 ? this.#perf.now() : 0;
|
|
419
|
+
setPurgetTimer(index, ttls[index]);
|
|
479
420
|
};
|
|
421
|
+
// clear out the purge timer if we're setting TTL to 0, and
|
|
422
|
+
// previously had a ttl purge timer running, so it doesn't
|
|
423
|
+
// fire unnecessarily. Don't need to do this if we're not doing
|
|
424
|
+
// autopurge.
|
|
425
|
+
const setPurgetTimer = !this.ttlAutopurge ?
|
|
426
|
+
() => { }
|
|
427
|
+
: (index, ttl) => {
|
|
428
|
+
if (purgeTimers?.[index]) {
|
|
429
|
+
clearTimeout(purgeTimers[index]);
|
|
430
|
+
purgeTimers[index] = undefined;
|
|
431
|
+
}
|
|
432
|
+
if (ttl && ttl !== 0 && purgeTimers) {
|
|
433
|
+
const t = setTimeout(() => {
|
|
434
|
+
if (this.#isStale(index)) {
|
|
435
|
+
this.#delete(this.#keyList[index], 'expire');
|
|
436
|
+
}
|
|
437
|
+
}, ttl + 1);
|
|
438
|
+
// unref() not supported on all platforms
|
|
439
|
+
/* c8 ignore start */
|
|
440
|
+
if (t.unref) {
|
|
441
|
+
t.unref();
|
|
442
|
+
}
|
|
443
|
+
/* c8 ignore stop */
|
|
444
|
+
purgeTimers[index] = t;
|
|
445
|
+
}
|
|
446
|
+
};
|
|
480
447
|
this.#statusTTL = (status, index) => {
|
|
481
448
|
if (ttls[index]) {
|
|
482
449
|
const ttl = ttls[index];
|
|
483
450
|
const start = starts[index];
|
|
484
|
-
/* c8 ignore
|
|
485
|
-
if (!ttl || !start)
|
|
451
|
+
/* c8 ignore start */
|
|
452
|
+
if (!ttl || !start) {
|
|
486
453
|
return;
|
|
454
|
+
}
|
|
455
|
+
/* c8 ignore stop */
|
|
487
456
|
status.ttl = ttl;
|
|
488
457
|
status.start = start;
|
|
489
458
|
status.now = cachedNow || getNow();
|
|
@@ -542,12 +511,15 @@ class LRUCache {
|
|
|
542
511
|
sizes[index] = 0;
|
|
543
512
|
};
|
|
544
513
|
this.#requireSize = (k, v, size, sizeCalculation) => {
|
|
545
|
-
// provisionally accept background fetches.
|
|
546
|
-
// actual value size will be checked when they return.
|
|
547
|
-
if (this.#isBackgroundFetch(v)) {
|
|
548
|
-
return 0;
|
|
549
|
-
}
|
|
550
514
|
if (!isPosInt(size)) {
|
|
515
|
+
// provisionally accept background fetches.
|
|
516
|
+
// actual value size will be checked when they return.
|
|
517
|
+
if (this.#isBackgroundFetch(v)) {
|
|
518
|
+
// NB: this cannot occur if v.__staleWhileFetching is set,
|
|
519
|
+
// because in that case, it would take on the size of the
|
|
520
|
+
// existing entry that it temporarily replaces.
|
|
521
|
+
return this.backgroundFetchSize;
|
|
522
|
+
}
|
|
551
523
|
if (sizeCalculation) {
|
|
552
524
|
if (typeof sizeCalculation !== 'function') {
|
|
553
525
|
throw new TypeError('sizeCalculation must be a function');
|
|
@@ -590,10 +562,7 @@ class LRUCache {
|
|
|
590
562
|
};
|
|
591
563
|
*#indexes({ allowStale = this.allowStale } = {}) {
|
|
592
564
|
if (this.#size) {
|
|
593
|
-
for (let i = this.#tail;
|
|
594
|
-
if (!this.#isValidIndex(i)) {
|
|
595
|
-
break;
|
|
596
|
-
}
|
|
565
|
+
for (let i = this.#tail; this.#isValidIndex(i);) {
|
|
597
566
|
if (allowStale || !this.#isStale(i)) {
|
|
598
567
|
yield i;
|
|
599
568
|
}
|
|
@@ -608,10 +577,7 @@ class LRUCache {
|
|
|
608
577
|
}
|
|
609
578
|
*#rindexes({ allowStale = this.allowStale } = {}) {
|
|
610
579
|
if (this.#size) {
|
|
611
|
-
for (let i = this.#head;
|
|
612
|
-
if (!this.#isValidIndex(i)) {
|
|
613
|
-
break;
|
|
614
|
-
}
|
|
580
|
+
for (let i = this.#head; this.#isValidIndex(i);) {
|
|
615
581
|
if (allowStale || !this.#isStale(i)) {
|
|
616
582
|
yield i;
|
|
617
583
|
}
|
|
@@ -732,7 +698,7 @@ class LRUCache {
|
|
|
732
698
|
if (value === undefined)
|
|
733
699
|
continue;
|
|
734
700
|
if (fn(value, this.#keyList[i], this)) {
|
|
735
|
-
return this
|
|
701
|
+
return this.#get(this.#keyList[i], getOptions);
|
|
736
702
|
}
|
|
737
703
|
}
|
|
738
704
|
}
|
|
@@ -805,7 +771,7 @@ class LRUCache {
|
|
|
805
771
|
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
806
772
|
if (value === undefined)
|
|
807
773
|
return undefined;
|
|
808
|
-
/* c8 ignore
|
|
774
|
+
/* c8 ignore stop */
|
|
809
775
|
const entry = { value };
|
|
810
776
|
if (this.#ttls && this.#starts) {
|
|
811
777
|
const ttl = this.#ttls[i];
|
|
@@ -879,7 +845,7 @@ class LRUCache {
|
|
|
879
845
|
const age = Date.now() - entry.start;
|
|
880
846
|
entry.start = this.#perf.now() - age;
|
|
881
847
|
}
|
|
882
|
-
this
|
|
848
|
+
this.#set(key, entry.value, entry);
|
|
883
849
|
}
|
|
884
850
|
}
|
|
885
851
|
/**
|
|
@@ -913,22 +879,43 @@ class LRUCache {
|
|
|
913
879
|
* `cache.delete(key)`. `undefined` is never stored in the cache.
|
|
914
880
|
*/
|
|
915
881
|
set(k, v, setOptions = {}) {
|
|
882
|
+
const { status = diagnostics_channel_js_1.metrics.hasSubscribers ? {} : undefined } = setOptions;
|
|
883
|
+
setOptions.status = status;
|
|
884
|
+
if (status) {
|
|
885
|
+
status.op = 'set';
|
|
886
|
+
status.key = k;
|
|
887
|
+
if (v !== undefined)
|
|
888
|
+
status.value = v;
|
|
889
|
+
status.cache = this;
|
|
890
|
+
}
|
|
891
|
+
const result = this.#set(k, v, setOptions);
|
|
892
|
+
if (status && diagnostics_channel_js_1.metrics.hasSubscribers) {
|
|
893
|
+
diagnostics_channel_js_1.metrics.publish(status);
|
|
894
|
+
}
|
|
895
|
+
return result;
|
|
896
|
+
}
|
|
897
|
+
#set(k, v, setOptions, bf) {
|
|
898
|
+
const { ttl = this.ttl, start, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status, } = setOptions;
|
|
899
|
+
const isBF = this.#isBackgroundFetch(v);
|
|
916
900
|
if (v === undefined) {
|
|
901
|
+
if (status)
|
|
902
|
+
status.set = 'deleted';
|
|
917
903
|
this.delete(k);
|
|
918
904
|
return this;
|
|
919
905
|
}
|
|
920
|
-
const { ttl = this.ttl, start, noDisposeOnSet = this.noDisposeOnSet, sizeCalculation = this.sizeCalculation, status, } = setOptions;
|
|
921
906
|
let { noUpdateTTL = this.noUpdateTTL } = setOptions;
|
|
922
|
-
|
|
907
|
+
if (status && !isBF)
|
|
908
|
+
status.value = v;
|
|
909
|
+
const size = this.#requireSize(k, v, setOptions.size || 0, sizeCalculation, status);
|
|
923
910
|
// if the item doesn't fit, don't do anything
|
|
924
911
|
// NB: maxEntrySize set to maxSize by default
|
|
925
912
|
if (this.maxEntrySize && size > this.maxEntrySize) {
|
|
913
|
+
// have to delete, in case something is there already.
|
|
914
|
+
this.#delete(k, 'set');
|
|
926
915
|
if (status) {
|
|
927
916
|
status.set = 'miss';
|
|
928
917
|
status.maxEntrySizeExceeded = true;
|
|
929
918
|
}
|
|
930
|
-
// have to delete, in case something is there already.
|
|
931
|
-
this.#delete(k, 'set');
|
|
932
919
|
return this;
|
|
933
920
|
}
|
|
934
921
|
let index = this.#size === 0 ? undefined : this.#keyMap.get(k);
|
|
@@ -949,52 +936,68 @@ class LRUCache {
|
|
|
949
936
|
if (status)
|
|
950
937
|
status.set = 'add';
|
|
951
938
|
noUpdateTTL = false;
|
|
952
|
-
if (this.#hasOnInsert) {
|
|
939
|
+
if (this.#hasOnInsert && !isBF) {
|
|
953
940
|
this.#onInsert?.(v, k, 'add');
|
|
954
941
|
}
|
|
955
942
|
}
|
|
956
943
|
else {
|
|
957
944
|
// update
|
|
945
|
+
// might be updating a background fetch!
|
|
958
946
|
this.#moveToTail(index);
|
|
959
947
|
const oldVal = this.#valList[index];
|
|
960
948
|
if (v !== oldVal) {
|
|
961
|
-
if (
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
949
|
+
if (!noDisposeOnSet) {
|
|
950
|
+
if (this.#isBackgroundFetch(oldVal)) {
|
|
951
|
+
if (oldVal !== bf) {
|
|
952
|
+
// setting over a background fetch, not merely resolving it.
|
|
953
|
+
oldVal.__abortController.abort(new Error('replaced'));
|
|
954
|
+
}
|
|
955
|
+
const { __staleWhileFetching: s } = oldVal;
|
|
956
|
+
if (s !== undefined && s !== v) {
|
|
957
|
+
if (this.#hasDispose) {
|
|
958
|
+
this.#dispose?.(s, k, 'set');
|
|
959
|
+
}
|
|
960
|
+
if (this.#hasDisposeAfter) {
|
|
961
|
+
this.#disposed?.push([s, k, 'set']);
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
else {
|
|
965
966
|
if (this.#hasDispose) {
|
|
966
|
-
this.#dispose?.(
|
|
967
|
+
this.#dispose?.(oldVal, k, 'set');
|
|
967
968
|
}
|
|
968
969
|
if (this.#hasDisposeAfter) {
|
|
969
|
-
this.#disposed?.push([
|
|
970
|
+
this.#disposed?.push([oldVal, k, 'set']);
|
|
970
971
|
}
|
|
971
972
|
}
|
|
972
973
|
}
|
|
973
|
-
else if (!noDisposeOnSet) {
|
|
974
|
-
if (this.#hasDispose) {
|
|
975
|
-
this.#dispose?.(oldVal, k, 'set');
|
|
976
|
-
}
|
|
977
|
-
if (this.#hasDisposeAfter) {
|
|
978
|
-
this.#disposed?.push([oldVal, k, 'set']);
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
974
|
this.#removeItemSize(index);
|
|
982
975
|
this.#addItemSize(index, size, status);
|
|
983
976
|
this.#valList[index] = v;
|
|
984
|
-
if (
|
|
985
|
-
status.set = 'replace';
|
|
977
|
+
if (!isBF) {
|
|
986
978
|
const oldValue = oldVal && this.#isBackgroundFetch(oldVal) ?
|
|
987
979
|
oldVal.__staleWhileFetching
|
|
988
980
|
: oldVal;
|
|
989
|
-
|
|
990
|
-
|
|
981
|
+
const setType = oldValue === undefined ? 'add'
|
|
982
|
+
: v !== oldValue ? 'replace'
|
|
983
|
+
: 'update';
|
|
984
|
+
if (status) {
|
|
985
|
+
status.set = setType;
|
|
986
|
+
if (oldValue !== undefined)
|
|
987
|
+
status.oldValue = oldValue;
|
|
988
|
+
}
|
|
989
|
+
if (this.#hasOnInsert) {
|
|
990
|
+
this.onInsert?.(v, k, setType);
|
|
991
|
+
}
|
|
991
992
|
}
|
|
992
993
|
}
|
|
993
|
-
else if (
|
|
994
|
-
status
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
this
|
|
994
|
+
else if (!isBF) {
|
|
995
|
+
if (status) {
|
|
996
|
+
status.set = 'update';
|
|
997
|
+
}
|
|
998
|
+
if (this.#hasOnInsert) {
|
|
999
|
+
this.onInsert?.(v, k, 'update');
|
|
1000
|
+
}
|
|
998
1001
|
}
|
|
999
1002
|
}
|
|
1000
1003
|
if (ttl !== 0 && !this.#ttls) {
|
|
@@ -1049,15 +1052,18 @@ class LRUCache {
|
|
|
1049
1052
|
const head = this.#head;
|
|
1050
1053
|
const k = this.#keyList[head];
|
|
1051
1054
|
const v = this.#valList[head];
|
|
1052
|
-
|
|
1055
|
+
const isBF = this.#isBackgroundFetch(v);
|
|
1056
|
+
if (isBF) {
|
|
1053
1057
|
v.__abortController.abort(new Error('evicted'));
|
|
1054
1058
|
}
|
|
1055
|
-
|
|
1059
|
+
const oldValue = isBF ? v.__staleWhileFetching : v;
|
|
1060
|
+
if ((this.#hasDispose || this.#hasDisposeAfter) &&
|
|
1061
|
+
oldValue !== undefined) {
|
|
1056
1062
|
if (this.#hasDispose) {
|
|
1057
|
-
this.#dispose?.(
|
|
1063
|
+
this.#dispose?.(oldValue, k, 'evict');
|
|
1058
1064
|
}
|
|
1059
1065
|
if (this.#hasDisposeAfter) {
|
|
1060
|
-
this.#disposed?.push([
|
|
1066
|
+
this.#disposed?.push([oldValue, k, 'evict']);
|
|
1061
1067
|
}
|
|
1062
1068
|
}
|
|
1063
1069
|
this.#removeItemSize(head);
|
|
@@ -1099,6 +1105,19 @@ class LRUCache {
|
|
|
1099
1105
|
* {@link LRUCache.OptionsBase.updateAgeOnHas} is set.
|
|
1100
1106
|
*/
|
|
1101
1107
|
has(k, hasOptions = {}) {
|
|
1108
|
+
const { status = diagnostics_channel_js_1.metrics.hasSubscribers ? {} : undefined } = hasOptions;
|
|
1109
|
+
hasOptions.status = status;
|
|
1110
|
+
if (status) {
|
|
1111
|
+
status.op = 'has';
|
|
1112
|
+
status.key = k;
|
|
1113
|
+
status.cache = this;
|
|
1114
|
+
}
|
|
1115
|
+
const result = this.#has(k, hasOptions);
|
|
1116
|
+
if (diagnostics_channel_js_1.metrics.hasSubscribers)
|
|
1117
|
+
diagnostics_channel_js_1.metrics.publish(status);
|
|
1118
|
+
return result;
|
|
1119
|
+
}
|
|
1120
|
+
#has(k, hasOptions = {}) {
|
|
1102
1121
|
const { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions;
|
|
1103
1122
|
const index = this.#keyMap.get(k);
|
|
1104
1123
|
if (index !== undefined) {
|
|
@@ -1135,21 +1154,46 @@ class LRUCache {
|
|
|
1135
1154
|
* {@link LRUCache.OptionsBase.allowStale} is set.
|
|
1136
1155
|
*/
|
|
1137
1156
|
peek(k, peekOptions = {}) {
|
|
1138
|
-
const {
|
|
1157
|
+
const { status = hasSubscribers() ? {} : undefined } = peekOptions;
|
|
1158
|
+
if (status) {
|
|
1159
|
+
status.op = 'peek';
|
|
1160
|
+
status.key = k;
|
|
1161
|
+
status.cache = this;
|
|
1162
|
+
}
|
|
1163
|
+
peekOptions.status = status;
|
|
1164
|
+
const result = this.#peek(k, peekOptions);
|
|
1165
|
+
if (diagnostics_channel_js_1.metrics.hasSubscribers) {
|
|
1166
|
+
diagnostics_channel_js_1.metrics.publish(status);
|
|
1167
|
+
}
|
|
1168
|
+
return result;
|
|
1169
|
+
}
|
|
1170
|
+
#peek(k, peekOptions) {
|
|
1171
|
+
const { status, allowStale = this.allowStale } = peekOptions;
|
|
1139
1172
|
const index = this.#keyMap.get(k);
|
|
1140
1173
|
if (index === undefined || (!allowStale && this.#isStale(index))) {
|
|
1141
|
-
|
|
1174
|
+
if (status)
|
|
1175
|
+
status.peek = index === undefined ? 'miss' : 'stale';
|
|
1176
|
+
return undefined;
|
|
1142
1177
|
}
|
|
1143
1178
|
const v = this.#valList[index];
|
|
1144
|
-
|
|
1145
|
-
|
|
1179
|
+
const val = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
1180
|
+
if (status) {
|
|
1181
|
+
if (val !== undefined) {
|
|
1182
|
+
status.peek = 'hit';
|
|
1183
|
+
status.value = val;
|
|
1184
|
+
}
|
|
1185
|
+
else {
|
|
1186
|
+
status.peek = 'miss';
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
return val;
|
|
1146
1190
|
}
|
|
1147
1191
|
#backgroundFetch(k, index, options, context) {
|
|
1148
1192
|
const v = index === undefined ? undefined : this.#valList[index];
|
|
1149
1193
|
if (this.#isBackgroundFetch(v)) {
|
|
1150
1194
|
return v;
|
|
1151
1195
|
}
|
|
1152
|
-
const ac = new
|
|
1196
|
+
const ac = new AbortController();
|
|
1153
1197
|
const { signal } = options;
|
|
1154
1198
|
// when/if our AC signals, then stop listening to theirs.
|
|
1155
1199
|
signal?.addEventListener('abort', () => ac.abort(signal.reason), {
|
|
@@ -1185,7 +1229,7 @@ class LRUCache {
|
|
|
1185
1229
|
// cache and ignore the abort, or if it's still pending on this specific
|
|
1186
1230
|
// background request, then write it to the cache.
|
|
1187
1231
|
const vl = this.#valList[index];
|
|
1188
|
-
if (vl === p || (
|
|
1232
|
+
if (vl === p || (vl === undefined && ignoreAbort && updateCache)) {
|
|
1189
1233
|
if (v === undefined) {
|
|
1190
1234
|
if (bf.__staleWhileFetching !== undefined) {
|
|
1191
1235
|
this.#valList[index] = bf.__staleWhileFetching;
|
|
@@ -1197,7 +1241,7 @@ class LRUCache {
|
|
|
1197
1241
|
else {
|
|
1198
1242
|
if (options.status)
|
|
1199
1243
|
options.status.fetchUpdated = true;
|
|
1200
|
-
this
|
|
1244
|
+
this.#set(k, v, fetchOpts.options, bf);
|
|
1201
1245
|
}
|
|
1202
1246
|
}
|
|
1203
1247
|
return v;
|
|
@@ -1219,8 +1263,7 @@ class LRUCache {
|
|
|
1219
1263
|
if (this.#valList[index] === p) {
|
|
1220
1264
|
// if we allow stale on fetch rejections, then we need to ensure that
|
|
1221
1265
|
// the stale value is not removed from the cache when the fetch fails.
|
|
1222
|
-
const del = !noDelete ||
|
|
1223
|
-
!proceed && bf.__staleWhileFetching === undefined;
|
|
1266
|
+
const del = !noDelete || (!proceed && bf.__staleWhileFetching === undefined);
|
|
1224
1267
|
if (del) {
|
|
1225
1268
|
this.#delete(k, 'fetch');
|
|
1226
1269
|
}
|
|
@@ -1244,9 +1287,6 @@ class LRUCache {
|
|
|
1244
1287
|
};
|
|
1245
1288
|
const pcall = (res, rej) => {
|
|
1246
1289
|
const fmp = this.#fetchMethod?.(k, v, fetchOpts);
|
|
1247
|
-
if (fmp && fmp instanceof Promise) {
|
|
1248
|
-
fmp.then(v => res(v === undefined ? undefined : v), rej);
|
|
1249
|
-
}
|
|
1250
1290
|
// ignored, we go until we finish, regardless.
|
|
1251
1291
|
// defer check until we are actually aborting,
|
|
1252
1292
|
// so fetchMethod can override.
|
|
@@ -1259,6 +1299,12 @@ class LRUCache {
|
|
|
1259
1299
|
}
|
|
1260
1300
|
}
|
|
1261
1301
|
});
|
|
1302
|
+
if (fmp && fmp instanceof Promise) {
|
|
1303
|
+
fmp.then(v => res(v === undefined ? undefined : v), rej);
|
|
1304
|
+
}
|
|
1305
|
+
else if (fmp !== undefined) {
|
|
1306
|
+
res(fmp);
|
|
1307
|
+
}
|
|
1262
1308
|
};
|
|
1263
1309
|
if (options.status)
|
|
1264
1310
|
options.status.fetchDispatched = true;
|
|
@@ -1270,10 +1316,14 @@ class LRUCache {
|
|
|
1270
1316
|
});
|
|
1271
1317
|
if (index === undefined) {
|
|
1272
1318
|
// internal, don't expose status.
|
|
1273
|
-
this
|
|
1319
|
+
this.#set(k, bf, { ...fetchOpts.options, status: undefined });
|
|
1274
1320
|
index = this.#keyMap.get(k);
|
|
1275
1321
|
}
|
|
1276
1322
|
else {
|
|
1323
|
+
// do not call #set, because we do not want to adjust its place
|
|
1324
|
+
// in the lru queue, as it has not yet been "used". Also, we don't
|
|
1325
|
+
// need to worry about evicting for size, because a background fetch
|
|
1326
|
+
// over a stale value is treated as the same size as its stale value.
|
|
1277
1327
|
this.#valList[index] = bf;
|
|
1278
1328
|
}
|
|
1279
1329
|
return bf;
|
|
@@ -1285,9 +1335,23 @@ class LRUCache {
|
|
|
1285
1335
|
return (!!b &&
|
|
1286
1336
|
b instanceof Promise &&
|
|
1287
1337
|
b.hasOwnProperty('__staleWhileFetching') &&
|
|
1288
|
-
b.__abortController instanceof
|
|
1338
|
+
b.__abortController instanceof AbortController);
|
|
1289
1339
|
}
|
|
1290
|
-
|
|
1340
|
+
fetch(k, fetchOptions = {}) {
|
|
1341
|
+
const ths = diagnostics_channel_js_1.tracing.hasSubscribers;
|
|
1342
|
+
const { status = hasSubscribers() ? {} : undefined } = fetchOptions;
|
|
1343
|
+
fetchOptions.status = status;
|
|
1344
|
+
if (status && fetchOptions.context) {
|
|
1345
|
+
status.context = fetchOptions.context;
|
|
1346
|
+
}
|
|
1347
|
+
const p = this.#fetch(k, fetchOptions);
|
|
1348
|
+
if (status && ths) {
|
|
1349
|
+
status.trace = true;
|
|
1350
|
+
diagnostics_channel_js_1.tracing.tracePromise(() => p, status).catch(() => { });
|
|
1351
|
+
}
|
|
1352
|
+
return p;
|
|
1353
|
+
}
|
|
1354
|
+
async #fetch(k, fetchOptions = {}) {
|
|
1291
1355
|
const {
|
|
1292
1356
|
// get options
|
|
1293
1357
|
allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet,
|
|
@@ -1295,10 +1359,17 @@ class LRUCache {
|
|
|
1295
1359
|
ttl = this.ttl, noDisposeOnSet = this.noDisposeOnSet, size = 0, sizeCalculation = this.sizeCalculation, noUpdateTTL = this.noUpdateTTL,
|
|
1296
1360
|
// fetch exclusive options
|
|
1297
1361
|
noDeleteOnFetchRejection = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection = this.allowStaleOnFetchRejection, ignoreFetchAbort = this.ignoreFetchAbort, allowStaleOnFetchAbort = this.allowStaleOnFetchAbort, context, forceRefresh = false, status, signal, } = fetchOptions;
|
|
1362
|
+
if (status) {
|
|
1363
|
+
status.op = 'fetch';
|
|
1364
|
+
status.key = k;
|
|
1365
|
+
if (forceRefresh)
|
|
1366
|
+
status.forceRefresh = true;
|
|
1367
|
+
status.cache = this;
|
|
1368
|
+
}
|
|
1298
1369
|
if (!this.#hasFetchMethod) {
|
|
1299
1370
|
if (status)
|
|
1300
1371
|
status.fetch = 'get';
|
|
1301
|
-
return this
|
|
1372
|
+
return this.#get(k, {
|
|
1302
1373
|
allowStale,
|
|
1303
1374
|
updateAgeOnGet,
|
|
1304
1375
|
noDeleteOnStaleGet,
|
|
@@ -1367,26 +1438,68 @@ class LRUCache {
|
|
|
1367
1438
|
return staleVal ? p.__staleWhileFetching : (p.__returned = p);
|
|
1368
1439
|
}
|
|
1369
1440
|
}
|
|
1370
|
-
|
|
1371
|
-
const
|
|
1441
|
+
forceFetch(k, fetchOptions = {}) {
|
|
1442
|
+
const ths = diagnostics_channel_js_1.tracing.hasSubscribers;
|
|
1443
|
+
const { status = hasSubscribers() ? {} : undefined } = fetchOptions;
|
|
1444
|
+
fetchOptions.status = status;
|
|
1445
|
+
if (status && fetchOptions.context) {
|
|
1446
|
+
status.context = fetchOptions.context;
|
|
1447
|
+
}
|
|
1448
|
+
const p = this.#forceFetch(k, fetchOptions);
|
|
1449
|
+
if (status && ths) {
|
|
1450
|
+
status.trace = true;
|
|
1451
|
+
diagnostics_channel_js_1.tracing.tracePromise(() => p, status).catch(() => { });
|
|
1452
|
+
}
|
|
1453
|
+
return p;
|
|
1454
|
+
}
|
|
1455
|
+
async #forceFetch(k, fetchOptions = {}) {
|
|
1456
|
+
const v = await this.#fetch(k, fetchOptions);
|
|
1372
1457
|
if (v === undefined)
|
|
1373
1458
|
throw new Error('fetch() returned undefined');
|
|
1374
1459
|
return v;
|
|
1375
1460
|
}
|
|
1376
1461
|
memo(k, memoOptions = {}) {
|
|
1462
|
+
const { status = diagnostics_channel_js_1.metrics.hasSubscribers ? {} : undefined } = memoOptions;
|
|
1463
|
+
memoOptions.status = status;
|
|
1464
|
+
if (status) {
|
|
1465
|
+
status.op = 'memo';
|
|
1466
|
+
status.key = k;
|
|
1467
|
+
if (memoOptions.context) {
|
|
1468
|
+
status.context = memoOptions.context;
|
|
1469
|
+
}
|
|
1470
|
+
status.cache = this;
|
|
1471
|
+
}
|
|
1472
|
+
const result = this.#memo(k, memoOptions);
|
|
1473
|
+
if (status)
|
|
1474
|
+
status.value = result;
|
|
1475
|
+
if (diagnostics_channel_js_1.metrics.hasSubscribers)
|
|
1476
|
+
diagnostics_channel_js_1.metrics.publish(status);
|
|
1477
|
+
return result;
|
|
1478
|
+
}
|
|
1479
|
+
#memo(k, memoOptions = {}) {
|
|
1377
1480
|
const memoMethod = this.#memoMethod;
|
|
1378
1481
|
if (!memoMethod) {
|
|
1379
1482
|
throw new Error('no memoMethod provided to constructor');
|
|
1380
1483
|
}
|
|
1381
|
-
const { context, forceRefresh, ...options } = memoOptions;
|
|
1382
|
-
|
|
1383
|
-
|
|
1484
|
+
const { context, status, forceRefresh, ...options } = memoOptions;
|
|
1485
|
+
if (status && forceRefresh)
|
|
1486
|
+
status.forceRefresh = true;
|
|
1487
|
+
const v = this.#get(k, options);
|
|
1488
|
+
const refresh = forceRefresh || v === undefined;
|
|
1489
|
+
if (status) {
|
|
1490
|
+
status.memo = refresh ? 'miss' : 'hit';
|
|
1491
|
+
if (!refresh)
|
|
1492
|
+
status.value = v;
|
|
1493
|
+
}
|
|
1494
|
+
if (!refresh)
|
|
1384
1495
|
return v;
|
|
1385
1496
|
const vv = memoMethod(k, v, {
|
|
1386
1497
|
options,
|
|
1387
1498
|
context,
|
|
1388
1499
|
});
|
|
1389
|
-
|
|
1500
|
+
if (status)
|
|
1501
|
+
status.value = vv;
|
|
1502
|
+
this.#set(k, vv, options);
|
|
1390
1503
|
return vv;
|
|
1391
1504
|
}
|
|
1392
1505
|
/**
|
|
@@ -1396,55 +1509,71 @@ class LRUCache {
|
|
|
1396
1509
|
* If the key is not found, get() will return `undefined`.
|
|
1397
1510
|
*/
|
|
1398
1511
|
get(k, getOptions = {}) {
|
|
1512
|
+
const { status = diagnostics_channel_js_1.metrics.hasSubscribers ? {} : undefined } = getOptions;
|
|
1513
|
+
getOptions.status = status;
|
|
1514
|
+
if (status) {
|
|
1515
|
+
status.op = 'get';
|
|
1516
|
+
status.key = k;
|
|
1517
|
+
status.cache = this;
|
|
1518
|
+
}
|
|
1519
|
+
const result = this.#get(k, getOptions);
|
|
1520
|
+
if (status) {
|
|
1521
|
+
if (result !== undefined)
|
|
1522
|
+
status.value = result;
|
|
1523
|
+
if (diagnostics_channel_js_1.metrics.hasSubscribers)
|
|
1524
|
+
diagnostics_channel_js_1.metrics.publish(status);
|
|
1525
|
+
}
|
|
1526
|
+
return result;
|
|
1527
|
+
}
|
|
1528
|
+
#get(k, getOptions = {}) {
|
|
1399
1529
|
const { allowStale = this.allowStale, updateAgeOnGet = this.updateAgeOnGet, noDeleteOnStaleGet = this.noDeleteOnStaleGet, status, } = getOptions;
|
|
1400
1530
|
const index = this.#keyMap.get(k);
|
|
1401
|
-
if (index
|
|
1402
|
-
const value = this.#valList[index];
|
|
1403
|
-
const fetching = this.#isBackgroundFetch(value);
|
|
1531
|
+
if (index === undefined) {
|
|
1404
1532
|
if (status)
|
|
1405
|
-
|
|
1406
|
-
|
|
1533
|
+
status.get = 'miss';
|
|
1534
|
+
return undefined;
|
|
1535
|
+
}
|
|
1536
|
+
const value = this.#valList[index];
|
|
1537
|
+
const fetching = this.#isBackgroundFetch(value);
|
|
1538
|
+
if (status)
|
|
1539
|
+
this.#statusTTL(status, index);
|
|
1540
|
+
if (this.#isStale(index)) {
|
|
1541
|
+
// delete only if not an in-flight background fetch
|
|
1542
|
+
if (!fetching) {
|
|
1543
|
+
if (!noDeleteOnStaleGet) {
|
|
1544
|
+
this.#delete(k, 'expire');
|
|
1545
|
+
}
|
|
1407
1546
|
if (status)
|
|
1408
1547
|
status.get = 'stale';
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
if (!noDeleteOnStaleGet) {
|
|
1412
|
-
this.#delete(k, 'expire');
|
|
1413
|
-
}
|
|
1414
|
-
if (status && allowStale)
|
|
1415
|
-
status.returnedStale = true;
|
|
1416
|
-
return allowStale ? value : undefined;
|
|
1417
|
-
}
|
|
1418
|
-
else {
|
|
1419
|
-
if (status &&
|
|
1420
|
-
allowStale &&
|
|
1421
|
-
value.__staleWhileFetching !== undefined) {
|
|
1548
|
+
if (allowStale) {
|
|
1549
|
+
if (status)
|
|
1422
1550
|
status.returnedStale = true;
|
|
1423
|
-
|
|
1424
|
-
return allowStale ? value.__staleWhileFetching : undefined;
|
|
1551
|
+
return value;
|
|
1425
1552
|
}
|
|
1553
|
+
return undefined;
|
|
1426
1554
|
}
|
|
1427
|
-
|
|
1555
|
+
if (status)
|
|
1556
|
+
status.get = 'stale-fetching';
|
|
1557
|
+
if (allowStale && value.__staleWhileFetching !== undefined) {
|
|
1428
1558
|
if (status)
|
|
1429
|
-
status.
|
|
1430
|
-
|
|
1431
|
-
// it's not stale, which means this isn't a staleWhileRefetching.
|
|
1432
|
-
// If it's not stale, and fetching, AND has a __staleWhileFetching
|
|
1433
|
-
// value, then that means the user fetched with {forceRefresh:true},
|
|
1434
|
-
// so it's safe to return that value.
|
|
1435
|
-
if (fetching) {
|
|
1436
|
-
return value.__staleWhileFetching;
|
|
1437
|
-
}
|
|
1438
|
-
this.#moveToTail(index);
|
|
1439
|
-
if (updateAgeOnGet) {
|
|
1440
|
-
this.#updateItemAge(index);
|
|
1441
|
-
}
|
|
1442
|
-
return value;
|
|
1559
|
+
status.returnedStale = true;
|
|
1560
|
+
return value.__staleWhileFetching;
|
|
1443
1561
|
}
|
|
1562
|
+
return undefined;
|
|
1444
1563
|
}
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1564
|
+
// not stale
|
|
1565
|
+
if (status)
|
|
1566
|
+
status.get = fetching ? 'fetching' : 'hit';
|
|
1567
|
+
// if we're currently fetching it, we don't actually have it yet
|
|
1568
|
+
// it's not stale, which means this isn't a staleWhileRefetching.
|
|
1569
|
+
// If it's not stale, and fetching, AND has a __staleWhileFetching
|
|
1570
|
+
// value, then that means the user fetched with {forceRefresh:true},
|
|
1571
|
+
// so it's safe to return that value.
|
|
1572
|
+
this.#moveToTail(index);
|
|
1573
|
+
if (updateAgeOnGet) {
|
|
1574
|
+
this.#updateItemAge(index);
|
|
1575
|
+
}
|
|
1576
|
+
return fetching ? value.__staleWhileFetching : value;
|
|
1448
1577
|
}
|
|
1449
1578
|
#connect(p, n) {
|
|
1450
1579
|
this.#prev[n] = p;
|
|
@@ -1479,6 +1608,14 @@ class LRUCache {
|
|
|
1479
1608
|
return this.#delete(k, 'delete');
|
|
1480
1609
|
}
|
|
1481
1610
|
#delete(k, reason) {
|
|
1611
|
+
if (diagnostics_channel_js_1.metrics.hasSubscribers) {
|
|
1612
|
+
diagnostics_channel_js_1.metrics.publish({
|
|
1613
|
+
op: 'delete',
|
|
1614
|
+
delete: reason,
|
|
1615
|
+
key: k,
|
|
1616
|
+
cache: this,
|
|
1617
|
+
});
|
|
1618
|
+
}
|
|
1482
1619
|
let deleted = false;
|
|
1483
1620
|
if (this.#size !== 0) {
|
|
1484
1621
|
const index = this.#keyMap.get(k);
|
|
@@ -1557,7 +1694,7 @@ class LRUCache {
|
|
|
1557
1694
|
}
|
|
1558
1695
|
}
|
|
1559
1696
|
this.#keyMap.clear();
|
|
1560
|
-
this.#valList.fill(undefined);
|
|
1697
|
+
void this.#valList.fill(undefined);
|
|
1561
1698
|
this.#keyList.fill(undefined);
|
|
1562
1699
|
if (this.#ttls && this.#starts) {
|
|
1563
1700
|
this.#ttls.fill(0);
|