@office-ai/aioncli-core 0.2.3 → 0.18.4
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/dist/index.d.ts +16 -3
- package/dist/index.js +15 -3
- package/dist/index.js.map +1 -1
- package/dist/src/agents/codebase-investigator.d.ts +46 -0
- package/dist/src/agents/codebase-investigator.js +132 -0
- package/dist/src/agents/codebase-investigator.js.map +1 -0
- package/dist/src/agents/codebase-investigator.test.js +35 -0
- package/dist/src/agents/codebase-investigator.test.js.map +1 -0
- package/dist/src/agents/executor.d.ts +114 -0
- package/dist/src/agents/executor.js +779 -0
- package/dist/src/agents/executor.js.map +1 -0
- package/dist/src/agents/executor.test.js +1362 -0
- package/dist/src/agents/executor.test.js.map +1 -0
- package/dist/src/agents/invocation.d.ts +46 -0
- package/dist/src/agents/invocation.js +102 -0
- package/dist/src/agents/invocation.js.map +1 -0
- package/dist/src/agents/invocation.test.js +215 -0
- package/dist/src/agents/invocation.test.js.map +1 -0
- package/dist/src/agents/registry.d.ts +40 -0
- package/dist/src/agents/registry.js +105 -0
- package/dist/src/agents/registry.js.map +1 -0
- package/dist/src/agents/registry.test.d.ts +6 -0
- package/dist/src/agents/registry.test.js +160 -0
- package/dist/src/agents/registry.test.js.map +1 -0
- package/dist/src/agents/schema-utils.d.ts +39 -0
- package/dist/src/agents/schema-utils.js +57 -0
- package/dist/src/agents/schema-utils.js.map +1 -0
- package/dist/src/agents/schema-utils.test.d.ts +6 -0
- package/dist/src/agents/schema-utils.test.js +144 -0
- package/dist/src/agents/schema-utils.test.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.d.ts +38 -0
- package/dist/src/agents/subagent-tool-wrapper.js +48 -0
- package/dist/src/agents/subagent-tool-wrapper.js.map +1 -0
- package/dist/src/agents/subagent-tool-wrapper.test.d.ts +6 -0
- package/dist/src/agents/subagent-tool-wrapper.test.js +110 -0
- package/dist/src/agents/subagent-tool-wrapper.test.js.map +1 -0
- package/dist/src/agents/types.d.ts +146 -0
- package/dist/src/agents/types.js +19 -0
- package/dist/src/agents/types.js.map +1 -0
- package/dist/src/agents/utils.d.ts +15 -0
- package/dist/src/agents/utils.js +29 -0
- package/dist/src/agents/utils.js.map +1 -0
- package/dist/src/agents/utils.test.d.ts +6 -0
- package/dist/src/agents/utils.test.js +87 -0
- package/dist/src/agents/utils.test.js.map +1 -0
- package/dist/src/code_assist/codeAssist.d.ts +6 -3
- package/dist/src/code_assist/codeAssist.js +13 -1
- package/dist/src/code_assist/codeAssist.js.map +1 -1
- package/dist/src/code_assist/codeAssist.test.d.ts +6 -0
- package/dist/src/code_assist/codeAssist.test.js +99 -0
- package/dist/src/code_assist/codeAssist.test.js.map +1 -0
- package/dist/src/code_assist/converter.d.ts +5 -1
- package/dist/src/code_assist/converter.js +39 -5
- package/dist/src/code_assist/converter.js.map +1 -1
- package/dist/src/code_assist/converter.test.js +112 -0
- package/dist/src/code_assist/converter.test.js.map +1 -1
- package/dist/src/code_assist/experiments/client_metadata.d.ts +12 -0
- package/dist/src/code_assist/experiments/client_metadata.js +50 -0
- package/dist/src/code_assist/experiments/client_metadata.js.map +1 -0
- package/dist/src/code_assist/experiments/client_metadata.test.d.ts +6 -0
- package/dist/src/code_assist/experiments/client_metadata.test.js +99 -0
- package/dist/src/code_assist/experiments/client_metadata.test.js.map +1 -0
- package/dist/src/code_assist/experiments/experiments.d.ts +17 -0
- package/dist/src/code_assist/experiments/experiments.js +36 -0
- package/dist/src/code_assist/experiments/experiments.js.map +1 -0
- package/dist/src/code_assist/experiments/experiments.test.d.ts +6 -0
- package/dist/src/code_assist/experiments/experiments.test.js +92 -0
- package/dist/src/code_assist/experiments/experiments.test.js.map +1 -0
- package/dist/src/code_assist/experiments/flagNames.d.ts +13 -0
- package/dist/src/code_assist/experiments/flagNames.js +13 -0
- package/dist/src/code_assist/experiments/flagNames.js.map +1 -0
- package/dist/src/code_assist/experiments/types.d.ts +35 -0
- package/dist/src/code_assist/experiments/types.js +7 -0
- package/dist/src/code_assist/experiments/types.js.map +1 -0
- package/dist/src/code_assist/oauth-credential-storage.d.ts +25 -0
- package/dist/src/code_assist/oauth-credential-storage.js +110 -0
- package/dist/src/code_assist/oauth-credential-storage.js.map +1 -0
- package/dist/src/code_assist/oauth-credential-storage.test.d.ts +6 -0
- package/dist/src/code_assist/oauth-credential-storage.test.js +198 -0
- package/dist/src/code_assist/oauth-credential-storage.test.js.map +1 -0
- package/dist/src/code_assist/oauth2.d.ts +3 -3
- package/dist/src/code_assist/oauth2.js +252 -125
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +788 -350
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +8 -6
- package/dist/src/code_assist/server.js +41 -10
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/server.test.js +151 -28
- package/dist/src/code_assist/server.test.js.map +1 -1
- package/dist/src/code_assist/setup.d.ts +2 -2
- package/dist/src/code_assist/setup.js +5 -3
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/code_assist/setup.test.js.map +1 -1
- package/dist/src/code_assist/types.d.ts +18 -3
- package/dist/src/code_assist/types.js.map +1 -1
- package/dist/src/commands/extensions.d.ts +7 -0
- package/dist/src/commands/extensions.js +9 -0
- package/dist/src/commands/extensions.js.map +1 -0
- package/dist/src/commands/extensions.test.d.ts +6 -0
- package/dist/src/commands/extensions.test.js +19 -0
- package/dist/src/commands/extensions.test.js.map +1 -0
- package/dist/src/config/config.d.ts +282 -60
- package/dist/src/config/config.js +677 -129
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +1020 -146
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/constants.d.ts +11 -0
- package/dist/src/config/constants.js +16 -0
- package/dist/src/config/constants.js.map +1 -0
- package/dist/src/config/defaultModelConfigs.d.ts +7 -0
- package/dist/src/config/defaultModelConfigs.js +185 -0
- package/dist/src/config/defaultModelConfigs.js.map +1 -0
- package/dist/src/config/models.d.ts +37 -0
- package/dist/src/config/models.js +72 -0
- package/dist/src/config/models.js.map +1 -1
- package/dist/src/config/models.test.d.ts +6 -0
- package/dist/src/config/models.test.js +116 -0
- package/dist/src/config/models.test.js.map +1 -0
- package/dist/src/config/storage.d.ts +36 -0
- package/dist/src/config/storage.js +115 -0
- package/dist/src/config/storage.js.map +1 -0
- package/dist/src/config/storage.test.d.ts +6 -0
- package/dist/src/config/storage.test.js +48 -0
- package/dist/src/config/storage.test.js.map +1 -0
- package/dist/src/confirmation-bus/index.d.ts +7 -0
- package/dist/src/confirmation-bus/index.js +8 -0
- package/dist/src/confirmation-bus/index.js.map +1 -0
- package/dist/src/confirmation-bus/message-bus.d.ts +18 -0
- package/dist/src/confirmation-bus/message-bus.js +87 -0
- package/dist/src/confirmation-bus/message-bus.js.map +1 -0
- package/dist/src/confirmation-bus/message-bus.test.d.ts +6 -0
- package/dist/src/confirmation-bus/message-bus.test.js +170 -0
- package/dist/src/confirmation-bus/message-bus.test.js.map +1 -0
- package/dist/src/confirmation-bus/types.d.ts +49 -0
- package/dist/src/confirmation-bus/types.js +16 -0
- package/dist/src/confirmation-bus/types.js.map +1 -0
- package/dist/src/core/apiKeyCredentialStorage.d.ts +17 -0
- package/dist/src/core/apiKeyCredentialStorage.js +64 -0
- package/dist/src/core/apiKeyCredentialStorage.js.map +1 -0
- package/dist/src/core/apiKeyCredentialStorage.test.d.ts +6 -0
- package/dist/src/core/apiKeyCredentialStorage.test.js +71 -0
- package/dist/src/core/apiKeyCredentialStorage.test.js.map +1 -0
- package/dist/src/core/baseLlmClient.d.ts +50 -0
- package/dist/src/core/baseLlmClient.js +185 -0
- package/dist/src/core/baseLlmClient.js.map +1 -0
- package/dist/src/core/baseLlmClient.test.d.ts +6 -0
- package/dist/src/core/baseLlmClient.test.js +311 -0
- package/dist/src/core/baseLlmClient.test.js.map +1 -0
- package/dist/src/core/client.d.ts +30 -42
- package/dist/src/core/client.js +178 -477
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +739 -617
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/contentGenerator.d.ts +7 -6
- package/dist/src/core/contentGenerator.js +59 -45
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/contentGenerator.test.js +50 -4
- package/dist/src/core/contentGenerator.test.js.map +1 -1
- package/dist/src/core/coreToolScheduler.d.ts +28 -11
- package/dist/src/core/coreToolScheduler.js +493 -161
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +995 -163
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/fakeContentGenerator.d.ts +33 -0
- package/dist/src/core/fakeContentGenerator.js +58 -0
- package/dist/src/core/fakeContentGenerator.js.map +1 -0
- package/dist/src/core/fakeContentGenerator.test.d.ts +6 -0
- package/dist/src/core/fakeContentGenerator.test.js +127 -0
- package/dist/src/core/fakeContentGenerator.test.js.map +1 -0
- package/dist/src/core/geminiChat.d.ts +61 -55
- package/dist/src/core/geminiChat.js +388 -366
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiChat.test.js +1600 -355
- package/dist/src/core/geminiChat.test.js.map +1 -1
- package/dist/src/core/geminiRequest.js +1 -0
- package/dist/src/core/geminiRequest.js.map +1 -1
- package/dist/src/core/logger.d.ts +11 -4
- package/dist/src/core/logger.js +39 -30
- package/dist/src/core/logger.js.map +1 -1
- package/dist/src/core/logger.test.js +62 -45
- package/dist/src/core/logger.test.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.d.ts +4 -3
- package/dist/src/core/loggingContentGenerator.js +116 -37
- package/dist/src/core/loggingContentGenerator.js.map +1 -1
- package/dist/src/core/loggingContentGenerator.test.d.ts +6 -0
- package/dist/src/core/loggingContentGenerator.test.js +180 -0
- package/dist/src/core/loggingContentGenerator.test.js.map +1 -0
- package/dist/src/core/nonInteractiveToolExecutor.d.ts +4 -5
- package/dist/src/core/nonInteractiveToolExecutor.js +17 -120
- package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +168 -84
- package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -1
- package/dist/src/core/openaiContentGenerator.d.ts +4 -3
- package/dist/src/core/openaiContentGenerator.js +49 -19
- package/dist/src/core/openaiContentGenerator.js.map +1 -1
- package/dist/src/core/openaiContentGenerator.test.js +1 -0
- package/dist/src/core/openaiContentGenerator.test.js.map +1 -1
- package/dist/src/core/prompts.d.ts +7 -1
- package/dist/src/core/prompts.js +198 -195
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +172 -104
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/recordingContentGenerator.d.ts +18 -0
- package/dist/src/core/recordingContentGenerator.js +77 -0
- package/dist/src/core/recordingContentGenerator.js.map +1 -0
- package/dist/src/core/recordingContentGenerator.test.d.ts +6 -0
- package/dist/src/core/recordingContentGenerator.test.js +101 -0
- package/dist/src/core/recordingContentGenerator.test.js.map +1 -0
- package/dist/src/core/subagent.d.ts +24 -18
- package/dist/src/core/subagent.js +125 -90
- package/dist/src/core/subagent.js.map +1 -1
- package/dist/src/core/subagent.test.js +59 -44
- package/dist/src/core/subagent.test.js.map +1 -1
- package/dist/src/core/tokenLimits.test.d.ts +6 -0
- package/dist/src/core/tokenLimits.test.js +26 -0
- package/dist/src/core/tokenLimits.test.js.map +1 -0
- package/dist/src/core/turn.d.ts +57 -13
- package/dist/src/core/turn.js +79 -35
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +373 -120
- package/dist/src/core/turn.test.js.map +1 -1
- package/dist/src/fallback/handler.d.ts +7 -0
- package/dist/src/fallback/handler.js +181 -0
- package/dist/src/fallback/handler.js.map +1 -0
- package/dist/src/fallback/handler.test.d.ts +6 -0
- package/dist/src/fallback/handler.test.js +245 -0
- package/dist/src/fallback/handler.test.js.map +1 -0
- package/dist/src/fallback/types.d.ts +14 -0
- package/dist/src/fallback/types.js +7 -0
- package/dist/src/fallback/types.js.map +1 -0
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/generated/git-commit.js.map +1 -1
- package/dist/src/hooks/hookAggregator.d.ts +68 -0
- package/dist/src/hooks/hookAggregator.js +262 -0
- package/dist/src/hooks/hookAggregator.js.map +1 -0
- package/dist/src/hooks/hookAggregator.test.d.ts +6 -0
- package/dist/src/hooks/hookAggregator.test.js +387 -0
- package/dist/src/hooks/hookAggregator.test.js.map +1 -0
- package/dist/src/hooks/hookPlanner.d.ts +46 -0
- package/dist/src/hooks/hookPlanner.js +108 -0
- package/dist/src/hooks/hookPlanner.js.map +1 -0
- package/dist/src/hooks/hookPlanner.test.d.ts +6 -0
- package/dist/src/hooks/hookPlanner.test.js +255 -0
- package/dist/src/hooks/hookPlanner.test.js.map +1 -0
- package/dist/src/hooks/hookRegistry.d.ts +87 -0
- package/dist/src/hooks/hookRegistry.js +198 -0
- package/dist/src/hooks/hookRegistry.js.map +1 -0
- package/dist/src/hooks/hookRegistry.test.d.ts +6 -0
- package/dist/src/hooks/hookRegistry.test.js +341 -0
- package/dist/src/hooks/hookRegistry.test.js.map +1 -0
- package/dist/src/hooks/hookRunner.d.ts +42 -0
- package/dist/src/hooks/hookRunner.js +272 -0
- package/dist/src/hooks/hookRunner.js.map +1 -0
- package/dist/src/hooks/hookRunner.test.d.ts +6 -0
- package/dist/src/hooks/hookRunner.test.js +468 -0
- package/dist/src/hooks/hookRunner.test.js.map +1 -0
- package/dist/src/hooks/hookTranslator.d.ts +113 -0
- package/dist/src/hooks/hookTranslator.js +232 -0
- package/dist/src/hooks/hookTranslator.js.map +1 -0
- package/dist/src/hooks/hookTranslator.test.d.ts +6 -0
- package/dist/src/hooks/hookTranslator.test.js +192 -0
- package/dist/src/hooks/hookTranslator.test.js.map +1 -0
- package/dist/src/hooks/types.d.ts +384 -0
- package/dist/src/hooks/types.js +284 -0
- package/dist/src/hooks/types.js.map +1 -0
- package/dist/src/hooks/types.test.d.ts +6 -0
- package/dist/src/hooks/types.test.js +313 -0
- package/dist/src/hooks/types.test.js.map +1 -0
- package/dist/src/ide/constants.d.ts +3 -0
- package/dist/src/ide/constants.js +3 -0
- package/dist/src/ide/constants.js.map +1 -1
- package/dist/src/ide/detect-ide.d.ts +52 -12
- package/dist/src/ide/detect-ide.js +51 -65
- package/dist/src/ide/detect-ide.js.map +1 -1
- package/dist/src/ide/detect-ide.test.js +95 -52
- package/dist/src/ide/detect-ide.test.js.map +1 -1
- package/dist/src/ide/ide-client.d.ts +72 -24
- package/dist/src/ide/ide-client.js +380 -84
- package/dist/src/ide/ide-client.js.map +1 -1
- package/dist/src/ide/ide-client.test.js +539 -35
- package/dist/src/ide/ide-client.test.js.map +1 -1
- package/dist/src/ide/ide-installer.d.ts +2 -2
- package/dist/src/ide/ide-installer.js +93 -35
- package/dist/src/ide/ide-installer.js.map +1 -1
- package/dist/src/ide/ide-installer.test.js +157 -26
- package/dist/src/ide/ide-installer.test.js.map +1 -1
- package/dist/src/ide/ideContext.d.ts +35 -365
- package/dist/src/ide/ideContext.js +60 -106
- package/dist/src/ide/ideContext.js.map +1 -1
- package/dist/src/ide/ideContext.test.js +152 -24
- package/dist/src/ide/ideContext.test.js.map +1 -1
- package/dist/src/ide/process-utils.d.ts +7 -5
- package/dist/src/ide/process-utils.js +108 -67
- package/dist/src/ide/process-utils.js.map +1 -1
- package/dist/src/ide/process-utils.test.d.ts +6 -0
- package/dist/src/ide/process-utils.test.js +151 -0
- package/dist/src/ide/process-utils.test.js.map +1 -0
- package/dist/src/ide/types.d.ts +486 -0
- package/dist/src/ide/types.js +138 -0
- package/dist/src/ide/types.js.map +1 -0
- package/dist/src/index.d.ts +41 -2
- package/dist/src/index.js +44 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/google-auth-provider.d.ts +5 -3
- package/dist/src/mcp/google-auth-provider.js +21 -3
- package/dist/src/mcp/google-auth-provider.js.map +1 -1
- package/dist/src/mcp/google-auth-provider.test.js +42 -9
- package/dist/src/mcp/google-auth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-provider.d.ts +25 -18
- package/dist/src/mcp/oauth-provider.js +194 -97
- package/dist/src/mcp/oauth-provider.js.map +1 -1
- package/dist/src/mcp/oauth-provider.test.js +581 -39
- package/dist/src/mcp/oauth-provider.test.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.d.ts +14 -32
- package/dist/src/mcp/oauth-token-storage.js +58 -28
- package/dist/src/mcp/oauth-token-storage.js.map +1 -1
- package/dist/src/mcp/oauth-token-storage.test.js +262 -162
- package/dist/src/mcp/oauth-token-storage.test.js.map +1 -1
- package/dist/src/mcp/oauth-utils.d.ts +16 -1
- package/dist/src/mcp/oauth-utils.js +68 -33
- package/dist/src/mcp/oauth-utils.js.map +1 -1
- package/dist/src/mcp/oauth-utils.test.js +86 -3
- package/dist/src/mcp/oauth-utils.test.js.map +1 -1
- package/dist/src/mcp/sa-impersonation-provider.d.ts +27 -0
- package/dist/src/mcp/sa-impersonation-provider.js +113 -0
- package/dist/src/mcp/sa-impersonation-provider.js.map +1 -0
- package/dist/src/mcp/sa-impersonation-provider.test.d.ts +6 -0
- package/dist/src/mcp/sa-impersonation-provider.test.js +117 -0
- package/dist/src/mcp/sa-impersonation-provider.test.js.map +1 -0
- package/dist/src/mcp/token-storage/base-token-storage.d.ts +19 -0
- package/dist/src/mcp/token-storage/base-token-storage.js +36 -0
- package/dist/src/mcp/token-storage/base-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.js +151 -0
- package/dist/src/mcp/token-storage/base-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/file-token-storage.d.ts +24 -0
- package/dist/src/mcp/token-storage/file-token-storage.js +145 -0
- package/dist/src/mcp/token-storage/file-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.js +238 -0
- package/dist/src/mcp/token-storage/file-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.d.ts +23 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.js +78 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.js +193 -0
- package/dist/src/mcp/token-storage/hybrid-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/index.d.ts +11 -0
- package/dist/src/mcp/token-storage/index.js +12 -0
- package/dist/src/mcp/token-storage/index.js.map +1 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.d.ts +35 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.js +246 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.js.map +1 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.d.ts +6 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js +305 -0
- package/dist/src/mcp/token-storage/keychain-token-storage.test.js.map +1 -0
- package/dist/src/mcp/token-storage/types.d.ts +44 -0
- package/dist/src/mcp/token-storage/types.js +11 -0
- package/dist/src/mcp/token-storage/types.js.map +1 -0
- package/dist/src/output/json-formatter.d.ts +11 -0
- package/dist/src/output/json-formatter.js +30 -0
- package/dist/src/output/json-formatter.js.map +1 -0
- package/dist/src/output/json-formatter.test.d.ts +6 -0
- package/dist/src/output/json-formatter.test.js +266 -0
- package/dist/src/output/json-formatter.test.js.map +1 -0
- package/dist/src/output/stream-json-formatter.d.ts +32 -0
- package/dist/src/output/stream-json-formatter.js +52 -0
- package/dist/src/output/stream-json-formatter.js.map +1 -0
- package/dist/src/output/stream-json-formatter.test.d.ts +6 -0
- package/dist/src/output/stream-json-formatter.test.js +479 -0
- package/dist/src/output/stream-json-formatter.test.js.map +1 -0
- package/dist/src/output/types.d.ts +82 -0
- package/dist/src/output/types.js +22 -0
- package/dist/src/output/types.js.map +1 -0
- package/dist/src/policy/config.d.ts +31 -0
- package/dist/src/policy/config.js +199 -0
- package/dist/src/policy/config.js.map +1 -0
- package/dist/src/policy/config.test.d.ts +6 -0
- package/dist/src/policy/config.test.js +538 -0
- package/dist/src/policy/config.test.js.map +1 -0
- package/dist/src/policy/index.d.ts +9 -0
- package/dist/src/policy/index.js +10 -0
- package/dist/src/policy/index.js.map +1 -0
- package/dist/src/policy/policies/discovered.toml +8 -0
- package/dist/src/policy/policies/read-only.toml +56 -0
- package/dist/src/policy/policies/write.toml +73 -0
- package/dist/src/policy/policies/yolo.toml +31 -0
- package/dist/src/policy/policy-engine.d.ts +39 -0
- package/dist/src/policy/policy-engine.js +158 -0
- package/dist/src/policy/policy-engine.js.map +1 -0
- package/dist/src/policy/policy-engine.test.d.ts +6 -0
- package/dist/src/policy/policy-engine.test.js +899 -0
- package/dist/src/policy/policy-engine.test.js.map +1 -0
- package/dist/src/policy/stable-stringify.d.ts +58 -0
- package/dist/src/policy/stable-stringify.js +122 -0
- package/dist/src/policy/stable-stringify.js.map +1 -0
- package/dist/src/policy/toml-loader.d.ts +47 -0
- package/dist/src/policy/toml-loader.js +411 -0
- package/dist/src/policy/toml-loader.js.map +1 -0
- package/dist/src/policy/toml-loader.test.d.ts +6 -0
- package/dist/src/policy/toml-loader.test.js +376 -0
- package/dist/src/policy/toml-loader.test.js.map +1 -0
- package/dist/src/policy/types.d.ts +130 -0
- package/dist/src/policy/types.js +22 -0
- package/dist/src/policy/types.js.map +1 -0
- package/dist/src/prompts/mcp-prompts.d.ts +2 -2
- package/dist/src/prompts/mcp-prompts.test.d.ts +6 -0
- package/dist/src/prompts/mcp-prompts.test.js +39 -0
- package/dist/src/prompts/mcp-prompts.test.js.map +1 -0
- package/dist/src/prompts/prompt-registry.d.ts +1 -1
- package/dist/src/prompts/prompt-registry.js +2 -1
- package/dist/src/prompts/prompt-registry.js.map +1 -1
- package/dist/src/prompts/prompt-registry.test.d.ts +6 -0
- package/dist/src/prompts/prompt-registry.test.js +96 -0
- package/dist/src/prompts/prompt-registry.test.js.map +1 -0
- package/dist/src/routing/modelRouterService.d.ts +23 -0
- package/dist/src/routing/modelRouterService.js +85 -0
- package/dist/src/routing/modelRouterService.js.map +1 -0
- package/dist/src/routing/modelRouterService.test.d.ts +6 -0
- package/dist/src/routing/modelRouterService.test.js +160 -0
- package/dist/src/routing/modelRouterService.test.js.map +1 -0
- package/dist/src/routing/routingStrategy.d.ts +62 -0
- package/dist/src/routing/routingStrategy.js +7 -0
- package/dist/src/routing/routingStrategy.js.map +1 -0
- package/dist/src/routing/strategies/classifierStrategy.d.ts +12 -0
- package/dist/src/routing/strategies/classifierStrategy.js +166 -0
- package/dist/src/routing/strategies/classifierStrategy.js.map +1 -0
- package/dist/src/routing/strategies/classifierStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/classifierStrategy.test.js +196 -0
- package/dist/src/routing/strategies/classifierStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/compositeStrategy.d.ts +26 -0
- package/dist/src/routing/strategies/compositeStrategy.js +68 -0
- package/dist/src/routing/strategies/compositeStrategy.js.map +1 -0
- package/dist/src/routing/strategies/compositeStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/compositeStrategy.test.js +123 -0
- package/dist/src/routing/strategies/compositeStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/defaultStrategy.d.ts +12 -0
- package/dist/src/routing/strategies/defaultStrategy.js +20 -0
- package/dist/src/routing/strategies/defaultStrategy.js.map +1 -0
- package/dist/src/routing/strategies/defaultStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/defaultStrategy.test.js +26 -0
- package/dist/src/routing/strategies/defaultStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/fallbackStrategy.d.ts +12 -0
- package/dist/src/routing/strategies/fallbackStrategy.js +25 -0
- package/dist/src/routing/strategies/fallbackStrategy.js.map +1 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.js +59 -0
- package/dist/src/routing/strategies/fallbackStrategy.test.js.map +1 -0
- package/dist/src/routing/strategies/overrideStrategy.d.ts +15 -0
- package/dist/src/routing/strategies/overrideStrategy.js +28 -0
- package/dist/src/routing/strategies/overrideStrategy.js.map +1 -0
- package/dist/src/routing/strategies/overrideStrategy.test.d.ts +6 -0
- package/dist/src/routing/strategies/overrideStrategy.test.js +45 -0
- package/dist/src/routing/strategies/overrideStrategy.test.js.map +1 -0
- package/dist/src/safety/built-in.d.ts +21 -0
- package/dist/src/safety/built-in.js +106 -0
- package/dist/src/safety/built-in.js.map +1 -0
- package/dist/src/safety/built-in.test.d.ts +6 -0
- package/dist/src/safety/built-in.test.js +199 -0
- package/dist/src/safety/built-in.test.js.map +1 -0
- package/dist/src/safety/checker-runner.d.ts +48 -0
- package/dist/src/safety/checker-runner.js +208 -0
- package/dist/src/safety/checker-runner.js.map +1 -0
- package/dist/src/safety/checker-runner.test.d.ts +6 -0
- package/dist/src/safety/checker-runner.test.js +238 -0
- package/dist/src/safety/checker-runner.test.js.map +1 -0
- package/dist/src/safety/context-builder.d.ts +23 -0
- package/dist/src/safety/context-builder.js +47 -0
- package/dist/src/safety/context-builder.js.map +1 -0
- package/dist/src/safety/context-builder.test.d.ts +6 -0
- package/dist/src/safety/context-builder.test.js +49 -0
- package/dist/src/safety/context-builder.test.js.map +1 -0
- package/dist/src/safety/protocol.d.ts +88 -0
- package/dist/src/safety/protocol.js +15 -0
- package/dist/src/safety/protocol.js.map +1 -0
- package/dist/src/safety/registry.d.ts +26 -0
- package/dist/src/safety/registry.js +65 -0
- package/dist/src/safety/registry.js.map +1 -0
- package/dist/src/safety/registry.test.d.ts +6 -0
- package/dist/src/safety/registry.test.js +31 -0
- package/dist/src/safety/registry.test.js.map +1 -0
- package/dist/src/services/chatCompressionService.d.ts +32 -0
- package/dist/src/services/chatCompressionService.js +162 -0
- package/dist/src/services/chatCompressionService.js.map +1 -0
- package/dist/src/services/chatCompressionService.test.d.ts +6 -0
- package/dist/src/services/chatCompressionService.test.js +210 -0
- package/dist/src/services/chatCompressionService.test.js.map +1 -0
- package/dist/src/services/chatRecordingService.d.ts +10 -15
- package/dist/src/services/chatRecordingService.js +43 -29
- package/dist/src/services/chatRecordingService.js.map +1 -1
- package/dist/src/services/chatRecordingService.test.js +69 -25
- package/dist/src/services/chatRecordingService.test.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.d.ts +8 -10
- package/dist/src/services/fileDiscoveryService.js +31 -53
- package/dist/src/services/fileDiscoveryService.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.test.js +94 -14
- package/dist/src/services/fileDiscoveryService.test.js.map +1 -1
- package/dist/src/services/fileSystemService.d.ts +9 -0
- package/dist/src/services/fileSystemService.js +12 -1
- package/dist/src/services/fileSystemService.js.map +1 -1
- package/dist/src/services/fileSystemService.test.js +1 -1
- package/dist/src/services/fileSystemService.test.js.map +1 -1
- package/dist/src/services/gitService.d.ts +3 -1
- package/dist/src/services/gitService.js +30 -24
- package/dist/src/services/gitService.js.map +1 -1
- package/dist/src/services/gitService.test.js +30 -37
- package/dist/src/services/gitService.test.js.map +1 -1
- package/dist/src/services/loopDetectionService.d.ts +12 -3
- package/dist/src/services/loopDetectionService.js +148 -55
- package/dist/src/services/loopDetectionService.js.map +1 -1
- package/dist/src/services/loopDetectionService.test.js +280 -21
- package/dist/src/services/loopDetectionService.test.js.map +1 -1
- package/dist/src/services/modelConfig.golden.test.d.ts +6 -0
- package/dist/src/services/modelConfig.golden.test.js +42 -0
- package/dist/src/services/modelConfig.golden.test.js.map +1 -0
- package/dist/src/services/modelConfig.integration.test.d.ts +6 -0
- package/dist/src/services/modelConfig.integration.test.js +247 -0
- package/dist/src/services/modelConfig.integration.test.js.map +1 -0
- package/dist/src/services/modelConfigService.d.ts +48 -0
- package/dist/src/services/modelConfigService.js +151 -0
- package/dist/src/services/modelConfigService.js.map +1 -0
- package/dist/src/services/modelConfigService.test.d.ts +6 -0
- package/dist/src/services/modelConfigService.test.js +531 -0
- package/dist/src/services/modelConfigService.test.js.map +1 -0
- package/dist/src/services/shellExecutionService.d.ts +37 -2
- package/dist/src/services/shellExecutionService.js +361 -67
- package/dist/src/services/shellExecutionService.js.map +1 -1
- package/dist/src/services/shellExecutionService.test.js +333 -71
- package/dist/src/services/shellExecutionService.test.js.map +1 -1
- package/dist/src/services/test-data/resolved-aliases.golden.json +202 -0
- package/dist/src/telemetry/activity-detector.d.ts +41 -0
- package/dist/src/telemetry/activity-detector.js +61 -0
- package/dist/src/telemetry/activity-detector.js.map +1 -0
- package/dist/src/telemetry/activity-detector.test.d.ts +6 -0
- package/dist/src/telemetry/activity-detector.test.js +136 -0
- package/dist/src/telemetry/activity-detector.test.js.map +1 -0
- package/dist/src/telemetry/activity-monitor.d.ts +116 -0
- package/dist/src/telemetry/activity-monitor.js +209 -0
- package/dist/src/telemetry/activity-monitor.js.map +1 -0
- package/dist/src/telemetry/activity-monitor.test.d.ts +6 -0
- package/dist/src/telemetry/activity-monitor.test.js +251 -0
- package/dist/src/telemetry/activity-monitor.test.js.map +1 -0
- package/dist/src/telemetry/activity-types.d.ts +19 -0
- package/dist/src/telemetry/activity-types.js +21 -0
- package/dist/src/telemetry/activity-types.js.map +1 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +53 -5
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +581 -56
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.d.ts +2 -0
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js +467 -31
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +75 -4
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +182 -6
- package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -1
- package/dist/src/telemetry/config.d.ts +31 -0
- package/dist/src/telemetry/config.js +76 -0
- package/dist/src/telemetry/config.js.map +1 -0
- package/dist/src/telemetry/config.test.d.ts +6 -0
- package/dist/src/telemetry/config.test.js +124 -0
- package/dist/src/telemetry/config.test.js.map +1 -0
- package/dist/src/telemetry/constants.d.ts +0 -18
- package/dist/src/telemetry/constants.js +0 -18
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/file-exporters.d.ts +5 -4
- package/dist/src/telemetry/file-exporters.js +1 -1
- package/dist/src/telemetry/file-exporters.js.map +1 -1
- package/dist/src/telemetry/gcp-exporters.d.ts +34 -0
- package/dist/src/telemetry/gcp-exporters.js +116 -0
- package/dist/src/telemetry/gcp-exporters.js.map +1 -0
- package/dist/src/telemetry/gcp-exporters.test.d.ts +6 -0
- package/dist/src/telemetry/gcp-exporters.test.js +318 -0
- package/dist/src/telemetry/gcp-exporters.test.js.map +1 -0
- package/dist/src/telemetry/high-water-mark-tracker.d.ts +43 -0
- package/dist/src/telemetry/high-water-mark-tracker.js +88 -0
- package/dist/src/telemetry/high-water-mark-tracker.js.map +1 -0
- package/dist/src/telemetry/high-water-mark-tracker.test.d.ts +6 -0
- package/dist/src/telemetry/high-water-mark-tracker.test.js +152 -0
- package/dist/src/telemetry/high-water-mark-tracker.test.js.map +1 -0
- package/dist/src/telemetry/index.d.ts +16 -2
- package/dist/src/telemetry/index.js +25 -2
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/loggers.d.ts +25 -3
- package/dist/src/telemetry/loggers.js +333 -154
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/loggers.test.circular.js +3 -4
- package/dist/src/telemetry/loggers.test.circular.js.map +1 -1
- package/dist/src/telemetry/loggers.test.js +868 -63
- package/dist/src/telemetry/loggers.test.js.map +1 -1
- package/dist/src/telemetry/memory-monitor.d.ts +149 -0
- package/dist/src/telemetry/memory-monitor.js +335 -0
- package/dist/src/telemetry/memory-monitor.js.map +1 -0
- package/dist/src/telemetry/memory-monitor.test.d.ts +6 -0
- package/dist/src/telemetry/memory-monitor.test.js +472 -0
- package/dist/src/telemetry/memory-monitor.test.js.map +1 -0
- package/dist/src/telemetry/metrics.d.ts +498 -11
- package/dist/src/telemetry/metrics.js +729 -84
- package/dist/src/telemetry/metrics.js.map +1 -1
- package/dist/src/telemetry/metrics.test.js +964 -101
- package/dist/src/telemetry/metrics.test.js.map +1 -1
- package/dist/src/telemetry/rate-limiter.d.ts +48 -0
- package/dist/src/telemetry/rate-limiter.js +100 -0
- package/dist/src/telemetry/rate-limiter.js.map +1 -0
- package/dist/src/telemetry/rate-limiter.test.d.ts +6 -0
- package/dist/src/telemetry/rate-limiter.test.js +207 -0
- package/dist/src/telemetry/rate-limiter.test.js.map +1 -0
- package/dist/src/telemetry/sdk.d.ts +1 -1
- package/dist/src/telemetry/sdk.js +23 -4
- package/dist/src/telemetry/sdk.js.map +1 -1
- package/dist/src/telemetry/sdk.test.js +108 -0
- package/dist/src/telemetry/sdk.test.js.map +1 -1
- package/dist/src/telemetry/semantic.d.ts +82 -0
- package/dist/src/telemetry/semantic.js +269 -0
- package/dist/src/telemetry/semantic.js.map +1 -0
- package/dist/src/telemetry/semantic.test.d.ts +6 -0
- package/dist/src/telemetry/semantic.test.js +387 -0
- package/dist/src/telemetry/semantic.test.js.map +1 -0
- package/dist/src/telemetry/telemetry-utils.d.ts +6 -0
- package/dist/src/telemetry/telemetry-utils.js +14 -0
- package/dist/src/telemetry/telemetry-utils.js.map +1 -0
- package/dist/src/telemetry/telemetry-utils.test.d.ts +6 -0
- package/dist/src/telemetry/telemetry-utils.test.js +41 -0
- package/dist/src/telemetry/telemetry-utils.test.js.map +1 -0
- package/dist/src/telemetry/telemetryAttributes.d.ts +8 -0
- package/dist/src/telemetry/telemetryAttributes.js +19 -0
- package/dist/src/telemetry/telemetryAttributes.js.map +1 -0
- package/dist/src/telemetry/trace.d.ts +46 -0
- package/dist/src/telemetry/trace.js +121 -0
- package/dist/src/telemetry/trace.js.map +1 -0
- package/dist/src/telemetry/types.d.ts +351 -25
- package/dist/src/telemetry/types.js +1071 -63
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.d.ts +4 -4
- package/dist/src/telemetry/uiTelemetry.js +14 -15
- package/dist/src/telemetry/uiTelemetry.js.map +1 -1
- package/dist/src/telemetry/uiTelemetry.test.js +122 -96
- package/dist/src/telemetry/uiTelemetry.test.js.map +1 -1
- package/dist/src/test-utils/config.d.ts +3 -2
- package/dist/src/test-utils/config.js +1 -1
- package/dist/src/test-utils/config.js.map +1 -1
- package/dist/src/test-utils/index.d.ts +6 -0
- package/dist/src/test-utils/index.js +7 -0
- package/dist/src/test-utils/index.js.map +1 -0
- package/dist/src/test-utils/mock-tool.d.ts +66 -0
- package/dist/src/test-utils/{tools.js → mock-tool.js} +45 -29
- package/dist/src/test-utils/mock-tool.js.map +1 -0
- package/dist/src/test-utils/mockWorkspaceContext.d.ts +1 -1
- package/dist/src/tools/base-tool-invocation.test.d.ts +6 -0
- package/dist/src/tools/base-tool-invocation.test.js +85 -0
- package/dist/src/tools/base-tool-invocation.test.js.map +1 -0
- package/dist/src/tools/diffOptions.d.ts +1 -1
- package/dist/src/tools/diffOptions.js +21 -13
- package/dist/src/tools/diffOptions.js.map +1 -1
- package/dist/src/tools/diffOptions.test.js +58 -22
- package/dist/src/tools/diffOptions.test.js.map +1 -1
- package/dist/src/tools/edit.d.ts +10 -8
- package/dist/src/tools/edit.js +100 -79
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +429 -163
- package/dist/src/tools/edit.test.js.map +1 -1
- package/dist/src/tools/glob.d.ts +11 -5
- package/dist/src/tools/glob.js +58 -42
- package/dist/src/tools/glob.js.map +1 -1
- package/dist/src/tools/glob.test.js +249 -166
- package/dist/src/tools/glob.test.js.map +1 -1
- package/dist/src/tools/grep.d.ts +7 -5
- package/dist/src/tools/grep.js +66 -40
- package/dist/src/tools/grep.js.map +1 -1
- package/dist/src/tools/grep.test.js +41 -15
- package/dist/src/tools/grep.test.js.map +1 -1
- package/dist/src/tools/ls.d.ts +7 -5
- package/dist/src/tools/ls.js +54 -68
- package/dist/src/tools/ls.js.map +1 -1
- package/dist/src/tools/ls.test.js +150 -293
- package/dist/src/tools/ls.test.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.d.ts +52 -12
- package/dist/src/tools/mcp-client-manager.js +196 -27
- package/dist/src/tools/mcp-client-manager.js.map +1 -1
- package/dist/src/tools/mcp-client-manager.test.js +139 -13
- package/dist/src/tools/mcp-client-manager.test.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +28 -24
- package/dist/src/tools/mcp-client.js +338 -351
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +380 -193
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/mcp-tool.d.ts +11 -5
- package/dist/src/tools/mcp-tool.js +66 -17
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/mcp-tool.test.js +278 -211
- package/dist/src/tools/mcp-tool.test.js.map +1 -1
- package/dist/src/tools/memoryTool.d.ts +10 -7
- package/dist/src/tools/memoryTool.js +28 -49
- package/dist/src/tools/memoryTool.js.map +1 -1
- package/dist/src/tools/memoryTool.test.js +26 -13
- package/dist/src/tools/memoryTool.test.js.map +1 -1
- package/dist/src/tools/message-bus-integration.test.d.ts +6 -0
- package/dist/src/tools/message-bus-integration.test.js +196 -0
- package/dist/src/tools/message-bus-integration.test.js.map +1 -0
- package/dist/src/tools/modifiable-tool.d.ts +7 -3
- package/dist/src/tools/modifiable-tool.js +41 -19
- package/dist/src/tools/modifiable-tool.js.map +1 -1
- package/dist/src/tools/modifiable-tool.test.js +70 -35
- package/dist/src/tools/modifiable-tool.test.js.map +1 -1
- package/dist/src/tools/read-file.d.ts +9 -7
- package/dist/src/tools/read-file.js +39 -60
- package/dist/src/tools/read-file.js.map +1 -1
- package/dist/src/tools/read-file.test.js +103 -36
- package/dist/src/tools/read-file.test.js.map +1 -1
- package/dist/src/tools/read-many-files.d.ts +9 -14
- package/dist/src/tools/read-many-files.js +71 -155
- package/dist/src/tools/read-many-files.js.map +1 -1
- package/dist/src/tools/read-many-files.test.js +98 -44
- package/dist/src/tools/read-many-files.test.js.map +1 -1
- package/dist/src/tools/ripGrep.d.ts +73 -0
- package/dist/src/tools/ripGrep.js +395 -0
- package/dist/src/tools/ripGrep.js.map +1 -0
- package/dist/src/tools/ripGrep.test.d.ts +6 -0
- package/dist/src/tools/ripGrep.test.js +1305 -0
- package/dist/src/tools/ripGrep.test.js.map +1 -0
- package/dist/src/tools/shell.d.ts +19 -6
- package/dist/src/tools/shell.js +92 -56
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +176 -103
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/smart-edit.d.ts +78 -0
- package/dist/src/tools/smart-edit.js +717 -0
- package/dist/src/tools/smart-edit.js.map +1 -0
- package/dist/src/tools/smart-edit.test.d.ts +6 -0
- package/dist/src/tools/smart-edit.test.js +592 -0
- package/dist/src/tools/smart-edit.test.js.map +1 -0
- package/dist/src/tools/tool-error.d.ts +39 -1
- package/dist/src/tools/tool-error.js +54 -0
- package/dist/src/tools/tool-error.js.map +1 -1
- package/dist/src/tools/tool-names.d.ts +17 -0
- package/dist/src/tools/tool-names.js +21 -0
- package/dist/src/tools/tool-names.js.map +1 -0
- package/dist/src/tools/tool-registry.d.ts +38 -20
- package/dist/src/tools/tool-registry.js +134 -77
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tool-registry.test.js +218 -58
- package/dist/src/tools/tool-registry.test.js.map +1 -1
- package/dist/src/tools/tools.d.ts +49 -17
- package/dist/src/tools/tools.js +150 -8
- package/dist/src/tools/tools.js.map +1 -1
- package/dist/src/tools/tools.test.js +1 -2
- package/dist/src/tools/tools.test.js.map +1 -1
- package/dist/src/tools/web-fetch.d.ts +14 -5
- package/dist/src/tools/web-fetch.js +90 -44
- package/dist/src/tools/web-fetch.js.map +1 -1
- package/dist/src/tools/web-fetch.test.js +388 -20
- package/dist/src/tools/web-fetch.test.js.map +1 -1
- package/dist/src/tools/web-search.d.ts +8 -6
- package/dist/src/tools/web-search.js +40 -15
- package/dist/src/tools/web-search.js.map +1 -1
- package/dist/src/tools/web-search.test.js +75 -1
- package/dist/src/tools/web-search.test.js.map +1 -1
- package/dist/src/tools/write-file.d.ts +7 -5
- package/dist/src/tools/write-file.js +54 -54
- package/dist/src/tools/write-file.js.map +1 -1
- package/dist/src/tools/write-file.test.js +237 -146
- package/dist/src/tools/write-file.test.js.map +1 -1
- package/dist/src/tools/write-todos.d.ts +50 -0
- package/dist/src/tools/write-todos.js +193 -0
- package/dist/src/tools/write-todos.js.map +1 -0
- package/dist/src/tools/write-todos.test.d.ts +6 -0
- package/dist/src/tools/write-todos.test.js +89 -0
- package/dist/src/tools/write-todos.test.js.map +1 -0
- package/dist/src/utils/bfsFileSearch.d.ts +2 -2
- package/dist/src/utils/bfsFileSearch.js +16 -9
- package/dist/src/utils/bfsFileSearch.js.map +1 -1
- package/dist/src/utils/bfsFileSearch.test.js +3 -3
- package/dist/src/utils/bfsFileSearch.test.js.map +1 -1
- package/dist/src/utils/channel.d.ts +19 -0
- package/dist/src/utils/channel.js +49 -0
- package/dist/src/utils/channel.js.map +1 -0
- package/dist/src/utils/channel.test.d.ts +6 -0
- package/dist/src/utils/channel.test.js +170 -0
- package/dist/src/utils/channel.test.js.map +1 -0
- package/dist/src/utils/debugLogger.d.ts +25 -0
- package/dist/src/utils/debugLogger.js +33 -0
- package/dist/src/utils/debugLogger.js.map +1 -0
- package/dist/src/utils/debugLogger.test.d.ts +6 -0
- package/dist/src/utils/debugLogger.test.js +69 -0
- package/dist/src/utils/debugLogger.test.js.map +1 -0
- package/dist/src/utils/delay.d.ts +16 -0
- package/dist/src/utils/delay.js +43 -0
- package/dist/src/utils/delay.js.map +1 -0
- package/dist/src/utils/delay.test.d.ts +6 -0
- package/dist/src/utils/delay.test.js +88 -0
- package/dist/src/utils/delay.test.js.map +1 -0
- package/dist/src/utils/editCorrector.d.ts +9 -8
- package/dist/src/utils/editCorrector.js +62 -34
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editCorrector.test.js +52 -87
- package/dist/src/utils/editCorrector.test.js.map +1 -1
- package/dist/src/utils/editor.d.ts +4 -2
- package/dist/src/utils/editor.js +56 -55
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/editor.test.js +47 -88
- package/dist/src/utils/editor.test.js.map +1 -1
- package/dist/src/utils/environmentContext.d.ts +3 -2
- package/dist/src/utils/environmentContext.js +20 -33
- package/dist/src/utils/environmentContext.js.map +1 -1
- package/dist/src/utils/environmentContext.test.js +6 -34
- package/dist/src/utils/environmentContext.test.js.map +1 -1
- package/dist/src/utils/errorParsing.d.ts +1 -1
- package/dist/src/utils/errorParsing.js +5 -33
- package/dist/src/utils/errorParsing.js.map +1 -1
- package/dist/src/utils/errorParsing.test.js +0 -88
- package/dist/src/utils/errorParsing.test.js.map +1 -1
- package/dist/src/utils/errorReporting.d.ts +1 -1
- package/dist/src/utils/errors.d.ts +28 -0
- package/dist/src/utils/errors.js +48 -0
- package/dist/src/utils/errors.js.map +1 -1
- package/dist/src/utils/events.d.ts +121 -0
- package/dist/src/utils/events.js +84 -0
- package/dist/src/utils/events.js.map +1 -0
- package/dist/src/utils/events.test.d.ts +6 -0
- package/dist/src/utils/events.test.js +212 -0
- package/dist/src/utils/events.test.js.map +1 -0
- package/dist/src/utils/extensionLoader.d.ts +86 -0
- package/dist/src/utils/extensionLoader.js +208 -0
- package/dist/src/utils/extensionLoader.js.map +1 -0
- package/dist/src/utils/extensionLoader.test.d.ts +6 -0
- package/dist/src/utils/extensionLoader.test.js +154 -0
- package/dist/src/utils/extensionLoader.test.js.map +1 -0
- package/dist/src/utils/fetch.d.ts +1 -0
- package/dist/src/utils/fetch.js +5 -1
- package/dist/src/utils/fetch.js.map +1 -1
- package/dist/src/utils/fileUtils.d.ts +28 -12
- package/dist/src/utils/fileUtils.js +204 -81
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/fileUtils.test.js +426 -82
- package/dist/src/utils/fileUtils.test.js.map +1 -1
- package/dist/src/utils/filesearch/crawler.d.ts +1 -1
- package/dist/src/utils/filesearch/crawler.test.js +2 -2
- package/dist/src/utils/filesearch/crawler.test.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.d.ts +1 -0
- package/dist/src/utils/filesearch/fileSearch.js +14 -9
- package/dist/src/utils/filesearch/fileSearch.js.map +1 -1
- package/dist/src/utils/filesearch/fileSearch.test.js +90 -0
- package/dist/src/utils/filesearch/fileSearch.test.js.map +1 -1
- package/dist/src/utils/flashFallback.test.d.ts +6 -0
- package/dist/src/utils/flashFallback.test.js +103 -0
- package/dist/src/utils/flashFallback.test.js.map +1 -0
- package/dist/src/utils/formatters.d.ts +1 -0
- package/dist/src/utils/formatters.js +2 -1
- package/dist/src/utils/formatters.js.map +1 -1
- package/dist/src/utils/formatters.test.d.ts +6 -0
- package/dist/src/utils/formatters.test.js +26 -0
- package/dist/src/utils/formatters.test.js.map +1 -0
- package/dist/src/utils/geminiIgnoreParser.d.ts +18 -0
- package/dist/src/utils/geminiIgnoreParser.js +61 -0
- package/dist/src/utils/geminiIgnoreParser.js.map +1 -0
- package/dist/src/utils/geminiIgnoreParser.test.d.ts +6 -0
- package/dist/src/utils/geminiIgnoreParser.test.js +50 -0
- package/dist/src/utils/geminiIgnoreParser.test.js.map +1 -0
- package/dist/src/utils/generateContentResponseUtilities.d.ts +1 -2
- package/dist/src/utils/generateContentResponseUtilities.js +1 -13
- package/dist/src/utils/generateContentResponseUtilities.js.map +1 -1
- package/dist/src/utils/generateContentResponseUtilities.test.js +2 -40
- package/dist/src/utils/generateContentResponseUtilities.test.js.map +1 -1
- package/dist/src/utils/getFolderStructure.d.ts +2 -2
- package/dist/src/utils/getFolderStructure.js +12 -20
- package/dist/src/utils/getFolderStructure.js.map +1 -1
- package/dist/src/utils/getFolderStructure.test.js +11 -10
- package/dist/src/utils/getFolderStructure.test.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.d.ts +7 -8
- package/dist/src/utils/gitIgnoreParser.js +145 -36
- package/dist/src/utils/gitIgnoreParser.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.test.js +127 -38
- package/dist/src/utils/gitIgnoreParser.test.js.map +1 -1
- package/dist/src/utils/gitUtils.js +2 -2
- package/dist/src/utils/gitUtils.js.map +1 -1
- package/dist/src/utils/googleErrors.d.ts +104 -0
- package/dist/src/utils/googleErrors.js +152 -0
- package/dist/src/utils/googleErrors.js.map +1 -0
- package/dist/src/utils/googleErrors.test.d.ts +6 -0
- package/dist/src/utils/googleErrors.test.js +301 -0
- package/dist/src/utils/googleErrors.test.js.map +1 -0
- package/dist/src/utils/googleQuotaErrors.d.ts +37 -0
- package/dist/src/utils/googleQuotaErrors.js +157 -0
- package/dist/src/utils/googleQuotaErrors.js.map +1 -0
- package/dist/src/utils/googleQuotaErrors.test.d.ts +6 -0
- package/dist/src/utils/googleQuotaErrors.test.js +311 -0
- package/dist/src/utils/googleQuotaErrors.test.js.map +1 -0
- package/dist/src/utils/httpErrors.d.ts +18 -0
- package/dist/src/utils/httpErrors.js +36 -0
- package/dist/src/utils/httpErrors.js.map +1 -0
- package/dist/src/utils/ignorePatterns.d.ts +103 -0
- package/dist/src/utils/ignorePatterns.js +220 -0
- package/dist/src/utils/ignorePatterns.js.map +1 -0
- package/dist/src/utils/ignorePatterns.test.d.ts +6 -0
- package/dist/src/utils/ignorePatterns.test.js +246 -0
- package/dist/src/utils/ignorePatterns.test.js.map +1 -0
- package/dist/src/utils/installationManager.d.ts +16 -0
- package/dist/src/utils/installationManager.js +51 -0
- package/dist/src/utils/installationManager.js.map +1 -0
- package/dist/src/utils/installationManager.test.d.ts +6 -0
- package/dist/src/utils/installationManager.test.js +85 -0
- package/dist/src/utils/installationManager.test.js.map +1 -0
- package/dist/src/utils/language-detection.d.ts +6 -0
- package/dist/src/utils/language-detection.js +101 -0
- package/dist/src/utils/language-detection.js.map +1 -0
- package/dist/src/utils/llm-edit-fixer.d.ts +26 -0
- package/dist/src/utils/llm-edit-fixer.js +155 -0
- package/dist/src/utils/llm-edit-fixer.js.map +1 -0
- package/dist/src/utils/llm-edit-fixer.test.d.ts +6 -0
- package/dist/src/utils/llm-edit-fixer.test.js +223 -0
- package/dist/src/utils/llm-edit-fixer.test.js.map +1 -0
- package/dist/src/utils/memoryDiscovery.d.ts +26 -6
- package/dist/src/utils/memoryDiscovery.js +239 -40
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +365 -44
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.js +19 -25
- package/dist/src/utils/memoryImportProcessor.js.map +1 -1
- package/dist/src/utils/memoryImportProcessor.test.js +24 -155
- package/dist/src/utils/memoryImportProcessor.test.js.map +1 -1
- package/dist/src/utils/messageInspectors.d.ts +1 -1
- package/dist/src/utils/nextSpeakerChecker.d.ts +3 -3
- package/dist/src/utils/nextSpeakerChecker.js +10 -4
- package/dist/src/utils/nextSpeakerChecker.js.map +1 -1
- package/dist/src/utils/nextSpeakerChecker.test.js +85 -66
- package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -1
- package/dist/src/utils/package.d.ts +12 -0
- package/dist/src/utils/package.js +15 -0
- package/dist/src/utils/package.js.map +1 -0
- package/dist/src/utils/partUtils.d.ts +22 -1
- package/dist/src/utils/partUtils.js +68 -0
- package/dist/src/utils/partUtils.js.map +1 -1
- package/dist/src/utils/partUtils.test.js +112 -1
- package/dist/src/utils/partUtils.test.js.map +1 -1
- package/dist/src/utils/pathCorrector.d.ts +25 -0
- package/dist/src/utils/pathCorrector.js +33 -0
- package/dist/src/utils/pathCorrector.js.map +1 -0
- package/dist/src/utils/pathCorrector.test.d.ts +6 -0
- package/dist/src/utils/pathCorrector.test.js +83 -0
- package/dist/src/utils/pathCorrector.test.js.map +1 -0
- package/dist/src/utils/pathReader.d.ts +17 -0
- package/dist/src/utils/pathReader.js +92 -0
- package/dist/src/utils/pathReader.js.map +1 -0
- package/dist/src/utils/pathReader.test.d.ts +6 -0
- package/dist/src/utils/pathReader.test.js +406 -0
- package/dist/src/utils/pathReader.test.js.map +1 -0
- package/dist/src/utils/paths.d.ts +1 -18
- package/dist/src/utils/paths.js +133 -57
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/paths.test.js +200 -68
- package/dist/src/utils/paths.test.js.map +1 -1
- package/dist/src/utils/promptIdContext.d.ts +7 -0
- package/dist/src/utils/promptIdContext.js +8 -0
- package/dist/src/utils/promptIdContext.js.map +1 -0
- package/dist/src/utils/quotaErrorDetection.d.ts +1 -3
- package/dist/src/utils/quotaErrorDetection.js +0 -46
- package/dist/src/utils/quotaErrorDetection.js.map +1 -1
- package/dist/src/utils/retry.d.ts +5 -10
- package/dist/src/utils/retry.js +114 -197
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/retry.test.js +196 -130
- package/dist/src/utils/retry.test.js.map +1 -1
- package/dist/src/utils/safeJsonStringify.d.ts +4 -4
- package/dist/src/utils/safeJsonStringify.js +31 -7
- package/dist/src/utils/safeJsonStringify.js.map +1 -1
- package/dist/src/utils/schemaValidator.js +15 -1
- package/dist/src/utils/schemaValidator.js.map +1 -1
- package/dist/src/utils/schemaValidator.test.d.ts +6 -0
- package/dist/src/utils/schemaValidator.test.js +113 -0
- package/dist/src/utils/schemaValidator.test.js.map +1 -0
- package/dist/src/utils/session.js +1 -1
- package/dist/src/utils/session.js.map +1 -1
- package/dist/src/utils/shell-utils.d.ts +21 -3
- package/dist/src/utils/shell-utils.js +427 -159
- package/dist/src/utils/shell-utils.js.map +1 -1
- package/dist/src/utils/shell-utils.test.js +250 -59
- package/dist/src/utils/shell-utils.test.js.map +1 -1
- package/dist/src/utils/stdio.d.ts +32 -0
- package/dist/src/utils/stdio.js +85 -0
- package/dist/src/utils/stdio.js.map +1 -0
- package/dist/src/utils/stdio.test.d.ts +6 -0
- package/dist/src/utils/stdio.test.js +47 -0
- package/dist/src/utils/stdio.test.js.map +1 -0
- package/dist/src/utils/summarizer.d.ts +6 -4
- package/dist/src/utils/summarizer.js +8 -9
- package/dist/src/utils/summarizer.js.map +1 -1
- package/dist/src/utils/summarizer.test.js +32 -12
- package/dist/src/utils/summarizer.test.js.map +1 -1
- package/dist/src/utils/systemEncoding.js +7 -6
- package/dist/src/utils/systemEncoding.js.map +1 -1
- package/dist/src/utils/systemEncoding.test.js +4 -3
- package/dist/src/utils/systemEncoding.test.js.map +1 -1
- package/dist/src/utils/terminal.d.ts +14 -0
- package/dist/src/utils/terminal.js +38 -0
- package/dist/src/utils/terminal.js.map +1 -0
- package/dist/src/utils/terminalSerializer.d.ts +25 -0
- package/dist/src/utils/terminalSerializer.js +432 -0
- package/dist/src/utils/terminalSerializer.js.map +1 -0
- package/dist/src/utils/terminalSerializer.test.d.ts +6 -0
- package/dist/src/utils/terminalSerializer.test.js +176 -0
- package/dist/src/utils/terminalSerializer.test.js.map +1 -0
- package/dist/src/utils/textUtils.d.ts +5 -0
- package/dist/src/utils/textUtils.js +14 -0
- package/dist/src/utils/textUtils.js.map +1 -1
- package/dist/src/utils/textUtils.test.d.ts +6 -0
- package/dist/src/utils/textUtils.test.js +59 -0
- package/dist/src/utils/textUtils.test.js.map +1 -0
- package/dist/src/utils/thoughtUtils.d.ts +21 -0
- package/dist/src/utils/thoughtUtils.js +39 -0
- package/dist/src/utils/thoughtUtils.js.map +1 -0
- package/dist/src/utils/thoughtUtils.test.d.ts +6 -0
- package/dist/src/utils/thoughtUtils.test.js +78 -0
- package/dist/src/utils/thoughtUtils.test.js.map +1 -0
- package/dist/src/utils/tool-utils.d.ts +19 -0
- package/dist/src/utils/tool-utils.js +67 -0
- package/dist/src/utils/tool-utils.js.map +1 -0
- package/dist/src/utils/tool-utils.test.d.ts +6 -0
- package/dist/src/utils/tool-utils.test.js +69 -0
- package/dist/src/utils/tool-utils.test.js.map +1 -0
- package/dist/src/utils/userAccountManager.d.ts +20 -0
- package/dist/src/utils/userAccountManager.js +115 -0
- package/dist/src/utils/userAccountManager.js.map +1 -0
- package/dist/src/utils/userAccountManager.test.d.ts +6 -0
- package/dist/src/utils/{user_account.test.js → userAccountManager.test.js} +41 -36
- package/dist/src/utils/userAccountManager.test.js.map +1 -0
- package/dist/src/utils/workspaceContext.d.ts +4 -3
- package/dist/src/utils/workspaceContext.js +23 -17
- package/dist/src/utils/workspaceContext.js.map +1 -1
- package/dist/src/utils/workspaceContext.test.js +45 -19
- package/dist/src/utils/workspaceContext.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +24 -10
- package/dist/src/core/modelCheck.d.ts +0 -14
- package/dist/src/core/modelCheck.js +0 -62
- package/dist/src/core/modelCheck.js.map +0 -1
- package/dist/src/test-utils/tools.d.ts +0 -44
- package/dist/src/test-utils/tools.js.map +0 -1
- package/dist/src/utils/flashFallback.integration.test.js +0 -118
- package/dist/src/utils/flashFallback.integration.test.js.map +0 -1
- package/dist/src/utils/user_account.d.ts +0 -9
- package/dist/src/utils/user_account.js +0 -109
- package/dist/src/utils/user_account.js.map +0 -1
- package/dist/src/utils/user_account.test.js.map +0 -1
- package/dist/src/utils/user_id.d.ts +0 -11
- package/dist/src/utils/user_id.js +0 -49
- package/dist/src/utils/user_id.js.map +0 -1
- package/dist/src/utils/user_id.test.js +0 -21
- package/dist/src/utils/user_id.test.js.map +0 -1
- /package/dist/src/{utils/flashFallback.integration.test.d.ts → agents/codebase-investigator.test.d.ts} +0 -0
- /package/dist/src/{utils/user_account.test.d.ts → agents/executor.test.d.ts} +0 -0
- /package/dist/src/{utils/user_id.test.d.ts → agents/invocation.test.d.ts} +0 -0
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
7
|
-
import { FileOperation } from './metrics.js';
|
|
7
|
+
import { FileOperation, MemoryMetricType, ToolExecutionPhase, ApiRequestPhase, } from './metrics.js';
|
|
8
8
|
import { makeFakeConfig } from '../test-utils/config.js';
|
|
9
|
+
import { ModelRoutingEvent, AgentFinishEvent } from './types.js';
|
|
10
|
+
import { AgentTerminateMode } from '../agents/types.js';
|
|
9
11
|
const mockCounterAddFn = vi.fn();
|
|
10
12
|
const mockHistogramRecordFn = vi.fn();
|
|
11
13
|
const mockCreateCounterFn = vi.fn();
|
|
@@ -27,18 +29,44 @@ function originalOtelMockFactory() {
|
|
|
27
29
|
},
|
|
28
30
|
ValueType: {
|
|
29
31
|
INT: 1,
|
|
32
|
+
DOUBLE: 2,
|
|
30
33
|
},
|
|
31
34
|
diag: {
|
|
32
35
|
setLogger: vi.fn(),
|
|
36
|
+
warn: vi.fn(),
|
|
37
|
+
},
|
|
38
|
+
DiagConsoleLogger: vi.fn(),
|
|
39
|
+
DiagLogLevel: {
|
|
40
|
+
NONE: 0,
|
|
41
|
+
INFO: 1,
|
|
33
42
|
},
|
|
34
43
|
};
|
|
35
44
|
}
|
|
36
45
|
vi.mock('@opentelemetry/api');
|
|
46
|
+
vi.mock('./telemetryAttributes.js');
|
|
37
47
|
describe('Telemetry Metrics', () => {
|
|
38
48
|
let initializeMetricsModule;
|
|
39
49
|
let recordTokenUsageMetricsModule;
|
|
40
50
|
let recordFileOperationMetricModule;
|
|
41
51
|
let recordChatCompressionMetricsModule;
|
|
52
|
+
let recordModelRoutingMetricsModule;
|
|
53
|
+
let recordStartupPerformanceModule;
|
|
54
|
+
let recordMemoryUsageModule;
|
|
55
|
+
let recordCpuUsageModule;
|
|
56
|
+
let recordToolQueueDepthModule;
|
|
57
|
+
let recordToolExecutionBreakdownModule;
|
|
58
|
+
let recordTokenEfficiencyModule;
|
|
59
|
+
let recordApiRequestBreakdownModule;
|
|
60
|
+
let recordPerformanceScoreModule;
|
|
61
|
+
let recordPerformanceRegressionModule;
|
|
62
|
+
let recordBaselineComparisonModule;
|
|
63
|
+
let recordGenAiClientTokenUsageModule;
|
|
64
|
+
let recordGenAiClientOperationDurationModule;
|
|
65
|
+
let recordFlickerFrameModule;
|
|
66
|
+
let recordExitFailModule;
|
|
67
|
+
let recordAgentRunMetricsModule;
|
|
68
|
+
let recordLinesChangedModule;
|
|
69
|
+
let recordSlowRenderModule;
|
|
42
70
|
beforeEach(async () => {
|
|
43
71
|
vi.resetModules();
|
|
44
72
|
vi.doMock('@opentelemetry/api', () => {
|
|
@@ -46,12 +74,40 @@ describe('Telemetry Metrics', () => {
|
|
|
46
74
|
actualApi.metrics.getMeter.mockReturnValue(mockMeterInstance);
|
|
47
75
|
return actualApi;
|
|
48
76
|
});
|
|
77
|
+
const { getCommonAttributes } = await import('./telemetryAttributes.js');
|
|
78
|
+
getCommonAttributes.mockReturnValue({
|
|
79
|
+
'session.id': 'test-session-id',
|
|
80
|
+
'installation.id': 'test-installation-id',
|
|
81
|
+
'user.email': 'test@example.com',
|
|
82
|
+
});
|
|
49
83
|
const metricsJsModule = await import('./metrics.js');
|
|
50
84
|
initializeMetricsModule = metricsJsModule.initializeMetrics;
|
|
51
85
|
recordTokenUsageMetricsModule = metricsJsModule.recordTokenUsageMetrics;
|
|
52
86
|
recordFileOperationMetricModule = metricsJsModule.recordFileOperationMetric;
|
|
53
87
|
recordChatCompressionMetricsModule =
|
|
54
88
|
metricsJsModule.recordChatCompressionMetrics;
|
|
89
|
+
recordModelRoutingMetricsModule = metricsJsModule.recordModelRoutingMetrics;
|
|
90
|
+
recordStartupPerformanceModule = metricsJsModule.recordStartupPerformance;
|
|
91
|
+
recordMemoryUsageModule = metricsJsModule.recordMemoryUsage;
|
|
92
|
+
recordCpuUsageModule = metricsJsModule.recordCpuUsage;
|
|
93
|
+
recordToolQueueDepthModule = metricsJsModule.recordToolQueueDepth;
|
|
94
|
+
recordToolExecutionBreakdownModule =
|
|
95
|
+
metricsJsModule.recordToolExecutionBreakdown;
|
|
96
|
+
recordTokenEfficiencyModule = metricsJsModule.recordTokenEfficiency;
|
|
97
|
+
recordApiRequestBreakdownModule = metricsJsModule.recordApiRequestBreakdown;
|
|
98
|
+
recordPerformanceScoreModule = metricsJsModule.recordPerformanceScore;
|
|
99
|
+
recordPerformanceRegressionModule =
|
|
100
|
+
metricsJsModule.recordPerformanceRegression;
|
|
101
|
+
recordBaselineComparisonModule = metricsJsModule.recordBaselineComparison;
|
|
102
|
+
recordGenAiClientTokenUsageModule =
|
|
103
|
+
metricsJsModule.recordGenAiClientTokenUsage;
|
|
104
|
+
recordGenAiClientOperationDurationModule =
|
|
105
|
+
metricsJsModule.recordGenAiClientOperationDuration;
|
|
106
|
+
recordFlickerFrameModule = metricsJsModule.recordFlickerFrame;
|
|
107
|
+
recordExitFailModule = metricsJsModule.recordExitFail;
|
|
108
|
+
recordAgentRunMetricsModule = metricsJsModule.recordAgentRunMetrics;
|
|
109
|
+
recordLinesChangedModule = metricsJsModule.recordLinesChanged;
|
|
110
|
+
recordSlowRenderModule = metricsJsModule.recordSlowRender;
|
|
55
111
|
const otelApiModule = await import('@opentelemetry/api');
|
|
56
112
|
mockCounterAddFn.mockClear();
|
|
57
113
|
mockCreateCounterFn.mockClear();
|
|
@@ -62,6 +118,75 @@ describe('Telemetry Metrics', () => {
|
|
|
62
118
|
mockCreateCounterFn.mockReturnValue(mockCounterInstance);
|
|
63
119
|
mockCreateHistogramFn.mockReturnValue(mockHistogramInstance);
|
|
64
120
|
});
|
|
121
|
+
describe('recordFlickerFrame', () => {
|
|
122
|
+
it('does not record metrics if not initialized', () => {
|
|
123
|
+
const config = makeFakeConfig({});
|
|
124
|
+
recordFlickerFrameModule(config);
|
|
125
|
+
expect(mockCounterAddFn).not.toHaveBeenCalled();
|
|
126
|
+
});
|
|
127
|
+
it('records a flicker frame event when initialized', () => {
|
|
128
|
+
const config = makeFakeConfig({});
|
|
129
|
+
initializeMetricsModule(config);
|
|
130
|
+
recordFlickerFrameModule(config);
|
|
131
|
+
// Called for session, then for flicker
|
|
132
|
+
expect(mockCounterAddFn).toHaveBeenCalledTimes(2);
|
|
133
|
+
expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 1, {
|
|
134
|
+
'session.id': 'test-session-id',
|
|
135
|
+
'installation.id': 'test-installation-id',
|
|
136
|
+
'user.email': 'test@example.com',
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
describe('recordExitFail', () => {
|
|
141
|
+
it('does not record metrics if not initialized', () => {
|
|
142
|
+
const config = makeFakeConfig({});
|
|
143
|
+
recordExitFailModule(config);
|
|
144
|
+
expect(mockCounterAddFn).not.toHaveBeenCalled();
|
|
145
|
+
});
|
|
146
|
+
it('records a exit fail event when initialized', () => {
|
|
147
|
+
const config = makeFakeConfig({});
|
|
148
|
+
initializeMetricsModule(config);
|
|
149
|
+
recordExitFailModule(config);
|
|
150
|
+
// Called for session, then for exit fail
|
|
151
|
+
expect(mockCounterAddFn).toHaveBeenCalledTimes(2);
|
|
152
|
+
expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 1, {
|
|
153
|
+
'session.id': 'test-session-id',
|
|
154
|
+
'installation.id': 'test-installation-id',
|
|
155
|
+
'user.email': 'test@example.com',
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
describe('recordSlowRender', () => {
|
|
160
|
+
it('does not record metrics if not initialized', () => {
|
|
161
|
+
const config = makeFakeConfig({});
|
|
162
|
+
recordSlowRenderModule(config, 123);
|
|
163
|
+
expect(mockHistogramRecordFn).not.toHaveBeenCalled();
|
|
164
|
+
});
|
|
165
|
+
it('records a slow render event when initialized', () => {
|
|
166
|
+
const config = makeFakeConfig({});
|
|
167
|
+
initializeMetricsModule(config);
|
|
168
|
+
recordSlowRenderModule(config, 123);
|
|
169
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(123, {
|
|
170
|
+
'session.id': 'test-session-id',
|
|
171
|
+
'installation.id': 'test-installation-id',
|
|
172
|
+
'user.email': 'test@example.com',
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
describe('initializeMetrics', () => {
|
|
177
|
+
const mockConfig = {
|
|
178
|
+
getSessionId: () => 'test-session-id',
|
|
179
|
+
getTelemetryEnabled: () => true,
|
|
180
|
+
};
|
|
181
|
+
it('should apply common attributes including email', () => {
|
|
182
|
+
initializeMetricsModule(mockConfig);
|
|
183
|
+
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
184
|
+
'session.id': 'test-session-id',
|
|
185
|
+
'installation.id': 'test-installation-id',
|
|
186
|
+
'user.email': 'test@example.com',
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
});
|
|
65
190
|
describe('recordChatCompressionMetrics', () => {
|
|
66
191
|
it('does not record metrics if not initialized', () => {
|
|
67
192
|
const lol = makeFakeConfig({});
|
|
@@ -80,6 +205,8 @@ describe('Telemetry Metrics', () => {
|
|
|
80
205
|
});
|
|
81
206
|
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
82
207
|
'session.id': 'test-session-id',
|
|
208
|
+
'installation.id': 'test-installation-id',
|
|
209
|
+
'user.email': 'test@example.com',
|
|
83
210
|
tokens_after: 100,
|
|
84
211
|
tokens_before: 200,
|
|
85
212
|
});
|
|
@@ -88,153 +215,889 @@ describe('Telemetry Metrics', () => {
|
|
|
88
215
|
describe('recordTokenUsageMetrics', () => {
|
|
89
216
|
const mockConfig = {
|
|
90
217
|
getSessionId: () => 'test-session-id',
|
|
218
|
+
getTelemetryEnabled: () => true,
|
|
91
219
|
};
|
|
92
220
|
it('should not record metrics if not initialized', () => {
|
|
93
|
-
recordTokenUsageMetricsModule(mockConfig,
|
|
94
|
-
expect(mockCounterAddFn).not.toHaveBeenCalled();
|
|
95
|
-
});
|
|
96
|
-
it('should record token usage with the correct attributes', () => {
|
|
97
|
-
initializeMetricsModule(mockConfig);
|
|
98
|
-
recordTokenUsageMetricsModule(mockConfig, 'gemini-pro', 100, 'input');
|
|
99
|
-
expect(mockCounterAddFn).toHaveBeenCalledTimes(2);
|
|
100
|
-
expect(mockCounterAddFn).toHaveBeenNthCalledWith(1, 1, {
|
|
101
|
-
'session.id': 'test-session-id',
|
|
102
|
-
});
|
|
103
|
-
expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 100, {
|
|
104
|
-
'session.id': 'test-session-id',
|
|
221
|
+
recordTokenUsageMetricsModule(mockConfig, 100, {
|
|
105
222
|
model: 'gemini-pro',
|
|
106
223
|
type: 'input',
|
|
107
224
|
});
|
|
225
|
+
expect(mockCounterAddFn).not.toHaveBeenCalled();
|
|
108
226
|
});
|
|
109
|
-
it(
|
|
227
|
+
it.each([
|
|
228
|
+
{ type: 'input', tokens: 100, model: 'gemini-pro' },
|
|
229
|
+
{ type: 'output', tokens: 50, model: 'gemini-pro' },
|
|
230
|
+
{ type: 'thought', tokens: 25, model: 'gemini-pro' },
|
|
231
|
+
{ type: 'cache', tokens: 75, model: 'gemini-pro' },
|
|
232
|
+
{ type: 'tool', tokens: 125, model: 'gemini-pro' },
|
|
233
|
+
{ type: 'input', tokens: 200, model: 'gemini-different-model' },
|
|
234
|
+
])('should record token usage for $type type with $tokens tokens for model $model', ({ type, tokens, model }) => {
|
|
110
235
|
initializeMetricsModule(mockConfig);
|
|
111
236
|
mockCounterAddFn.mockClear();
|
|
112
|
-
recordTokenUsageMetricsModule(mockConfig,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
model: 'gemini-pro',
|
|
116
|
-
type: 'output',
|
|
237
|
+
recordTokenUsageMetricsModule(mockConfig, tokens, {
|
|
238
|
+
model,
|
|
239
|
+
type: type,
|
|
117
240
|
});
|
|
118
|
-
|
|
119
|
-
expect(mockCounterAddFn).toHaveBeenCalledWith(25, {
|
|
241
|
+
expect(mockCounterAddFn).toHaveBeenCalledWith(tokens, {
|
|
120
242
|
'session.id': 'test-session-id',
|
|
121
|
-
|
|
122
|
-
|
|
243
|
+
'installation.id': 'test-installation-id',
|
|
244
|
+
'user.email': 'test@example.com',
|
|
245
|
+
model,
|
|
246
|
+
type,
|
|
123
247
|
});
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
describe('recordLinesChanged metric', () => {
|
|
251
|
+
const mockConfig = {
|
|
252
|
+
getSessionId: () => 'test-session-id',
|
|
253
|
+
getTelemetryEnabled: () => true,
|
|
254
|
+
};
|
|
255
|
+
it('should not record lines added/removed if not initialized', () => {
|
|
256
|
+
recordLinesChangedModule(mockConfig, 10, 'added', {
|
|
257
|
+
function_name: 'fn',
|
|
258
|
+
});
|
|
259
|
+
recordLinesChangedModule(mockConfig, 5, 'removed', {
|
|
260
|
+
function_name: 'fn',
|
|
261
|
+
});
|
|
262
|
+
expect(mockCounterAddFn).not.toHaveBeenCalled();
|
|
263
|
+
});
|
|
264
|
+
it('should record lines added with function_name after initialization', () => {
|
|
265
|
+
initializeMetricsModule(mockConfig);
|
|
266
|
+
mockCounterAddFn.mockClear();
|
|
267
|
+
recordLinesChangedModule(mockConfig, 10, 'added', {
|
|
268
|
+
function_name: 'my-fn',
|
|
129
269
|
});
|
|
130
|
-
|
|
131
|
-
expect(mockCounterAddFn).toHaveBeenCalledWith(125, {
|
|
270
|
+
expect(mockCounterAddFn).toHaveBeenCalledWith(10, {
|
|
132
271
|
'session.id': 'test-session-id',
|
|
133
|
-
|
|
134
|
-
|
|
272
|
+
'installation.id': 'test-installation-id',
|
|
273
|
+
'user.email': 'test@example.com',
|
|
274
|
+
type: 'added',
|
|
275
|
+
function_name: 'my-fn',
|
|
135
276
|
});
|
|
136
277
|
});
|
|
137
|
-
it('should
|
|
278
|
+
it('should record lines removed with function_name after initialization', () => {
|
|
138
279
|
initializeMetricsModule(mockConfig);
|
|
139
280
|
mockCounterAddFn.mockClear();
|
|
140
|
-
|
|
141
|
-
|
|
281
|
+
recordLinesChangedModule(mockConfig, 7, 'removed', {
|
|
282
|
+
function_name: 'my-fn',
|
|
283
|
+
});
|
|
284
|
+
expect(mockCounterAddFn).toHaveBeenCalledWith(7, {
|
|
142
285
|
'session.id': 'test-session-id',
|
|
143
|
-
|
|
144
|
-
|
|
286
|
+
'installation.id': 'test-installation-id',
|
|
287
|
+
'user.email': 'test@example.com',
|
|
288
|
+
type: 'removed',
|
|
289
|
+
function_name: 'my-fn',
|
|
145
290
|
});
|
|
146
291
|
});
|
|
147
292
|
});
|
|
148
293
|
describe('recordFileOperationMetric', () => {
|
|
149
294
|
const mockConfig = {
|
|
150
295
|
getSessionId: () => 'test-session-id',
|
|
296
|
+
getTelemetryEnabled: () => true,
|
|
297
|
+
};
|
|
298
|
+
it.each([
|
|
299
|
+
{
|
|
300
|
+
name: 'should not record metrics if not initialized',
|
|
301
|
+
initialized: false,
|
|
302
|
+
attributes: {
|
|
303
|
+
operation: FileOperation.CREATE,
|
|
304
|
+
lines: 10,
|
|
305
|
+
mimetype: 'text/plain',
|
|
306
|
+
extension: 'txt',
|
|
307
|
+
},
|
|
308
|
+
shouldCall: false,
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
name: 'should record file creation with all attributes',
|
|
312
|
+
initialized: true,
|
|
313
|
+
attributes: {
|
|
314
|
+
operation: FileOperation.CREATE,
|
|
315
|
+
lines: 10,
|
|
316
|
+
mimetype: 'text/plain',
|
|
317
|
+
extension: 'txt',
|
|
318
|
+
},
|
|
319
|
+
shouldCall: true,
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
name: 'should record file read with minimal attributes',
|
|
323
|
+
initialized: true,
|
|
324
|
+
attributes: { operation: FileOperation.READ },
|
|
325
|
+
shouldCall: true,
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
name: 'should record file update with some attributes',
|
|
329
|
+
initialized: true,
|
|
330
|
+
attributes: {
|
|
331
|
+
operation: FileOperation.UPDATE,
|
|
332
|
+
mimetype: 'application/javascript',
|
|
333
|
+
},
|
|
334
|
+
shouldCall: true,
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
name: 'should record file update with no optional attributes',
|
|
338
|
+
initialized: true,
|
|
339
|
+
attributes: { operation: FileOperation.UPDATE },
|
|
340
|
+
shouldCall: true,
|
|
341
|
+
},
|
|
342
|
+
])('$name', ({ initialized, attributes, shouldCall }) => {
|
|
343
|
+
if (initialized) {
|
|
344
|
+
initializeMetricsModule(mockConfig);
|
|
345
|
+
// The session start event also calls the counter.
|
|
346
|
+
mockCounterAddFn.mockClear();
|
|
347
|
+
}
|
|
348
|
+
recordFileOperationMetricModule(mockConfig, attributes);
|
|
349
|
+
if (shouldCall) {
|
|
350
|
+
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
351
|
+
'session.id': 'test-session-id',
|
|
352
|
+
'installation.id': 'test-installation-id',
|
|
353
|
+
'user.email': 'test@example.com',
|
|
354
|
+
...attributes,
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
expect(mockCounterAddFn).not.toHaveBeenCalled();
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
describe('recordModelRoutingMetrics', () => {
|
|
363
|
+
const mockConfig = {
|
|
364
|
+
getSessionId: () => 'test-session-id',
|
|
365
|
+
getTelemetryEnabled: () => true,
|
|
151
366
|
};
|
|
152
367
|
it('should not record metrics if not initialized', () => {
|
|
153
|
-
|
|
368
|
+
const event = new ModelRoutingEvent('gemini-pro', 'default', 100, 'test-reason', false, undefined);
|
|
369
|
+
recordModelRoutingMetricsModule(mockConfig, event);
|
|
370
|
+
expect(mockHistogramRecordFn).not.toHaveBeenCalled();
|
|
154
371
|
expect(mockCounterAddFn).not.toHaveBeenCalled();
|
|
155
372
|
});
|
|
156
|
-
it('should record
|
|
373
|
+
it('should record latency for a successful routing decision', () => {
|
|
157
374
|
initializeMetricsModule(mockConfig);
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
expect(
|
|
375
|
+
const event = new ModelRoutingEvent('gemini-pro', 'default', 150, 'test-reason', false, undefined);
|
|
376
|
+
recordModelRoutingMetricsModule(mockConfig, event);
|
|
377
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(150, {
|
|
161
378
|
'session.id': 'test-session-id',
|
|
379
|
+
'installation.id': 'test-installation-id',
|
|
380
|
+
'user.email': 'test@example.com',
|
|
381
|
+
'routing.decision_model': 'gemini-pro',
|
|
382
|
+
'routing.decision_source': 'default',
|
|
162
383
|
});
|
|
384
|
+
// The session counter is called once on init
|
|
385
|
+
expect(mockCounterAddFn).toHaveBeenCalledTimes(1);
|
|
386
|
+
});
|
|
387
|
+
it('should record latency and failure for a failed routing decision', () => {
|
|
388
|
+
initializeMetricsModule(mockConfig);
|
|
389
|
+
const event = new ModelRoutingEvent('gemini-pro', 'classifier', 200, 'test-reason', true, 'test-error');
|
|
390
|
+
recordModelRoutingMetricsModule(mockConfig, event);
|
|
391
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(200, {
|
|
392
|
+
'session.id': 'test-session-id',
|
|
393
|
+
'installation.id': 'test-installation-id',
|
|
394
|
+
'user.email': 'test@example.com',
|
|
395
|
+
'routing.decision_model': 'gemini-pro',
|
|
396
|
+
'routing.decision_source': 'classifier',
|
|
397
|
+
});
|
|
398
|
+
expect(mockCounterAddFn).toHaveBeenCalledTimes(2);
|
|
163
399
|
expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 1, {
|
|
164
400
|
'session.id': 'test-session-id',
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
401
|
+
'installation.id': 'test-installation-id',
|
|
402
|
+
'user.email': 'test@example.com',
|
|
403
|
+
'routing.decision_source': 'classifier',
|
|
404
|
+
'routing.error_message': 'test-error',
|
|
169
405
|
});
|
|
170
406
|
});
|
|
171
|
-
|
|
407
|
+
});
|
|
408
|
+
describe('recordAgentRunMetrics', () => {
|
|
409
|
+
const mockConfig = {
|
|
410
|
+
getSessionId: () => 'test-session-id',
|
|
411
|
+
getTelemetryEnabled: () => true,
|
|
412
|
+
};
|
|
413
|
+
it('should not record metrics if not initialized', () => {
|
|
414
|
+
const event = new AgentFinishEvent('agent-123', 'TestAgent', 1000, 5, AgentTerminateMode.GOAL);
|
|
415
|
+
recordAgentRunMetricsModule(mockConfig, event);
|
|
416
|
+
expect(mockCounterAddFn).not.toHaveBeenCalled();
|
|
417
|
+
expect(mockHistogramRecordFn).not.toHaveBeenCalled();
|
|
418
|
+
});
|
|
419
|
+
it('should record agent run metrics', () => {
|
|
172
420
|
initializeMetricsModule(mockConfig);
|
|
173
421
|
mockCounterAddFn.mockClear();
|
|
174
|
-
|
|
422
|
+
mockHistogramRecordFn.mockClear();
|
|
423
|
+
const event = new AgentFinishEvent('agent-123', 'TestAgent', 1000, 5, AgentTerminateMode.GOAL);
|
|
424
|
+
recordAgentRunMetricsModule(mockConfig, event);
|
|
425
|
+
// Verify agent run counter
|
|
175
426
|
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
176
427
|
'session.id': 'test-session-id',
|
|
177
|
-
|
|
428
|
+
'installation.id': 'test-installation-id',
|
|
429
|
+
'user.email': 'test@example.com',
|
|
430
|
+
agent_name: 'TestAgent',
|
|
431
|
+
terminate_reason: 'GOAL',
|
|
178
432
|
});
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
initializeMetricsModule(mockConfig);
|
|
182
|
-
mockCounterAddFn.mockClear();
|
|
183
|
-
recordFileOperationMetricModule(mockConfig, FileOperation.UPDATE, undefined, 'application/javascript');
|
|
184
|
-
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
433
|
+
// Verify agent duration histogram
|
|
434
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(1000, {
|
|
185
435
|
'session.id': 'test-session-id',
|
|
186
|
-
|
|
187
|
-
|
|
436
|
+
'installation.id': 'test-installation-id',
|
|
437
|
+
'user.email': 'test@example.com',
|
|
438
|
+
agent_name: 'TestAgent',
|
|
188
439
|
});
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
initializeMetricsModule(mockConfig);
|
|
192
|
-
mockCounterAddFn.mockClear();
|
|
193
|
-
const diffStat = {
|
|
194
|
-
ai_added_lines: 5,
|
|
195
|
-
ai_removed_lines: 2,
|
|
196
|
-
user_added_lines: 3,
|
|
197
|
-
user_removed_lines: 1,
|
|
198
|
-
};
|
|
199
|
-
recordFileOperationMetricModule(mockConfig, FileOperation.UPDATE, undefined, undefined, undefined, diffStat);
|
|
200
|
-
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
440
|
+
// Verify agent turns histogram
|
|
441
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(5, {
|
|
201
442
|
'session.id': 'test-session-id',
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
user_added_lines: 3,
|
|
206
|
-
user_removed_lines: 1,
|
|
443
|
+
'installation.id': 'test-installation-id',
|
|
444
|
+
'user.email': 'test@example.com',
|
|
445
|
+
agent_name: 'TestAgent',
|
|
207
446
|
});
|
|
208
447
|
});
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
448
|
+
});
|
|
449
|
+
describe('OpenTelemetry GenAI Semantic Convention Metrics', () => {
|
|
450
|
+
const mockConfig = {
|
|
451
|
+
getSessionId: () => 'test-session-id',
|
|
452
|
+
getTelemetryEnabled: () => true,
|
|
453
|
+
};
|
|
454
|
+
describe('recordGenAiClientTokenUsage', () => {
|
|
455
|
+
it('should not record metrics when not initialized', () => {
|
|
456
|
+
recordGenAiClientTokenUsageModule(mockConfig, 100, {
|
|
457
|
+
'gen_ai.operation.name': 'generate_content',
|
|
458
|
+
'gen_ai.provider.name': 'gcp.gen_ai',
|
|
459
|
+
'gen_ai.token.type': 'input',
|
|
460
|
+
});
|
|
461
|
+
expect(mockHistogramRecordFn).not.toHaveBeenCalled();
|
|
462
|
+
});
|
|
463
|
+
it('should record input token usage with correct attributes', () => {
|
|
464
|
+
initializeMetricsModule(mockConfig);
|
|
465
|
+
mockHistogramRecordFn.mockClear();
|
|
466
|
+
recordGenAiClientTokenUsageModule(mockConfig, 150, {
|
|
467
|
+
'gen_ai.operation.name': 'generate_content',
|
|
468
|
+
'gen_ai.provider.name': 'gcp.gen_ai',
|
|
469
|
+
'gen_ai.token.type': 'input',
|
|
470
|
+
'gen_ai.request.model': 'gemini-2.0-flash',
|
|
471
|
+
'gen_ai.response.model': 'gemini-2.0-flash',
|
|
472
|
+
});
|
|
473
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(150, {
|
|
474
|
+
'session.id': 'test-session-id',
|
|
475
|
+
'installation.id': 'test-installation-id',
|
|
476
|
+
'user.email': 'test@example.com',
|
|
477
|
+
'gen_ai.operation.name': 'generate_content',
|
|
478
|
+
'gen_ai.provider.name': 'gcp.gen_ai',
|
|
479
|
+
'gen_ai.token.type': 'input',
|
|
480
|
+
'gen_ai.request.model': 'gemini-2.0-flash',
|
|
481
|
+
'gen_ai.response.model': 'gemini-2.0-flash',
|
|
482
|
+
});
|
|
483
|
+
});
|
|
484
|
+
it('should record output token usage with correct attributes', () => {
|
|
485
|
+
initializeMetricsModule(mockConfig);
|
|
486
|
+
mockHistogramRecordFn.mockClear();
|
|
487
|
+
recordGenAiClientTokenUsageModule(mockConfig, 75, {
|
|
488
|
+
'gen_ai.operation.name': 'generate_content',
|
|
489
|
+
'gen_ai.provider.name': 'gcp.vertex_ai',
|
|
490
|
+
'gen_ai.token.type': 'output',
|
|
491
|
+
'gen_ai.request.model': 'gemini-pro',
|
|
492
|
+
});
|
|
493
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(75, {
|
|
494
|
+
'session.id': 'test-session-id',
|
|
495
|
+
'installation.id': 'test-installation-id',
|
|
496
|
+
'user.email': 'test@example.com',
|
|
497
|
+
'gen_ai.operation.name': 'generate_content',
|
|
498
|
+
'gen_ai.provider.name': 'gcp.vertex_ai',
|
|
499
|
+
'gen_ai.token.type': 'output',
|
|
500
|
+
'gen_ai.request.model': 'gemini-pro',
|
|
501
|
+
});
|
|
502
|
+
});
|
|
503
|
+
it('should record token usage with optional attributes', () => {
|
|
504
|
+
initializeMetricsModule(mockConfig);
|
|
505
|
+
mockHistogramRecordFn.mockClear();
|
|
506
|
+
recordGenAiClientTokenUsageModule(mockConfig, 200, {
|
|
507
|
+
'gen_ai.operation.name': 'generate_content',
|
|
508
|
+
'gen_ai.provider.name': 'gcp.vertex_ai',
|
|
509
|
+
'gen_ai.token.type': 'input',
|
|
510
|
+
'gen_ai.request.model': 'text-embedding-004',
|
|
511
|
+
'server.address': 'aiplatform.googleapis.com',
|
|
512
|
+
'server.port': 443,
|
|
513
|
+
});
|
|
514
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(200, {
|
|
515
|
+
'session.id': 'test-session-id',
|
|
516
|
+
'installation.id': 'test-installation-id',
|
|
517
|
+
'user.email': 'test@example.com',
|
|
518
|
+
'gen_ai.operation.name': 'generate_content',
|
|
519
|
+
'gen_ai.provider.name': 'gcp.vertex_ai',
|
|
520
|
+
'gen_ai.token.type': 'input',
|
|
521
|
+
'gen_ai.request.model': 'text-embedding-004',
|
|
522
|
+
'server.address': 'aiplatform.googleapis.com',
|
|
523
|
+
'server.port': 443,
|
|
524
|
+
});
|
|
219
525
|
});
|
|
220
526
|
});
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
527
|
+
describe('recordGenAiClientOperationDuration', () => {
|
|
528
|
+
it('should not record metrics when not initialized', () => {
|
|
529
|
+
recordGenAiClientOperationDurationModule(mockConfig, 2.5, {
|
|
530
|
+
'gen_ai.operation.name': 'generate_content',
|
|
531
|
+
'gen_ai.provider.name': 'gcp.gen_ai',
|
|
532
|
+
});
|
|
533
|
+
expect(mockHistogramRecordFn).not.toHaveBeenCalled();
|
|
534
|
+
});
|
|
535
|
+
it('should record successful operation duration with correct attributes', () => {
|
|
536
|
+
initializeMetricsModule(mockConfig);
|
|
537
|
+
mockHistogramRecordFn.mockClear();
|
|
538
|
+
recordGenAiClientOperationDurationModule(mockConfig, 1.25, {
|
|
539
|
+
'gen_ai.operation.name': 'generate_content',
|
|
540
|
+
'gen_ai.provider.name': 'gcp.gen_ai',
|
|
541
|
+
'gen_ai.request.model': 'gemini-2.0-flash',
|
|
542
|
+
'gen_ai.response.model': 'gemini-2.0-flash',
|
|
543
|
+
});
|
|
544
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(1.25, {
|
|
545
|
+
'session.id': 'test-session-id',
|
|
546
|
+
'installation.id': 'test-installation-id',
|
|
547
|
+
'user.email': 'test@example.com',
|
|
548
|
+
'gen_ai.operation.name': 'generate_content',
|
|
549
|
+
'gen_ai.provider.name': 'gcp.gen_ai',
|
|
550
|
+
'gen_ai.request.model': 'gemini-2.0-flash',
|
|
551
|
+
'gen_ai.response.model': 'gemini-2.0-flash',
|
|
552
|
+
});
|
|
553
|
+
});
|
|
554
|
+
it('should record failed operation duration with error type', () => {
|
|
555
|
+
initializeMetricsModule(mockConfig);
|
|
556
|
+
mockHistogramRecordFn.mockClear();
|
|
557
|
+
recordGenAiClientOperationDurationModule(mockConfig, 3.75, {
|
|
558
|
+
'gen_ai.operation.name': 'generate_content',
|
|
559
|
+
'gen_ai.provider.name': 'gcp.vertex_ai',
|
|
560
|
+
'gen_ai.request.model': 'gemini-pro',
|
|
561
|
+
'error.type': 'quota_exceeded',
|
|
562
|
+
});
|
|
563
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(3.75, {
|
|
564
|
+
'session.id': 'test-session-id',
|
|
565
|
+
'installation.id': 'test-installation-id',
|
|
566
|
+
'user.email': 'test@example.com',
|
|
567
|
+
'gen_ai.operation.name': 'generate_content',
|
|
568
|
+
'gen_ai.provider.name': 'gcp.vertex_ai',
|
|
569
|
+
'gen_ai.request.model': 'gemini-pro',
|
|
570
|
+
'error.type': 'quota_exceeded',
|
|
571
|
+
});
|
|
572
|
+
});
|
|
573
|
+
it('should record operation duration with server details', () => {
|
|
574
|
+
initializeMetricsModule(mockConfig);
|
|
575
|
+
mockHistogramRecordFn.mockClear();
|
|
576
|
+
recordGenAiClientOperationDurationModule(mockConfig, 0.95, {
|
|
577
|
+
'gen_ai.operation.name': 'generate_content',
|
|
578
|
+
'gen_ai.provider.name': 'gcp.vertex_ai',
|
|
579
|
+
'gen_ai.request.model': 'gemini-1.5-pro',
|
|
580
|
+
'gen_ai.response.model': 'gemini-1.5-pro-001',
|
|
581
|
+
'server.address': 'us-central1-aiplatform.googleapis.com',
|
|
582
|
+
'server.port': 443,
|
|
583
|
+
});
|
|
584
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(0.95, {
|
|
585
|
+
'session.id': 'test-session-id',
|
|
586
|
+
'installation.id': 'test-installation-id',
|
|
587
|
+
'user.email': 'test@example.com',
|
|
588
|
+
'gen_ai.operation.name': 'generate_content',
|
|
589
|
+
'gen_ai.provider.name': 'gcp.vertex_ai',
|
|
590
|
+
'gen_ai.request.model': 'gemini-1.5-pro',
|
|
591
|
+
'gen_ai.response.model': 'gemini-1.5-pro-001',
|
|
592
|
+
'server.address': 'us-central1-aiplatform.googleapis.com',
|
|
593
|
+
'server.port': 443,
|
|
594
|
+
});
|
|
595
|
+
});
|
|
596
|
+
it('should handle minimal required attributes', () => {
|
|
597
|
+
initializeMetricsModule(mockConfig);
|
|
598
|
+
mockHistogramRecordFn.mockClear();
|
|
599
|
+
recordGenAiClientOperationDurationModule(mockConfig, 2.1, {
|
|
600
|
+
'gen_ai.operation.name': 'generate_content',
|
|
601
|
+
'gen_ai.provider.name': 'gcp.gen_ai',
|
|
602
|
+
});
|
|
603
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(2.1, {
|
|
604
|
+
'session.id': 'test-session-id',
|
|
605
|
+
'installation.id': 'test-installation-id',
|
|
606
|
+
'user.email': 'test@example.com',
|
|
607
|
+
'gen_ai.operation.name': 'generate_content',
|
|
608
|
+
'gen_ai.provider.name': 'gcp.gen_ai',
|
|
609
|
+
});
|
|
610
|
+
});
|
|
611
|
+
});
|
|
612
|
+
});
|
|
613
|
+
describe('Performance Monitoring Metrics', () => {
|
|
614
|
+
const mockConfig = {
|
|
615
|
+
getSessionId: () => 'test-session-id',
|
|
616
|
+
getTelemetryEnabled: () => true,
|
|
617
|
+
};
|
|
618
|
+
describe('recordStartupPerformance', () => {
|
|
619
|
+
it('should not record metrics when performance monitoring is disabled', async () => {
|
|
620
|
+
// Re-import with performance monitoring disabled by mocking the config
|
|
621
|
+
const mockConfigDisabled = {
|
|
622
|
+
getSessionId: () => 'test-session-id',
|
|
623
|
+
getTelemetryEnabled: () => false, // Disable telemetry to disable performance monitoring
|
|
624
|
+
};
|
|
625
|
+
initializeMetricsModule(mockConfigDisabled);
|
|
626
|
+
mockHistogramRecordFn.mockClear();
|
|
627
|
+
recordStartupPerformanceModule(mockConfigDisabled, 100, {
|
|
628
|
+
phase: 'settings_loading',
|
|
629
|
+
details: {
|
|
630
|
+
auth_type: 'gemini',
|
|
631
|
+
},
|
|
632
|
+
});
|
|
633
|
+
expect(mockHistogramRecordFn).not.toHaveBeenCalled();
|
|
634
|
+
});
|
|
635
|
+
it('should record startup performance with phase and details', () => {
|
|
636
|
+
initializeMetricsModule(mockConfig);
|
|
637
|
+
mockHistogramRecordFn.mockClear();
|
|
638
|
+
recordStartupPerformanceModule(mockConfig, 150, {
|
|
639
|
+
phase: 'settings_loading',
|
|
640
|
+
details: {
|
|
641
|
+
auth_type: 'gemini',
|
|
642
|
+
telemetry_enabled: true,
|
|
643
|
+
settings_sources: 2,
|
|
644
|
+
},
|
|
645
|
+
});
|
|
646
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(150, {
|
|
647
|
+
'session.id': 'test-session-id',
|
|
648
|
+
'installation.id': 'test-installation-id',
|
|
649
|
+
'user.email': 'test@example.com',
|
|
650
|
+
phase: 'settings_loading',
|
|
651
|
+
auth_type: 'gemini',
|
|
652
|
+
telemetry_enabled: true,
|
|
653
|
+
settings_sources: 2,
|
|
654
|
+
});
|
|
655
|
+
});
|
|
656
|
+
it('should record startup performance without details', () => {
|
|
657
|
+
initializeMetricsModule(mockConfig);
|
|
658
|
+
mockHistogramRecordFn.mockClear();
|
|
659
|
+
recordStartupPerformanceModule(mockConfig, 50, { phase: 'cleanup' });
|
|
660
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(50, {
|
|
661
|
+
'session.id': 'test-session-id',
|
|
662
|
+
'installation.id': 'test-installation-id',
|
|
663
|
+
'user.email': 'test@example.com',
|
|
664
|
+
phase: 'cleanup',
|
|
665
|
+
});
|
|
666
|
+
});
|
|
667
|
+
it('should handle floating-point duration values from performance.now()', () => {
|
|
668
|
+
initializeMetricsModule(mockConfig);
|
|
669
|
+
mockHistogramRecordFn.mockClear();
|
|
670
|
+
// Test with realistic floating-point values that performance.now() would return
|
|
671
|
+
const floatingPointDuration = 123.45678;
|
|
672
|
+
recordStartupPerformanceModule(mockConfig, floatingPointDuration, {
|
|
673
|
+
phase: 'total_startup',
|
|
674
|
+
details: {
|
|
675
|
+
is_tty: true,
|
|
676
|
+
has_question: false,
|
|
677
|
+
},
|
|
678
|
+
});
|
|
679
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(floatingPointDuration, {
|
|
680
|
+
'session.id': 'test-session-id',
|
|
681
|
+
'installation.id': 'test-installation-id',
|
|
682
|
+
'user.email': 'test@example.com',
|
|
683
|
+
phase: 'total_startup',
|
|
684
|
+
is_tty: true,
|
|
685
|
+
has_question: false,
|
|
686
|
+
});
|
|
687
|
+
});
|
|
688
|
+
});
|
|
689
|
+
describe('recordMemoryUsage', () => {
|
|
690
|
+
it.each([
|
|
691
|
+
{
|
|
692
|
+
memory_type: MemoryMetricType.HEAP_USED,
|
|
693
|
+
component: 'startup',
|
|
694
|
+
value: 15728640,
|
|
695
|
+
},
|
|
696
|
+
{
|
|
697
|
+
memory_type: MemoryMetricType.HEAP_TOTAL,
|
|
698
|
+
component: 'api_call',
|
|
699
|
+
value: 31457280,
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
memory_type: MemoryMetricType.EXTERNAL,
|
|
703
|
+
component: 'tool_execution',
|
|
704
|
+
value: 2097152,
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
memory_type: MemoryMetricType.RSS,
|
|
708
|
+
component: 'memory_monitor',
|
|
709
|
+
value: 41943040,
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
memory_type: MemoryMetricType.HEAP_USED,
|
|
713
|
+
component: undefined,
|
|
714
|
+
value: 15728640,
|
|
715
|
+
},
|
|
716
|
+
])('should record memory usage for $memory_type', ({ memory_type, component, value }) => {
|
|
717
|
+
initializeMetricsModule(mockConfig);
|
|
718
|
+
mockHistogramRecordFn.mockClear();
|
|
719
|
+
recordMemoryUsageModule(mockConfig, value, {
|
|
720
|
+
memory_type,
|
|
721
|
+
component,
|
|
722
|
+
});
|
|
723
|
+
const expectedAttributes = {
|
|
724
|
+
'session.id': 'test-session-id',
|
|
725
|
+
'installation.id': 'test-installation-id',
|
|
726
|
+
'user.email': 'test@example.com',
|
|
727
|
+
memory_type,
|
|
728
|
+
};
|
|
729
|
+
if (component) {
|
|
730
|
+
expectedAttributes['component'] = component;
|
|
731
|
+
}
|
|
732
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(value, expectedAttributes);
|
|
733
|
+
});
|
|
734
|
+
});
|
|
735
|
+
describe('recordCpuUsage', () => {
|
|
736
|
+
it('should record CPU usage percentage', () => {
|
|
737
|
+
initializeMetricsModule(mockConfig);
|
|
738
|
+
mockHistogramRecordFn.mockClear();
|
|
739
|
+
recordCpuUsageModule(mockConfig, 85.5, {
|
|
740
|
+
component: 'tool_execution',
|
|
741
|
+
});
|
|
742
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(85.5, {
|
|
743
|
+
'session.id': 'test-session-id',
|
|
744
|
+
'installation.id': 'test-installation-id',
|
|
745
|
+
'user.email': 'test@example.com',
|
|
746
|
+
component: 'tool_execution',
|
|
747
|
+
});
|
|
748
|
+
});
|
|
749
|
+
it('should record CPU usage without component', () => {
|
|
750
|
+
initializeMetricsModule(mockConfig);
|
|
751
|
+
mockHistogramRecordFn.mockClear();
|
|
752
|
+
recordCpuUsageModule(mockConfig, 42.3, {});
|
|
753
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(42.3, {
|
|
754
|
+
'session.id': 'test-session-id',
|
|
755
|
+
'installation.id': 'test-installation-id',
|
|
756
|
+
'user.email': 'test@example.com',
|
|
757
|
+
});
|
|
758
|
+
});
|
|
759
|
+
});
|
|
760
|
+
describe('recordToolQueueDepth', () => {
|
|
761
|
+
it('should record tool queue depth', () => {
|
|
762
|
+
initializeMetricsModule(mockConfig);
|
|
763
|
+
mockHistogramRecordFn.mockClear();
|
|
764
|
+
recordToolQueueDepthModule(mockConfig, 3);
|
|
765
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(3, {
|
|
766
|
+
'session.id': 'test-session-id',
|
|
767
|
+
'installation.id': 'test-installation-id',
|
|
768
|
+
'user.email': 'test@example.com',
|
|
769
|
+
});
|
|
770
|
+
});
|
|
771
|
+
it('should record zero queue depth', () => {
|
|
772
|
+
initializeMetricsModule(mockConfig);
|
|
773
|
+
mockHistogramRecordFn.mockClear();
|
|
774
|
+
recordToolQueueDepthModule(mockConfig, 0);
|
|
775
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(0, {
|
|
776
|
+
'session.id': 'test-session-id',
|
|
777
|
+
'installation.id': 'test-installation-id',
|
|
778
|
+
'user.email': 'test@example.com',
|
|
779
|
+
});
|
|
780
|
+
});
|
|
781
|
+
});
|
|
782
|
+
describe('recordToolExecutionBreakdown', () => {
|
|
783
|
+
it('should record tool execution breakdown for all phases', () => {
|
|
784
|
+
initializeMetricsModule(mockConfig);
|
|
785
|
+
mockHistogramRecordFn.mockClear();
|
|
786
|
+
recordToolExecutionBreakdownModule(mockConfig, 25, {
|
|
787
|
+
function_name: 'Read',
|
|
788
|
+
phase: ToolExecutionPhase.VALIDATION,
|
|
789
|
+
});
|
|
790
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(25, {
|
|
791
|
+
'session.id': 'test-session-id',
|
|
792
|
+
'installation.id': 'test-installation-id',
|
|
793
|
+
'user.email': 'test@example.com',
|
|
794
|
+
function_name: 'Read',
|
|
795
|
+
phase: 'validation',
|
|
796
|
+
});
|
|
797
|
+
});
|
|
798
|
+
it('should record execution breakdown for different phases', () => {
|
|
799
|
+
initializeMetricsModule(mockConfig);
|
|
800
|
+
mockHistogramRecordFn.mockClear();
|
|
801
|
+
recordToolExecutionBreakdownModule(mockConfig, 50, {
|
|
802
|
+
function_name: 'Bash',
|
|
803
|
+
phase: ToolExecutionPhase.PREPARATION,
|
|
804
|
+
});
|
|
805
|
+
recordToolExecutionBreakdownModule(mockConfig, 1500, {
|
|
806
|
+
function_name: 'Bash',
|
|
807
|
+
phase: ToolExecutionPhase.EXECUTION,
|
|
808
|
+
});
|
|
809
|
+
recordToolExecutionBreakdownModule(mockConfig, 75, {
|
|
810
|
+
function_name: 'Bash',
|
|
811
|
+
phase: ToolExecutionPhase.RESULT_PROCESSING,
|
|
812
|
+
});
|
|
813
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledTimes(3); // One for each call
|
|
814
|
+
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(1, 50, {
|
|
815
|
+
'session.id': 'test-session-id',
|
|
816
|
+
'installation.id': 'test-installation-id',
|
|
817
|
+
'user.email': 'test@example.com',
|
|
818
|
+
function_name: 'Bash',
|
|
819
|
+
phase: 'preparation',
|
|
820
|
+
});
|
|
821
|
+
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(2, 1500, {
|
|
822
|
+
'session.id': 'test-session-id',
|
|
823
|
+
'installation.id': 'test-installation-id',
|
|
824
|
+
'user.email': 'test@example.com',
|
|
825
|
+
function_name: 'Bash',
|
|
826
|
+
phase: 'execution',
|
|
827
|
+
});
|
|
828
|
+
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(3, 75, {
|
|
829
|
+
'session.id': 'test-session-id',
|
|
830
|
+
'installation.id': 'test-installation-id',
|
|
831
|
+
'user.email': 'test@example.com',
|
|
832
|
+
function_name: 'Bash',
|
|
833
|
+
phase: 'result_processing',
|
|
834
|
+
});
|
|
835
|
+
});
|
|
836
|
+
});
|
|
837
|
+
describe('recordTokenEfficiency', () => {
|
|
838
|
+
it('should record token efficiency metrics', () => {
|
|
839
|
+
initializeMetricsModule(mockConfig);
|
|
840
|
+
mockHistogramRecordFn.mockClear();
|
|
841
|
+
recordTokenEfficiencyModule(mockConfig, 0.85, {
|
|
842
|
+
model: 'gemini-pro',
|
|
843
|
+
metric: 'cache_hit_rate',
|
|
844
|
+
context: 'api_request',
|
|
845
|
+
});
|
|
846
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(0.85, {
|
|
847
|
+
'session.id': 'test-session-id',
|
|
848
|
+
'installation.id': 'test-installation-id',
|
|
849
|
+
'user.email': 'test@example.com',
|
|
850
|
+
model: 'gemini-pro',
|
|
851
|
+
metric: 'cache_hit_rate',
|
|
852
|
+
context: 'api_request',
|
|
853
|
+
});
|
|
854
|
+
});
|
|
855
|
+
it('should record token efficiency without context', () => {
|
|
856
|
+
initializeMetricsModule(mockConfig);
|
|
857
|
+
mockHistogramRecordFn.mockClear();
|
|
858
|
+
recordTokenEfficiencyModule(mockConfig, 125.5, {
|
|
859
|
+
model: 'gemini-pro',
|
|
860
|
+
metric: 'tokens_per_operation',
|
|
861
|
+
});
|
|
862
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(125.5, {
|
|
863
|
+
'session.id': 'test-session-id',
|
|
864
|
+
'installation.id': 'test-installation-id',
|
|
865
|
+
'user.email': 'test@example.com',
|
|
866
|
+
model: 'gemini-pro',
|
|
867
|
+
metric: 'tokens_per_operation',
|
|
868
|
+
});
|
|
869
|
+
});
|
|
870
|
+
});
|
|
871
|
+
describe('recordApiRequestBreakdown', () => {
|
|
872
|
+
it('should record API request breakdown for all phases', () => {
|
|
873
|
+
initializeMetricsModule(mockConfig);
|
|
874
|
+
mockHistogramRecordFn.mockClear();
|
|
875
|
+
recordApiRequestBreakdownModule(mockConfig, 15, {
|
|
876
|
+
model: 'gemini-pro',
|
|
877
|
+
phase: ApiRequestPhase.REQUEST_PREPARATION,
|
|
878
|
+
});
|
|
879
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(15, {
|
|
880
|
+
'session.id': 'test-session-id',
|
|
881
|
+
'installation.id': 'test-installation-id',
|
|
882
|
+
'user.email': 'test@example.com',
|
|
883
|
+
model: 'gemini-pro',
|
|
884
|
+
phase: 'request_preparation',
|
|
885
|
+
});
|
|
886
|
+
});
|
|
887
|
+
it('should record API request breakdown for different phases', () => {
|
|
888
|
+
initializeMetricsModule(mockConfig);
|
|
889
|
+
mockHistogramRecordFn.mockClear();
|
|
890
|
+
recordApiRequestBreakdownModule(mockConfig, 250, {
|
|
891
|
+
model: 'gemini-pro',
|
|
892
|
+
phase: ApiRequestPhase.NETWORK_LATENCY,
|
|
893
|
+
});
|
|
894
|
+
recordApiRequestBreakdownModule(mockConfig, 100, {
|
|
895
|
+
model: 'gemini-pro',
|
|
896
|
+
phase: ApiRequestPhase.RESPONSE_PROCESSING,
|
|
897
|
+
});
|
|
898
|
+
recordApiRequestBreakdownModule(mockConfig, 50, {
|
|
899
|
+
model: 'gemini-pro',
|
|
900
|
+
phase: ApiRequestPhase.TOKEN_PROCESSING,
|
|
901
|
+
});
|
|
902
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledTimes(3); // One for each call
|
|
903
|
+
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(1, 250, {
|
|
904
|
+
'session.id': 'test-session-id',
|
|
905
|
+
'installation.id': 'test-installation-id',
|
|
906
|
+
'user.email': 'test@example.com',
|
|
907
|
+
model: 'gemini-pro',
|
|
908
|
+
phase: 'network_latency',
|
|
909
|
+
});
|
|
910
|
+
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(2, 100, {
|
|
911
|
+
'session.id': 'test-session-id',
|
|
912
|
+
'installation.id': 'test-installation-id',
|
|
913
|
+
'user.email': 'test@example.com',
|
|
914
|
+
model: 'gemini-pro',
|
|
915
|
+
phase: 'response_processing',
|
|
916
|
+
});
|
|
917
|
+
expect(mockHistogramRecordFn).toHaveBeenNthCalledWith(3, 50, {
|
|
918
|
+
'session.id': 'test-session-id',
|
|
919
|
+
'installation.id': 'test-installation-id',
|
|
920
|
+
'user.email': 'test@example.com',
|
|
921
|
+
model: 'gemini-pro',
|
|
922
|
+
phase: 'token_processing',
|
|
923
|
+
});
|
|
924
|
+
});
|
|
925
|
+
});
|
|
926
|
+
describe('recordPerformanceScore', () => {
|
|
927
|
+
it('should record performance score with category and baseline', () => {
|
|
928
|
+
initializeMetricsModule(mockConfig);
|
|
929
|
+
mockHistogramRecordFn.mockClear();
|
|
930
|
+
recordPerformanceScoreModule(mockConfig, 85.5, {
|
|
931
|
+
category: 'memory_efficiency',
|
|
932
|
+
baseline: 80.0,
|
|
933
|
+
});
|
|
934
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(85.5, {
|
|
935
|
+
'session.id': 'test-session-id',
|
|
936
|
+
'installation.id': 'test-installation-id',
|
|
937
|
+
'user.email': 'test@example.com',
|
|
938
|
+
category: 'memory_efficiency',
|
|
939
|
+
baseline: 80.0,
|
|
940
|
+
});
|
|
941
|
+
});
|
|
942
|
+
it('should record performance score without baseline', () => {
|
|
943
|
+
initializeMetricsModule(mockConfig);
|
|
944
|
+
mockHistogramRecordFn.mockClear();
|
|
945
|
+
recordPerformanceScoreModule(mockConfig, 92.3, {
|
|
946
|
+
category: 'overall_performance',
|
|
947
|
+
});
|
|
948
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(92.3, {
|
|
949
|
+
'session.id': 'test-session-id',
|
|
950
|
+
'installation.id': 'test-installation-id',
|
|
951
|
+
'user.email': 'test@example.com',
|
|
952
|
+
category: 'overall_performance',
|
|
953
|
+
});
|
|
954
|
+
});
|
|
955
|
+
});
|
|
956
|
+
describe('recordPerformanceRegression', () => {
|
|
957
|
+
it('should record performance regression with baseline comparison', () => {
|
|
958
|
+
initializeMetricsModule(mockConfig);
|
|
959
|
+
mockCounterAddFn.mockClear();
|
|
960
|
+
mockHistogramRecordFn.mockClear();
|
|
961
|
+
recordPerformanceRegressionModule(mockConfig, {
|
|
962
|
+
metric: 'startup_time',
|
|
963
|
+
current_value: 1200,
|
|
964
|
+
baseline_value: 1000,
|
|
965
|
+
severity: 'medium',
|
|
966
|
+
});
|
|
967
|
+
// Verify regression counter
|
|
968
|
+
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
969
|
+
'session.id': 'test-session-id',
|
|
970
|
+
'installation.id': 'test-installation-id',
|
|
971
|
+
'user.email': 'test@example.com',
|
|
972
|
+
metric: 'startup_time',
|
|
973
|
+
severity: 'medium',
|
|
974
|
+
current_value: 1200,
|
|
975
|
+
baseline_value: 1000,
|
|
976
|
+
});
|
|
977
|
+
// Verify baseline comparison histogram (20% increase)
|
|
978
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(20, {
|
|
979
|
+
'session.id': 'test-session-id',
|
|
980
|
+
'installation.id': 'test-installation-id',
|
|
981
|
+
'user.email': 'test@example.com',
|
|
982
|
+
metric: 'startup_time',
|
|
983
|
+
severity: 'medium',
|
|
984
|
+
current_value: 1200,
|
|
985
|
+
baseline_value: 1000,
|
|
986
|
+
});
|
|
987
|
+
});
|
|
988
|
+
it('should handle zero baseline value gracefully', () => {
|
|
989
|
+
initializeMetricsModule(mockConfig);
|
|
990
|
+
mockCounterAddFn.mockClear();
|
|
991
|
+
mockHistogramRecordFn.mockClear();
|
|
992
|
+
recordPerformanceRegressionModule(mockConfig, {
|
|
993
|
+
metric: 'memory_usage',
|
|
994
|
+
current_value: 100,
|
|
995
|
+
baseline_value: 0,
|
|
996
|
+
severity: 'high',
|
|
997
|
+
});
|
|
998
|
+
// Verify regression counter still recorded
|
|
999
|
+
expect(mockCounterAddFn).toHaveBeenCalledWith(1, {
|
|
1000
|
+
'session.id': 'test-session-id',
|
|
1001
|
+
'installation.id': 'test-installation-id',
|
|
1002
|
+
'user.email': 'test@example.com',
|
|
1003
|
+
metric: 'memory_usage',
|
|
1004
|
+
severity: 'high',
|
|
1005
|
+
current_value: 100,
|
|
1006
|
+
baseline_value: 0,
|
|
1007
|
+
});
|
|
1008
|
+
// Verify no baseline comparison due to zero baseline
|
|
1009
|
+
expect(mockHistogramRecordFn).not.toHaveBeenCalled();
|
|
1010
|
+
});
|
|
1011
|
+
it('should record different severity levels', () => {
|
|
1012
|
+
initializeMetricsModule(mockConfig);
|
|
1013
|
+
mockCounterAddFn.mockClear();
|
|
1014
|
+
recordPerformanceRegressionModule(mockConfig, {
|
|
1015
|
+
metric: 'api_latency',
|
|
1016
|
+
current_value: 500,
|
|
1017
|
+
baseline_value: 400,
|
|
1018
|
+
severity: 'low',
|
|
1019
|
+
});
|
|
1020
|
+
recordPerformanceRegressionModule(mockConfig, {
|
|
1021
|
+
metric: 'cpu_usage',
|
|
1022
|
+
current_value: 90,
|
|
1023
|
+
baseline_value: 70,
|
|
1024
|
+
severity: 'high',
|
|
1025
|
+
});
|
|
1026
|
+
expect(mockCounterAddFn).toHaveBeenNthCalledWith(1, 1, {
|
|
1027
|
+
'session.id': 'test-session-id',
|
|
1028
|
+
'installation.id': 'test-installation-id',
|
|
1029
|
+
'user.email': 'test@example.com',
|
|
1030
|
+
metric: 'api_latency',
|
|
1031
|
+
severity: 'low',
|
|
1032
|
+
current_value: 500,
|
|
1033
|
+
baseline_value: 400,
|
|
1034
|
+
});
|
|
1035
|
+
expect(mockCounterAddFn).toHaveBeenNthCalledWith(2, 1, {
|
|
1036
|
+
'session.id': 'test-session-id',
|
|
1037
|
+
'installation.id': 'test-installation-id',
|
|
1038
|
+
'user.email': 'test@example.com',
|
|
1039
|
+
metric: 'cpu_usage',
|
|
1040
|
+
severity: 'high',
|
|
1041
|
+
current_value: 90,
|
|
1042
|
+
baseline_value: 70,
|
|
1043
|
+
});
|
|
1044
|
+
});
|
|
1045
|
+
});
|
|
1046
|
+
describe('recordBaselineComparison', () => {
|
|
1047
|
+
it('should record baseline comparison with percentage change', () => {
|
|
1048
|
+
initializeMetricsModule(mockConfig);
|
|
1049
|
+
mockHistogramRecordFn.mockClear();
|
|
1050
|
+
recordBaselineComparisonModule(mockConfig, {
|
|
1051
|
+
metric: 'memory_usage',
|
|
1052
|
+
current_value: 120,
|
|
1053
|
+
baseline_value: 100,
|
|
1054
|
+
category: 'performance_tracking',
|
|
1055
|
+
});
|
|
1056
|
+
// 20% increase: (120 - 100) / 100 * 100 = 20%
|
|
1057
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(20, {
|
|
1058
|
+
'session.id': 'test-session-id',
|
|
1059
|
+
'installation.id': 'test-installation-id',
|
|
1060
|
+
'user.email': 'test@example.com',
|
|
1061
|
+
metric: 'memory_usage',
|
|
1062
|
+
category: 'performance_tracking',
|
|
1063
|
+
current_value: 120,
|
|
1064
|
+
baseline_value: 100,
|
|
1065
|
+
});
|
|
1066
|
+
});
|
|
1067
|
+
it('should handle negative percentage change (improvement)', () => {
|
|
1068
|
+
initializeMetricsModule(mockConfig);
|
|
1069
|
+
mockHistogramRecordFn.mockClear();
|
|
1070
|
+
recordBaselineComparisonModule(mockConfig, {
|
|
1071
|
+
metric: 'startup_time',
|
|
1072
|
+
current_value: 800,
|
|
1073
|
+
baseline_value: 1000,
|
|
1074
|
+
category: 'optimization',
|
|
1075
|
+
});
|
|
1076
|
+
// 20% decrease: (800 - 1000) / 1000 * 100 = -20%
|
|
1077
|
+
expect(mockHistogramRecordFn).toHaveBeenCalledWith(-20, {
|
|
1078
|
+
'session.id': 'test-session-id',
|
|
1079
|
+
'installation.id': 'test-installation-id',
|
|
1080
|
+
'user.email': 'test@example.com',
|
|
1081
|
+
metric: 'startup_time',
|
|
1082
|
+
category: 'optimization',
|
|
1083
|
+
current_value: 800,
|
|
1084
|
+
baseline_value: 1000,
|
|
1085
|
+
});
|
|
1086
|
+
});
|
|
1087
|
+
it('should skip recording when baseline is zero', async () => {
|
|
1088
|
+
// Access the actual mocked module
|
|
1089
|
+
const mockedModule = (await vi.importMock('@opentelemetry/api'));
|
|
1090
|
+
const diagSpy = vi.spyOn(mockedModule.diag, 'warn');
|
|
1091
|
+
initializeMetricsModule(mockConfig);
|
|
1092
|
+
mockHistogramRecordFn.mockClear();
|
|
1093
|
+
recordBaselineComparisonModule(mockConfig, {
|
|
1094
|
+
metric: 'new_metric',
|
|
1095
|
+
current_value: 50,
|
|
1096
|
+
baseline_value: 0,
|
|
1097
|
+
category: 'testing',
|
|
1098
|
+
});
|
|
1099
|
+
expect(diagSpy).toHaveBeenCalledWith('Baseline value is zero, skipping comparison.');
|
|
1100
|
+
expect(mockHistogramRecordFn).not.toHaveBeenCalled();
|
|
238
1101
|
});
|
|
239
1102
|
});
|
|
240
1103
|
});
|