[Security Solution] [AI assistant] Global assistant bugs (#225149)

## Summary

Summarize your PR. If it involves visual changes, include a screenshot
or gif.

Fixes various bugs introduced by this PR
https://github.com/elastic/kibana/pull/223936

Changes:
- Fix bug where esql_content_references (citations that open the ESQL
editor) were not working due to the discover plugin not getting imported
to the elastic_assistant plugin. This caused the assistant to crash.
- Fix bug where some buttons in the AI4Soc flavour were not linking to
the correct pages.
https://github.com/elastic/kibana/pull/223936#discussion_r2164506213

### How to test:
#### Verify ESQL citations work:
- Start Kibana
- Create a semantic index and index a document through the dev console:
```
PUT my-index-000001
{
  "mappings": {
    "properties": {
      "description": {
        "type": "semantic_text"
      }
    }
  }
}


# Add a document to my-index
POST /my-index-000001/_doc
{
    "id": "Security threats",
    "title": "Stuxnet",
    "description": "What Made It Special:
Stuxnet was the first known cyber weapon designed to cause physical destruction. It targeted the Iranian nuclear program by infecting uranium enrichment facilities and sabotaging centrifuges."
}
```
- Set up a knowledge base and a knowledge base index in
http://localhost:5601/app/management/kibana/securityAiAssistantManagement?tab=knowledge_base
<img width="678" alt="image"
src="https://github.com/user-attachments/assets/a267146e-7973-4723-8c1d-365b8729a28e"
/>

- Open the security AI assistant and ask "What is the Stuxnet computer
virus?"
- Check the response to see if it contains a citation, click on the
citation, and verify the ESQL editor opens.
* If you don't get a citation, ask "What is the Stuxnet computer virus?
Provide me the citation"

#### Verify Ai4Soc buttons in the Security AI assistant link to the
correct pages:
- Start AI4Soc flavor - Create the following file
`config/serverless.security.dev.yml` with this content:
```yml
xpack.securitySolutionServerless.productTypes:
  [
    { product_line: 'ai_soc', product_tier: 'search_ai_lake' },
  ]
```
- Start serverless ES
```bash
node scripts/es serverless --projectType security --clean --kill
```
- Start serverless Kibana for security
```bash
node --no-experimental-require-module scripts/kibana --dev --serverless=security --no-base-path
```

- Open the security AI assistant
- Check that clicking on these buttons takes you to the respective pages
(KB settings
`/app/security/configurations/ai_settings?tab=knowledge_base` and AI
settings `/app/security/configurations/ai_settings` ):
<img width="690" alt="image"
src="https://github.com/user-attachments/assets/4e2728e9-8a13-4670-aef4-05b1bdb3fd57"
/>


### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [X] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [X]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [X] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [X] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [X] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [X] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [X] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

### Identify risks

Does this PR introduce any risks? For example, consider risks like hard
to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified
risk. Invite stakeholders and evaluate how to proceed before merging.

- [ ] [See some risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
- [ ] ...

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Kenneth Kreindler 2025-06-27 15:30:23 +01:00 committed by GitHub
parent 8b6b00e94d
commit 686315e62d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 25 additions and 18 deletions

View file

@ -5,6 +5,11 @@
* 2.0.
*/
export {
SECURITY_FEATURE_ID_V3 as SECURITY_FEATURE_ID,
CASES_FEATURE_ID_V3 as CASES_FEATURE_ID,
} from '@kbn/security-solution-features/constants';
export const PLUGIN_ID = 'elasticAssistant';
export const PLUGIN_NAME = 'elasticAssistant';
@ -45,5 +50,3 @@ export const CAPABILITIES = `${BASE_PATH}/capabilities`;
export const MINIMUM_AI_ASSISTANT_LICENSE = 'enterprise' as const;
export const DEFAULT_DATE_FORMAT_TZ = 'dateFormat:tz' as const;
export const SECURITY_FEATURE_ID = 'siemV2' as const;
export const CASES_FEATURE_ID = 'securitySolutionCasesV3' as const;

View file

@ -33,6 +33,7 @@
"triggersActionsUi",
"elasticAssistantSharedState",
"aiAssistantManagementSelection",
"discover"
],
"requiredBundles": [
"kibanaReact",

View file

@ -13,6 +13,7 @@ import { AssistantOverlay } from '@kbn/elastic-assistant';
import { Storage } from '@kbn/kibana-utils-plugin/public';
import { AssistantNavLink } from '@kbn/elastic-assistant/impl/assistant_context/assistant_nav_link';
import { KibanaThemeProvider } from '@kbn/react-kibana-context-theme';
import { NavigationProvider } from '@kbn/security-solution-navigation';
import {
ElasticAssistantPublicPluginSetupDependencies,
ElasticAssistantPublicPluginStartDependencies,
@ -93,16 +94,18 @@ export class ElasticAssistantPublicPlugin
}}
>
<KibanaThemeProvider {...coreStart}>
<ReactQueryClientProvider>
<AssistantSpaceIdProvider>
<AssistantProvider>
<Suspense fallback={null}>
<AssistantNavLink />
<AssistantOverlay />
</Suspense>
</AssistantProvider>
</AssistantSpaceIdProvider>
</ReactQueryClientProvider>
<NavigationProvider core={services}>
<ReactQueryClientProvider>
<AssistantSpaceIdProvider>
<AssistantProvider>
<Suspense fallback={null}>
<AssistantNavLink />
<AssistantOverlay />
</Suspense>
</AssistantProvider>
</AssistantSpaceIdProvider>
</ReactQueryClientProvider>
</NavigationProvider>
</KibanaThemeProvider>
</KibanaContextProvider>
</I18nProvider>,

View file

@ -5,9 +5,6 @@
* 2.0.
*/
export const ASSISTANT_FEATURE_ID = 'securitySolutionAssistant' as const;
export const SECURITY_FEATURE_ID = 'siemV2' as const;
export const ALERTS_PAGE_FILTER_OPEN = 'open';
export const ALERTS_PAGE_FILTER_ACKNOWLEDGED = 'acknowledged';
export const LOCAL_STORAGE_KEY = `securityAssistant`;
export const APP_ID = 'securitySolution' as const;

View file

@ -8,9 +8,10 @@
import { useAssistantAvailability } from './use_assistant_availability';
import { useLicense } from '../licence/use_licence';
import { useKibana } from '../../context/typed_kibana_context/typed_kibana_context';
import { ASSISTANT_FEATURE_ID, SECURITY_FEATURE_ID } from '../../common/constants';
import { LicenseService } from '../licence/license_service';
import { renderHook } from '@testing-library/react';
import { SECURITY_FEATURE_ID } from '../../../../common/constants';
import { ASSISTANT_FEATURE_ID } from '@kbn/security-solution-features/constants';
jest.mock('../licence/use_licence');
jest.mock('../../context/typed_kibana_context/typed_kibana_context');

View file

@ -6,7 +6,8 @@
*/
import type { UseAssistantAvailability } from '@kbn/elastic-assistant';
import { ASSISTANT_FEATURE_ID, SECURITY_FEATURE_ID } from '../../common/constants';
import { ASSISTANT_FEATURE_ID } from '@kbn/security-solution-features/constants';
import { SECURITY_FEATURE_ID } from '../../../../common/constants';
import { useKibana } from '../../context/typed_kibana_context/typed_kibana_context';
import { useLicense } from '../licence/use_licence';

View file

@ -86,7 +86,8 @@
"@kbn/deeplinks-security",
"@kbn/core-application-browser",
"@kbn/ai-security-labs-content",
"@kbn/inference-langchain"
"@kbn/inference-langchain",
"@kbn/security-solution-features"
],
"exclude": [
"target/**/*",