diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index b4ab853a19dcc..4e288a602193d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1190,6 +1190,7 @@ x-pack/platform/plugins/shared/inbox @elastic/security-genai-research-and-develo x-pack/platform/plugins/shared/index_management @elastic/kibana-management x-pack/platform/plugins/shared/inference @elastic/search-kibana x-pack/platform/plugins/shared/inference_endpoint @elastic/search-kibana +x-pack/platform/plugins/shared/inference_workflows @elastic/search-kibana x-pack/platform/plugins/shared/ingest_hub @elastic/obs-onboarding-team x-pack/platform/plugins/shared/ingest_pipelines @elastic/kibana-management x-pack/platform/plugins/shared/lens @elastic/kibana-visualizations diff --git a/docs/extend/plugin-list.md b/docs/extend/plugin-list.md index b4e75bd106bef..3ff772f892d28 100644 --- a/docs/extend/plugin-list.md +++ b/docs/extend/plugin-list.md @@ -173,6 +173,7 @@ mapped_pages: | [indicesMetadata](https://github.com/elastic/kibana/blob/main/x-pack/platform/plugins/private/indices_metadata/README.md) | Plugin for managing and retrieving metadata about indices in Kibana. This plugin collects and processes metadata from Elasticsearch indices, data streams, ILM policies, and index templates. | | [inference](https://github.com/elastic/kibana/blob/main/x-pack/platform/plugins/shared/inference/README.md) | The inference plugin is a central place to handle all interactions with the Elasticsearch Inference API and external LLM APIs. Its goals are: | | [inferenceEndpoint](https://github.com/elastic/kibana/blob/main/x-pack/platform/plugins/shared/inference_endpoint/README.md) | A Kibana plugin | +| [inferenceWorkflows](https://github.com/elastic/kibana/blob/main/x-pack/platform/plugins/shared/inference_workflows/README.md) | Registers AI workflow steps (ai.prompt, ai.summarize, ai.classify) that use the inference plugin to power LLM-based automation in Kibana Workflows. | | [infra](https://github.com/elastic/kibana/blob/main/x-pack/solutions/observability/plugins/infra/README.md) | This is the home of the infra plugin, which aims to provide a solution for the infrastructure monitoring use-case within Kibana. | | [ingestHub](https://github.com/elastic/kibana/blob/main/x-pack/platform/plugins/shared/ingest_hub/README.md) | Cross-solution onboarding page for adding data sources and integrations. Gated behind the ingestHub.enabled feature flag. | | [ingestPipelines](https://github.com/elastic/kibana/blob/main/x-pack/platform/plugins/shared/ingest_pipelines/README.md) | The ingest_pipelines plugin provides Kibana support for Elasticsearch's ingest pipelines. | diff --git a/package.json b/package.json index 44985996c5c05..d53cf1966802d 100644 --- a/package.json +++ b/package.json @@ -762,6 +762,7 @@ "@kbn/inference-prompt-utils": "link:x-pack/platform/packages/shared/kbn-inference-prompt-utils", "@kbn/inference-tracing": "link:x-pack/platform/packages/shared/kbn-inference-tracing", "@kbn/inference-tracing-config": "link:x-pack/platform/packages/shared/kbn-inference-tracing-config", + "@kbn/inference-workflows-plugin": "link:x-pack/platform/plugins/shared/inference_workflows", "@kbn/infra-forge": "link:x-pack/platform/packages/private/kbn-infra-forge", "@kbn/infra-plugin": "link:x-pack/solutions/observability/plugins/infra", "@kbn/ingest-hub-plugin": "link:x-pack/platform/plugins/shared/ingest_hub", diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index f47843b187235..0b192fcd71043 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -91,6 +91,7 @@ pageLoadAssetSize: indexLifecycleManagement: 47110 indexManagement: 39694 inference: 10368 + inferenceWorkflows: 25000 infra: 56302 ingestHub: 13422 ingestPipelines: 17866 diff --git a/packages/kbn-rspack-optimizer/limits.yml b/packages/kbn-rspack-optimizer/limits.yml index 02707cdda3d92..fcd17be47ca76 100644 --- a/packages/kbn-rspack-optimizer/limits.yml +++ b/packages/kbn-rspack-optimizer/limits.yml @@ -90,7 +90,8 @@ pageLoadAssetSize: inbox: 1294 indexLifecycleManagement: 39553 indexManagement: 316 - inference: 5564 + inference: 5751 + inferenceWorkflows: 25000 infra: 45673 ingestHub: 1923 ingestPipelines: 270 diff --git a/src/platform/plugins/shared/workflows_extensions/common/steps/index.ts b/src/platform/plugins/shared/workflows_extensions/common/steps/index.ts index 442170ddadaa3..8bc3ec9dd8c89 100644 --- a/src/platform/plugins/shared/workflows_extensions/common/steps/index.ts +++ b/src/platform/plugins/shared/workflows_extensions/common/steps/index.ts @@ -7,5 +7,4 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -export * from './ai'; export * from './data'; diff --git a/src/platform/plugins/shared/workflows_extensions/kibana.jsonc b/src/platform/plugins/shared/workflows_extensions/kibana.jsonc index 4d75a8445d9a8..a3c3ec19fe296 100644 --- a/src/platform/plugins/shared/workflows_extensions/kibana.jsonc +++ b/src/platform/plugins/shared/workflows_extensions/kibana.jsonc @@ -11,8 +11,6 @@ "browser": true, "server": true, "requiredPlugins": ["actions", "inference", "spaces"], - "optionalPlugins": ["searchInferenceEndpoints"], "extraPublicDirs": ["common"] } } - diff --git a/src/platform/plugins/shared/workflows_extensions/moon.yml b/src/platform/plugins/shared/workflows_extensions/moon.yml index 2c0751967d9b7..25f40f3b5cda2 100644 --- a/src/platform/plugins/shared/workflows_extensions/moon.yml +++ b/src/platform/plugins/shared/workflows_extensions/moon.yml @@ -25,7 +25,6 @@ dependsOn: - '@kbn/scout' - '@kbn/i18n' - '@kbn/inference-plugin' - - '@kbn/inference-common' - '@kbn/actions-plugin' - '@kbn/utility-types' - '@kbn/spaces-plugin' @@ -35,7 +34,6 @@ dependsOn: - '@kbn/logging-mocks' - '@kbn/logging' - '@kbn/core-http-common' - - '@kbn/search-inference-endpoints' tags: - plugin - prod diff --git a/src/platform/plugins/shared/workflows_extensions/public/steps/index.ts b/src/platform/plugins/shared/workflows_extensions/public/steps/index.ts index 552e4ae2e768d..4348a50b15aaa 100644 --- a/src/platform/plugins/shared/workflows_extensions/public/steps/index.ts +++ b/src/platform/plugins/shared/workflows_extensions/public/steps/index.ts @@ -29,13 +29,6 @@ export const registerInternalStepDefinitions = (stepRegistry: PublicStepRegistry stepRegistry.register(() => import('./data/data_aggregate_step').then((m) => m.dataAggregateStepDefinition) ); - stepRegistry.register(() => import('./ai/ai_prompt_step').then((m) => m.AiPromptStepDefinition)); - stepRegistry.register(() => - import('./ai/ai_summarize_step').then((m) => m.AiSummarizeStepDefinition) - ); - stepRegistry.register(() => - import('./ai/ai_classify_step').then((m) => m.AiClassifyStepDefinition) - ); stepRegistry.register(() => import('./data/data_stringify_json_step').then((m) => m.dataStringifyJsonStepDefinition) ); diff --git a/src/platform/plugins/shared/workflows_extensions/server/plugin.ts b/src/platform/plugins/shared/workflows_extensions/server/plugin.ts index 13b8c319deadc..a667ab90dc46e 100644 --- a/src/platform/plugins/shared/workflows_extensions/server/plugin.ts +++ b/src/platform/plugins/shared/workflows_extensions/server/plugin.ts @@ -25,7 +25,6 @@ import { registerGetStepDefinitionsRoute } from './routes/get_step_definitions'; import { registerGetTriggerDefinitionsRoute } from './routes/get_trigger_definitions'; import { ServerStepRegistry } from './step_registry'; import { registerInternalStepDefinitions } from './steps'; -import { registerInferenceFeatures } from './steps/ai/register_inference_features'; import { TriggerRegistry } from './trigger_registry'; import { registerInternalTriggerDefinitions } from './triggers'; import type { @@ -78,13 +77,9 @@ export class WorkflowsExtensionsServerPlugin registerGetStepDefinitionsRoute(router, this.stepRegistry); registerGetTriggerDefinitionsRoute(router, this.triggerRegistry); - registerInternalStepDefinitions(core, this.stepRegistry); + registerInternalStepDefinitions(this.stepRegistry); registerInternalTriggerDefinitions(this.triggerRegistry); - if (plugins.searchInferenceEndpoints) { - registerInferenceFeatures(plugins.searchInferenceEndpoints); - } - return { registerStepDefinition: (definition) => { this.stepRegistry.register(definition); diff --git a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_classify_step/schemas.ts b/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_classify_step/schemas.ts deleted file mode 100644 index 75a2a7bf3e076..0000000000000 --- a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_classify_step/schemas.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -import { OutputSchema } from '../../../../common/steps/ai/ai_classify_step'; - -export function convertOutputToModelResponseSchema(output: typeof OutputSchema) { - return output.omit({ metadata: true }); -} - -export const ModelResponseSchema = convertOutputToModelResponseSchema(OutputSchema); diff --git a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/index.ts b/src/platform/plugins/shared/workflows_extensions/server/steps/ai/index.ts deleted file mode 100644 index 1cde2dc8b7b9a..0000000000000 --- a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". - */ - -export * from './ai_prompt_step/step'; -export * from './ai_summarize_step/step'; -export * from './ai_classify_step/step'; diff --git a/src/platform/plugins/shared/workflows_extensions/server/steps/index.ts b/src/platform/plugins/shared/workflows_extensions/server/steps/index.ts index 640d30af894bb..172a53bdc2517 100644 --- a/src/platform/plugins/shared/workflows_extensions/server/steps/index.ts +++ b/src/platform/plugins/shared/workflows_extensions/server/steps/index.ts @@ -7,10 +7,6 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import type { CoreSetup } from '@kbn/core/server'; -import { aiClassifyStepDefinition } from './ai/ai_classify_step/step'; -import { aiPromptStepDefinition } from './ai/ai_prompt_step/step'; -import { aiSummarizeStepDefinition } from './ai/ai_summarize_step/step'; import { dataAggregateStepDefinition, dataConcatStepDefinition, @@ -24,12 +20,8 @@ import { dataStringifyJsonStepDefinition, } from './data'; import type { ServerStepRegistry } from '../step_registry/step_registry'; -import type { WorkflowsExtensionsServerPluginStartDeps } from '../types'; -export const registerInternalStepDefinitions = ( - core: CoreSetup, - serverStepRegistry: ServerStepRegistry -) => { +export const registerInternalStepDefinitions = (serverStepRegistry: ServerStepRegistry) => { serverStepRegistry.register(dataMapStepDefinition); serverStepRegistry.register(dataDedupeStepDefinition); serverStepRegistry.register(dataFilterStepDefinition); @@ -40,7 +32,4 @@ export const registerInternalStepDefinitions = ( serverStepRegistry.register(dataConcatStepDefinition); serverStepRegistry.register(dataParseJsonStepDefinition); serverStepRegistry.register(dataStringifyJsonStepDefinition); - serverStepRegistry.register(aiClassifyStepDefinition(core)); - serverStepRegistry.register(aiPromptStepDefinition(core)); - serverStepRegistry.register(aiSummarizeStepDefinition(core)); }; diff --git a/src/platform/plugins/shared/workflows_extensions/server/types.ts b/src/platform/plugins/shared/workflows_extensions/server/types.ts index bece21c2e0505..58de7598aaf4c 100644 --- a/src/platform/plugins/shared/workflows_extensions/server/types.ts +++ b/src/platform/plugins/shared/workflows_extensions/server/types.ts @@ -10,10 +10,6 @@ import type { PluginStartContract as ActionsPluginStartContract } from '@kbn/actions-plugin/server'; import type { CustomRequestHandlerContext, KibanaRequest } from '@kbn/core/server'; import type { InferenceServerStart } from '@kbn/inference-plugin/server'; -import type { - SearchInferenceEndpointsPluginSetup, - SearchInferenceEndpointsPluginStart, -} from '@kbn/search-inference-endpoints/server'; import type { SpacesPluginStart } from '@kbn/spaces-plugin/server'; import type { ManagedWorkflowsSystemApiProvider, @@ -115,9 +111,7 @@ export type WorkflowsExtensionsServerPluginStart = /** * Dependencies for the server plugin setup phase. */ -export interface WorkflowsExtensionsServerPluginSetupDeps { - searchInferenceEndpoints?: SearchInferenceEndpointsPluginSetup; -} +export type WorkflowsExtensionsServerPluginSetupDeps = Record; export type ServerStepDefinitionOrLoader< Input extends z.ZodType = z.ZodType, @@ -133,7 +127,6 @@ export type ServerStepDefinitionOrLoader< export interface WorkflowsExtensionsServerPluginStartDeps { actions: ActionsPluginStartContract; inference: InferenceServerStart; - searchInferenceEndpoints?: SearchInferenceEndpointsPluginStart; spaces?: SpacesPluginStart; } diff --git a/src/platform/plugins/shared/workflows_extensions/tsconfig.json b/src/platform/plugins/shared/workflows_extensions/tsconfig.json index 30f5fc9c81ac6..f770ee233b640 100644 --- a/src/platform/plugins/shared/workflows_extensions/tsconfig.json +++ b/src/platform/plugins/shared/workflows_extensions/tsconfig.json @@ -20,7 +20,6 @@ "@kbn/scout", "@kbn/i18n", "@kbn/inference-plugin", - "@kbn/inference-common", "@kbn/actions-plugin", "@kbn/utility-types", "@kbn/spaces-plugin", @@ -29,8 +28,7 @@ "@kbn/std", "@kbn/logging-mocks", "@kbn/logging", - "@kbn/core-http-common", - "@kbn/search-inference-endpoints" + "@kbn/core-http-common" ], "exclude": ["target/**/*"] } diff --git a/tsconfig.base.json b/tsconfig.base.json index 9ad4b7230cfd3..2c4654b964e01 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1478,6 +1478,8 @@ "@kbn/inference-tracing/*": ["x-pack/platform/packages/shared/kbn-inference-tracing/*"], "@kbn/inference-tracing-config": ["x-pack/platform/packages/shared/kbn-inference-tracing-config"], "@kbn/inference-tracing-config/*": ["x-pack/platform/packages/shared/kbn-inference-tracing-config/*"], + "@kbn/inference-workflows-plugin": ["x-pack/platform/plugins/shared/inference_workflows"], + "@kbn/inference-workflows-plugin/*": ["x-pack/platform/plugins/shared/inference_workflows/*"], "@kbn/infra-forge": ["x-pack/platform/packages/private/kbn-infra-forge"], "@kbn/infra-forge/*": ["x-pack/platform/packages/private/kbn-infra-forge/*"], "@kbn/infra-plugin": ["x-pack/solutions/observability/plugins/infra"], diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json index cf395d7ac8afb..05c751d94c283 100644 --- a/x-pack/.i18nrc.json +++ b/x-pack/.i18nrc.json @@ -46,15 +46,9 @@ "xpack.dataVisualizer": "platform/plugins/private/data_visualizer", "xpack.exploratoryView": "solutions/observability/plugins/exploratory_view", "xpack.fileUpload": "platform/plugins/private/file_upload", - "xpack.globalSearch": [ - "platform/plugins/shared/global_search" - ], - "xpack.globalSearchBar": [ - "platform/plugins/private/global_search_bar" - ], - "xpack.graph": [ - "platform/plugins/private/graph" - ], + "xpack.globalSearch": ["platform/plugins/shared/global_search"], + "xpack.globalSearchBar": ["platform/plugins/private/global_search_bar"], + "xpack.graph": ["platform/plugins/private/graph"], "xpack.grokDebugger": "platform/plugins/private/grokdebugger", "xpack.idxMgmt": "platform/plugins/shared/index_management", "xpack.idxMgmtPackage": "packages/index-management", @@ -66,6 +60,7 @@ "xpack.fleet": "platform/plugins/shared/fleet", "xpack.ingestPipelines": "platform/plugins/shared/ingest_pipelines", "xpack.inference": "platform/plugins/shared/inference", + "xpack.inferenceWorkflows": "platform/plugins/shared/inference_workflows", "xpack.inventory": "solutions/observability/plugins/inventory", "xpack.kubernetesSecurity": "solutions/security/plugins/kubernetes_security", "xpack.lens": "platform/plugins/shared/lens", @@ -73,13 +68,9 @@ "xpack.licenseMgmt": "platform/plugins/shared/license_management", "xpack.licensing": "platform/plugins/shared/licensing", "xpack.lists": "solutions/security/plugins/lists", - "xpack.logstash": [ - "platform/plugins/private/logstash" - ], + "xpack.logstash": ["platform/plugins/private/logstash"], "xpack.main": "legacy/plugins/xpack_main", - "xpack.maps": [ - "platform/plugins/shared/maps" - ], + "xpack.maps": ["platform/plugins/shared/maps"], "xpack.metricsData": "solutions/observability/plugins/metrics_data_access", "xpack.ml": [ "platform/packages/shared/ml/anomaly_utils", @@ -93,9 +84,7 @@ "platform/packages/private/ml/ui_actions", "platform/plugins/shared/ml" ], - "xpack.monitoring": [ - "platform/plugins/private/monitoring" - ], + "xpack.monitoring": ["platform/plugins/private/monitoring"], "xpack.observability": "solutions/observability/plugins/observability", "xpack.nightshift": "solutions/observability/packages/kbn-nightshift", "xpack.observabilityAgentBuilder": "solutions/observability/plugins/observability_agent_builder", @@ -107,27 +96,19 @@ "xpack.observabilityLogsExplorer": "solutions/observability/plugins/observability_logs_explorer", "xpack.observability_onboarding": "solutions/observability/plugins/observability_onboarding", "xpack.observabilityShared": "solutions/observability/plugins/observability_shared", - "xpack.observabilityLogsOverview": [ - "platform/packages/shared/logs-overview/src/components" + "xpack.observabilityLogsOverview": ["platform/packages/shared/logs-overview/src/components"], + "xpack.agentBuilder": [ + "platform/plugins/shared/agent_builder", + "platform/packages/shared/agent-builder" ], - "xpack.agentBuilder": ["platform/plugins/shared/agent_builder", "platform/packages/shared/agent-builder"], "xpack.agentBuilderPlatform": "platform/plugins/shared/agent_builder_platform", - "xpack.osquery": [ - "platform/plugins/shared/osquery" - ], + "xpack.osquery": ["platform/plugins/shared/osquery"], "xpack.painlessLab": "platform/plugins/private/painless_lab", - "xpack.profiling": [ - "solutions/observability/plugins/profiling" - ], + "xpack.profiling": ["solutions/observability/plugins/profiling"], "xpack.reindexService": "platform/plugins/private/reindex_service", "xpack.remoteClusters": "platform/plugins/private/remote_clusters", - "xpack.reporting": [ - "platform/plugins/private/reporting" - ], - "xpack.rollupJobs": [ - "platform/packages/private/rollup", - "platform/plugins/private/rollup" - ], + "xpack.reporting": ["platform/plugins/private/reporting"], + "xpack.rollupJobs": ["platform/packages/private/rollup", "platform/plugins/private/rollup"], "xpack.runtimeFields": "platform/plugins/private/runtime_fields", "xpack.screenshotting": "platform/plugins/shared/screenshotting", "xpack.searchSharedUI": "solutions/search/packages/shared-ui", @@ -152,15 +133,11 @@ "xpack.securitySolutionEss": "solutions/security/plugins/security_solution_ess", "xpack.securitySolutionServerless": "solutions/security/plugins/security_solution_serverless", "xpack.sessionView": "solutions/security/plugins/session_view", - "xpack.streams": [ - "platform/plugins/shared/streams_app" - ], + "xpack.streams": ["platform/plugins/shared/streams_app"], "xpack.slo": "solutions/observability/plugins/slo", "xpack.snapshotRestore": "platform/plugins/private/snapshot_restore", "xpack.spaces": "platform/plugins/shared/spaces", - "xpack.savedObjectsTagging": [ - "platform/plugins/shared/saved_objects_tagging" - ], + "xpack.savedObjectsTagging": ["platform/plugins/shared/saved_objects_tagging"], "xpack.taskManager": "legacy/platform/plugins/shared/task_manager", "xpack.threatIntelligence": "solutions/security/plugins/threat_intelligence", "xpack.timelines": "solutions/security/plugins/timelines", @@ -172,22 +149,14 @@ "platform/packages/private/upgrade-assistant/public", "platform/packages/private/upgrade-assistant/server" ], - "xpack.uptime": [ - "solutions/observability/plugins/uptime" - ], - "xpack.synthetics": [ - "solutions/observability/plugins/synthetics" - ], - "xpack.ux": [ - "solutions/observability/plugins/ux" - ], + "xpack.uptime": ["solutions/observability/plugins/uptime"], + "xpack.synthetics": ["solutions/observability/plugins/synthetics"], + "xpack.ux": ["solutions/observability/plugins/ux"], "xpack.urlDrilldown": "platform/plugins/private/drilldowns/url_drilldown", "xpack.watcher": "platform/plugins/private/watcher", "xpack.eventStacktrace": "platform/packages/shared/kbn-event-stacktrace" }, - "exclude": [ - "examples" - ], + "exclude": ["examples"], "translations": [ "@kbn/translations-plugin/translations/zh-CN.json", "@kbn/translations-plugin/translations/ja-JP.json", diff --git a/x-pack/platform/plugins/shared/inference_workflows/README.md b/x-pack/platform/plugins/shared/inference_workflows/README.md new file mode 100644 index 0000000000000..876f906d464bb --- /dev/null +++ b/x-pack/platform/plugins/shared/inference_workflows/README.md @@ -0,0 +1,3 @@ +# Inference Workflows + +Registers AI workflow steps (`ai.prompt`, `ai.summarize`, `ai.classify`) that use the inference plugin to power LLM-based automation in Kibana Workflows. diff --git a/src/platform/plugins/shared/workflows_extensions/common/steps/ai/ai_classify_step.test.ts b/x-pack/platform/plugins/shared/inference_workflows/common/steps/ai/ai_classify_step.test.ts similarity index 93% rename from src/platform/plugins/shared/workflows_extensions/common/steps/ai/ai_classify_step.test.ts rename to x-pack/platform/plugins/shared/inference_workflows/common/steps/ai/ai_classify_step.test.ts index 650105e9512c4..948221aa64399 100644 --- a/src/platform/plugins/shared/workflows_extensions/common/steps/ai/ai_classify_step.test.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/common/steps/ai/ai_classify_step.test.ts @@ -1,10 +1,8 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import { buildStructuredOutputSchema, ConfigSchema, InputSchema } from './ai_classify_step'; diff --git a/src/platform/plugins/shared/workflows_extensions/common/steps/ai/ai_classify_step.ts b/x-pack/platform/plugins/shared/inference_workflows/common/steps/ai/ai_classify_step.ts similarity index 83% rename from src/platform/plugins/shared/workflows_extensions/common/steps/ai/ai_classify_step.ts rename to x-pack/platform/plugins/shared/inference_workflows/common/steps/ai/ai_classify_step.ts index 002b637c462e5..d01218ec33ef7 100644 --- a/src/platform/plugins/shared/workflows_extensions/common/steps/ai/ai_classify_step.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/common/steps/ai/ai_classify_step.ts @@ -1,16 +1,14 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import { i18n } from '@kbn/i18n'; import { StepCategory } from '@kbn/workflows'; import { z } from '@kbn/zod/v4'; -import type { CommonStepDefinition } from '../../step_registry/types'; +import type { CommonStepDefinition } from '@kbn/workflows-extensions/common'; /** * Step type ID for the AI classify step. @@ -70,16 +68,17 @@ export const AiClassifyStepCommonDefinition: CommonStepDefinition< > = { id: AiClassifyStepTypeId, category: StepCategory.Ai, - label: i18n.translate('workflowsExtensionsExample.AiClassifyStep.label', { + label: i18n.translate('xpack.inferenceWorkflows.AiClassifyStep.label', { defaultMessage: 'AI Classify', }), - description: i18n.translate('workflowsExtensionsExample.AiClassifyStep.description', { + description: i18n.translate('xpack.inferenceWorkflows.AiClassifyStep.description', { defaultMessage: 'Categorizes data into predefined categories using AI', }), documentation: { - details: i18n.translate('workflowsExtensionsExample.AiClassifyStep.documentation.details', { - defaultMessage: `The ${AiClassifyStepTypeId} step categorizes input data into predefined categories using an AI connector. The classification result can be referenced in later steps using template syntax.`, - values: { templateSyntax: '`{{ steps.stepName.output }}`' }, + details: i18n.translate('xpack.inferenceWorkflows.AiClassifyStep.documentation.details', { + defaultMessage: + 'The {stepTypeId} step categorizes input data into predefined categories using an AI connector. The classification result can be referenced in later steps using template syntax.', + values: { stepTypeId: AiClassifyStepTypeId }, }), examples: [ `## Basic Classification @@ -150,7 +149,7 @@ When \`allowMultipleCategories\` is true, the output includes a \`categories\` a type: http with: url: "https://api.example.com/notify" - body: + body: severity: "{{ steps.classify_severity.output.category }}" reason: "{{ steps.classify_severity.output.rationale }}" \`\`\``, diff --git a/src/platform/plugins/shared/workflows_extensions/common/steps/ai/ai_prompt_step.ts b/x-pack/platform/plugins/shared/inference_workflows/common/steps/ai/ai_prompt_step.ts similarity index 79% rename from src/platform/plugins/shared/workflows_extensions/common/steps/ai/ai_prompt_step.ts rename to x-pack/platform/plugins/shared/inference_workflows/common/steps/ai/ai_prompt_step.ts index ce27d11bace39..1cf77a6986859 100644 --- a/src/platform/plugins/shared/workflows_extensions/common/steps/ai/ai_prompt_step.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/common/steps/ai/ai_prompt_step.ts @@ -1,17 +1,15 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import { i18n } from '@kbn/i18n'; import { StepCategory } from '@kbn/workflows'; import { JsonModelShapeSchema } from '@kbn/workflows/spec/schema/common/json_model_shape_schema'; import { z } from '@kbn/zod/v4'; -import type { CommonStepDefinition } from '../../step_registry/types'; +import type { CommonStepDefinition } from '@kbn/workflows-extensions/common'; /** * Step type ID for the AI prompt step. @@ -72,16 +70,17 @@ export const AiPromptStepCommonDefinition: CommonStepDefinition< > = { id: AiPromptStepTypeId, category: StepCategory.Ai, - label: i18n.translate('workflowsExtensionsExample.AiPromptStep.label', { + label: i18n.translate('xpack.inferenceWorkflows.AiPromptStep.label', { defaultMessage: 'AI Prompt', }), - description: i18n.translate('workflowsExtensionsExample.AiPromptStep.description', { + description: i18n.translate('xpack.inferenceWorkflows.AiPromptStep.description', { defaultMessage: 'Sends a prompt to an AI connector and returns the response', }), documentation: { - details: i18n.translate('workflowsExtensionsExample.AiPromptStep.documentation.details', { - defaultMessage: `The ${AiPromptStepTypeId} step sends a prompt to an AI connector and returns the response. The response can be referenced in later steps using template syntax like {templateSyntax}.`, - values: { templateSyntax: '`{{ steps.stepName.output }}`' }, // Needs to be extracted so it is not interpreted as a variable by the i18n plugin + details: i18n.translate('xpack.inferenceWorkflows.AiPromptStep.documentation.details', { + defaultMessage: + 'The {stepTypeId} step sends a prompt to an AI connector and returns the response. The response can be referenced in later steps using template syntax.', + values: { stepTypeId: AiPromptStepTypeId }, }), examples: [ `## Basic AI prompt @@ -101,7 +100,7 @@ The default AI connector configured for the workflow will be used.`, prompt: "Analyze this data: {{ steps.previous_step.output }}" \`\`\``, - `## AI prompt with structured output schema. + `## AI prompt with structured output schema. Output schema must be a valid JSON Schema object. See this [JSON Schema reference](https://json-schema.org/learn/getting-started-step-by-step) for details. \`\`\`yaml diff --git a/src/platform/plugins/shared/workflows_extensions/common/steps/ai/ai_summarize_step.ts b/x-pack/platform/plugins/shared/inference_workflows/common/steps/ai/ai_summarize_step.ts similarity index 75% rename from src/platform/plugins/shared/workflows_extensions/common/steps/ai/ai_summarize_step.ts rename to x-pack/platform/plugins/shared/inference_workflows/common/steps/ai/ai_summarize_step.ts index ce31362544d65..ed1f4cac3ef26 100644 --- a/src/platform/plugins/shared/workflows_extensions/common/steps/ai/ai_summarize_step.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/common/steps/ai/ai_summarize_step.ts @@ -1,16 +1,14 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import { i18n } from '@kbn/i18n'; import { StepCategory } from '@kbn/workflows'; import { z } from '@kbn/zod/v4'; -import type { CommonStepDefinition } from '../../step_registry/types'; +import type { CommonStepDefinition } from '@kbn/workflows-extensions/common'; /** * Step type ID for the AI summarize step. @@ -55,16 +53,17 @@ export const AiSummarizeStepCommonDefinition: CommonStepDefinition< > = { id: AiSummarizeStepTypeId, category: StepCategory.Ai, - label: i18n.translate('workflowsExtensionsExample.AiSummarizeStep.label', { + label: i18n.translate('xpack.inferenceWorkflows.AiSummarizeStep.label', { defaultMessage: 'AI Summarize', }), - description: i18n.translate('workflowsExtensionsExample.AiSummarizeStep.description', { + description: i18n.translate('xpack.inferenceWorkflows.AiSummarizeStep.description', { defaultMessage: 'Generates a summary of the provided content using AI', }), documentation: { - details: i18n.translate('workflowsExtensionsExample.AiSummarizeStep.documentation.details', { - defaultMessage: `The ${AiSummarizeStepTypeId} step generates a concise summary of the provided content using an AI connector. The summary can be referenced in later steps using template syntax.`, - values: { templateSyntax: '`{{ steps.stepName.output }}`' }, + details: i18n.translate('xpack.inferenceWorkflows.AiSummarizeStep.documentation.details', { + defaultMessage: + 'The {stepTypeId} step generates a concise summary of the provided content using an AI connector. The summary can be referenced in later steps using template syntax.', + values: { stepTypeId: AiSummarizeStepTypeId }, }), examples: [ `## Basic Summarization diff --git a/src/platform/plugins/shared/workflows_extensions/common/steps/ai/index.ts b/x-pack/platform/plugins/shared/inference_workflows/common/steps/ai/index.ts similarity index 69% rename from src/platform/plugins/shared/workflows_extensions/common/steps/ai/index.ts rename to x-pack/platform/plugins/shared/inference_workflows/common/steps/ai/index.ts index e96f22b9d1ac7..d5f38c2dace7f 100644 --- a/src/platform/plugins/shared/workflows_extensions/common/steps/ai/index.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/common/steps/ai/index.ts @@ -1,10 +1,8 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ export { diff --git a/x-pack/platform/plugins/shared/inference_workflows/jest.config.js b/x-pack/platform/plugins/shared/inference_workflows/jest.config.js new file mode 100644 index 0000000000000..d140968a32c75 --- /dev/null +++ b/x-pack/platform/plugins/shared/inference_workflows/jest.config.js @@ -0,0 +1,16 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../../..', + roots: [ + '/x-pack/platform/plugins/shared/inference_workflows/public', + '/x-pack/platform/plugins/shared/inference_workflows/server', + '/x-pack/platform/plugins/shared/inference_workflows/common', + ], +}; diff --git a/x-pack/platform/plugins/shared/inference_workflows/kibana.jsonc b/x-pack/platform/plugins/shared/inference_workflows/kibana.jsonc new file mode 100644 index 0000000000000..b756e7d5a2743 --- /dev/null +++ b/x-pack/platform/plugins/shared/inference_workflows/kibana.jsonc @@ -0,0 +1,16 @@ +{ + "type": "plugin", + "id": "@kbn/inference-workflows-plugin", + "owner": ["@elastic/search-kibana"], + "group": "platform", + "visibility": "shared", + "description": "Registers AI workflow steps (ai.prompt, ai.summarize, ai.classify) that bridge the inference and workflows_extensions plugins.", + "plugin": { + "id": "inferenceWorkflows", + "server": true, + "browser": true, + "configPath": ["xpack", "inferenceWorkflows"], + "requiredPlugins": ["inference", "workflowsExtensions"], + "optionalPlugins": ["searchInferenceEndpoints"] + } +} diff --git a/x-pack/platform/plugins/shared/inference_workflows/moon.yml b/x-pack/platform/plugins/shared/inference_workflows/moon.yml new file mode 100644 index 0000000000000..f6aa4cfb112a6 --- /dev/null +++ b/x-pack/platform/plugins/shared/inference_workflows/moon.yml @@ -0,0 +1,42 @@ +# This file is generated by the @kbn/moon package. Any manual edits will be erased! +# To extend this, write your extensions/overrides to 'moon.extend.yml' +# then regenerate this file with: 'node scripts/regenerate_moon_projects.js --update --filter @kbn/inference-workflows-plugin' + +$schema: https://moonrepo.dev/schemas/project.json +id: '@kbn/inference-workflows-plugin' +layer: unknown +owners: + defaultOwner: '@elastic/search-kibana' +toolchains: + default: node +language: typescript +project: + title: '@kbn/inference-workflows-plugin' + description: Moon project for @kbn/inference-workflows-plugin + channel: '' + owner: '@elastic/search-kibana' + sourceRoot: x-pack/platform/plugins/shared/inference_workflows +dependsOn: + - '@kbn/core' + - '@kbn/i18n' + - '@kbn/zod' + - '@kbn/workflows' + - '@kbn/workflows-extensions' + - '@kbn/inference-plugin' + - '@kbn/inference-common' + - '@kbn/search-inference-endpoints' +tags: + - plugin + - prod + - group-platform + - shared + - jest-unit-tests +fileGroups: + src: + - common/**/* + - public/**/* + - server/**/* + - '!target/**/*' + jest-config: + - jest.config.js +tasks: {} diff --git a/x-pack/platform/plugins/shared/inference_workflows/public/eui_icons.d.ts b/x-pack/platform/plugins/shared/inference_workflows/public/eui_icons.d.ts new file mode 100644 index 0000000000000..dbacfe2681740 --- /dev/null +++ b/x-pack/platform/plugins/shared/inference_workflows/public/eui_icons.d.ts @@ -0,0 +1,21 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +declare module '@elastic/eui/es/components/icon/assets/*' { + import type * as React from 'react'; + + interface SVGRProps { + title?: string; + titleId?: string; + } + export const icon: ({ + title, + titleId, + ...props + }: React.SVGProps & SVGRProps) => React.JSX.Element; + export {}; +} diff --git a/x-pack/platform/plugins/shared/inference_workflows/public/index.ts b/x-pack/platform/plugins/shared/inference_workflows/public/index.ts new file mode 100644 index 0000000000000..ea60ca09aed3e --- /dev/null +++ b/x-pack/platform/plugins/shared/inference_workflows/public/index.ts @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { PluginInitializerContext } from '@kbn/core/public'; +import { InferenceWorkflowsPublicPlugin } from './plugin'; + +export function plugin(initializerContext: PluginInitializerContext) { + return new InferenceWorkflowsPublicPlugin(); +} diff --git a/x-pack/platform/plugins/shared/inference_workflows/public/plugin.ts b/x-pack/platform/plugins/shared/inference_workflows/public/plugin.ts new file mode 100644 index 0000000000000..284fb0b04c850 --- /dev/null +++ b/x-pack/platform/plugins/shared/inference_workflows/public/plugin.ts @@ -0,0 +1,34 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { CoreSetup, CoreStart, Plugin } from '@kbn/core/public'; +import type { WorkflowsExtensionsPublicPluginSetup } from '@kbn/workflows-extensions/public'; + +interface InferenceWorkflowsPublicSetupDeps { + workflowsExtensions: WorkflowsExtensionsPublicPluginSetup; +} + +export class InferenceWorkflowsPublicPlugin + implements Plugin<{}, {}, InferenceWorkflowsPublicSetupDeps> +{ + setup(_core: CoreSetup, deps: InferenceWorkflowsPublicSetupDeps) { + deps.workflowsExtensions.registerStepDefinition(() => + import('./steps/ai/ai_prompt_step').then((m) => m.AiPromptStepDefinition) + ); + deps.workflowsExtensions.registerStepDefinition(() => + import('./steps/ai/ai_summarize_step').then((m) => m.AiSummarizeStepDefinition) + ); + deps.workflowsExtensions.registerStepDefinition(() => + import('./steps/ai/ai_classify_step').then((m) => m.AiClassifyStepDefinition) + ); + return {}; + } + + start(_core: CoreStart) { + return {}; + } +} diff --git a/src/platform/plugins/shared/workflows_extensions/public/steps/ai/ai_classify_step.ts b/x-pack/platform/plugins/shared/inference_workflows/public/steps/ai/ai_classify_step.ts similarity index 64% rename from src/platform/plugins/shared/workflows_extensions/public/steps/ai/ai_classify_step.ts rename to x-pack/platform/plugins/shared/inference_workflows/public/steps/ai/ai_classify_step.ts index 9b1a8bae07c20..3e6f761fcaf3b 100644 --- a/src/platform/plugins/shared/workflows_extensions/public/steps/ai/ai_classify_step.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/public/steps/ai/ai_classify_step.ts @@ -1,18 +1,16 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import React from 'react'; +import { createPublicStepDefinition } from '@kbn/workflows-extensions/public'; import { AiClassifyStepCommonDefinition, buildStructuredOutputSchema, } from '../../../common/steps/ai'; -import { createPublicStepDefinition } from '../../step_registry/types'; export const AiClassifyStepDefinition = createPublicStepDefinition({ ...AiClassifyStepCommonDefinition, diff --git a/src/platform/plugins/shared/workflows_extensions/public/steps/ai/ai_prompt_step.ts b/x-pack/platform/plugins/shared/inference_workflows/public/steps/ai/ai_prompt_step.ts similarity index 72% rename from src/platform/plugins/shared/workflows_extensions/public/steps/ai/ai_prompt_step.ts rename to x-pack/platform/plugins/shared/inference_workflows/public/steps/ai/ai_prompt_step.ts index 2afe4f0f8f2ce..6155140c85d6d 100644 --- a/src/platform/plugins/shared/workflows_extensions/public/steps/ai/ai_prompt_step.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/public/steps/ai/ai_prompt_step.ts @@ -1,20 +1,18 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import React from 'react'; import { fromJSONSchema } from '@kbn/zod/v4/from_json_schema'; +import { createPublicStepDefinition } from '@kbn/workflows-extensions/public'; import { AiPromptOutputSchema, AiPromptStepCommonDefinition, getStructuredOutputSchema, } from '../../../common/steps/ai'; -import { createPublicStepDefinition } from '../../step_registry/types'; export const AiPromptStepDefinition = createPublicStepDefinition({ ...AiPromptStepCommonDefinition, diff --git a/src/platform/plugins/shared/workflows_extensions/public/steps/ai/ai_summarize_step.ts b/x-pack/platform/plugins/shared/inference_workflows/public/steps/ai/ai_summarize_step.ts similarity index 60% rename from src/platform/plugins/shared/workflows_extensions/public/steps/ai/ai_summarize_step.ts rename to x-pack/platform/plugins/shared/inference_workflows/public/steps/ai/ai_summarize_step.ts index 15e386be2dbe5..0ceb46977b297 100644 --- a/src/platform/plugins/shared/workflows_extensions/public/steps/ai/ai_summarize_step.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/public/steps/ai/ai_summarize_step.ts @@ -1,15 +1,13 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import React from 'react'; +import { createPublicStepDefinition } from '@kbn/workflows-extensions/public'; import { AiSummarizeStepCommonDefinition } from '../../../common/steps/ai'; -import { createPublicStepDefinition } from '../../step_registry/types'; export const AiSummarizeStepDefinition = createPublicStepDefinition({ ...AiSummarizeStepCommonDefinition, diff --git a/x-pack/platform/plugins/shared/inference_workflows/server/index.ts b/x-pack/platform/plugins/shared/inference_workflows/server/index.ts new file mode 100644 index 0000000000000..0d6235e175f0f --- /dev/null +++ b/x-pack/platform/plugins/shared/inference_workflows/server/index.ts @@ -0,0 +1,13 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { PluginInitializerContext } from '@kbn/core/server'; + +export async function plugin(initializerContext: PluginInitializerContext) { + const { InferenceWorkflowsPlugin } = await import('./plugin'); + return new InferenceWorkflowsPlugin(); +} diff --git a/x-pack/platform/plugins/shared/inference_workflows/server/plugin.ts b/x-pack/platform/plugins/shared/inference_workflows/server/plugin.ts new file mode 100644 index 0000000000000..2dc8da536dac4 --- /dev/null +++ b/x-pack/platform/plugins/shared/inference_workflows/server/plugin.ts @@ -0,0 +1,33 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { CoreSetup, CoreStart, Plugin } from '@kbn/core/server'; +import type { InferenceWorkflowsSetupDeps, InferenceWorkflowsStartDeps } from './types'; +import { aiPromptStepDefinition } from './steps/ai/ai_prompt_step/step'; +import { aiSummarizeStepDefinition } from './steps/ai/ai_summarize_step/step'; +import { aiClassifyStepDefinition } from './steps/ai/ai_classify_step/step'; +import { registerInferenceFeatures } from './steps/ai/register_inference_features'; + +export class InferenceWorkflowsPlugin + implements Plugin<{}, {}, InferenceWorkflowsSetupDeps, InferenceWorkflowsStartDeps> +{ + setup(core: CoreSetup, deps: InferenceWorkflowsSetupDeps) { + deps.workflowsExtensions.registerStepDefinition(aiPromptStepDefinition(core)); + deps.workflowsExtensions.registerStepDefinition(aiSummarizeStepDefinition(core)); + deps.workflowsExtensions.registerStepDefinition(aiClassifyStepDefinition(core)); + + if (deps.searchInferenceEndpoints) { + registerInferenceFeatures(deps.searchInferenceEndpoints); + } + + return {}; + } + + start(_core: CoreStart) { + return {}; + } +} diff --git a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_classify_step/build_prompts.test.ts b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_classify_step/build_prompts.test.ts similarity index 94% rename from src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_classify_step/build_prompts.test.ts rename to x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_classify_step/build_prompts.test.ts index 08795c0edc39e..bbb4aa6debd53 100644 --- a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_classify_step/build_prompts.test.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_classify_step/build_prompts.test.ts @@ -1,10 +1,8 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import { diff --git a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_classify_step/build_prompts.ts b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_classify_step/build_prompts.ts similarity index 90% rename from src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_classify_step/build_prompts.ts rename to x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_classify_step/build_prompts.ts index 39f3fbc82920f..fab7a22a69f01 100644 --- a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_classify_step/build_prompts.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_classify_step/build_prompts.ts @@ -1,10 +1,8 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import type { MessageFieldWithRole } from '@langchain/core/messages'; diff --git a/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_classify_step/schemas.ts b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_classify_step/schemas.ts new file mode 100644 index 0000000000000..6f11d6ad4aa8a --- /dev/null +++ b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_classify_step/schemas.ts @@ -0,0 +1,14 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { OutputSchema } from '../../../../common/steps/ai/ai_classify_step'; + +export function convertOutputToModelResponseSchema(output: typeof OutputSchema) { + return output.omit({ metadata: true }); +} + +export const ModelResponseSchema = convertOutputToModelResponseSchema(OutputSchema); diff --git a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_classify_step/step.test.ts b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_classify_step/step.test.ts similarity index 94% rename from src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_classify_step/step.test.ts rename to x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_classify_step/step.test.ts index 6c052fcfa2d72..6886ed0402cda 100644 --- a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_classify_step/step.test.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_classify_step/step.test.ts @@ -1,16 +1,13 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import type { CoreSetup, KibanaRequest } from '@kbn/core/server'; import type { InferenceServerStart } from '@kbn/inference-plugin/server'; -// Mock all external dependencies jest.mock('./build_prompts', () => ({ buildSystemPart: jest.fn(), buildDataPart: jest.fn(), @@ -36,7 +33,7 @@ jest.mock('../../../../common/steps/ai', () => ({ buildStructuredOutputSchema: jest.fn(), })); -jest.mock('../../../step_registry/types', () => ({ +jest.mock('@kbn/workflows-extensions/server', () => ({ createServerStepDefinition: jest.fn((definition) => definition), })); @@ -54,9 +51,11 @@ import { convertOutputToModelResponseSchema } from './schemas'; import { aiClassifyStepDefinition } from './step'; import { validateModelResponse } from './validate_model_response'; import { buildStructuredOutputSchema } from '../../../../common/steps/ai'; -import type { ContextManager, StepHandlerContext } from '../../../step_registry/types'; -import { createServerStepDefinition } from '../../../step_registry/types'; -import type { WorkflowsExtensionsServerPluginStartDeps } from '../../../types'; +import type { StepHandlerContext } from '@kbn/workflows-extensions/server'; + +type ContextManager = StepHandlerContext['contextManager']; +import { createServerStepDefinition } from '@kbn/workflows-extensions/server'; +import type { InferenceWorkflowsStartDeps } from '../../../types'; import { resolveConnectorId } from '../utils/resolve_connector_id'; const mockBuildSystemPart = buildSystemPart as jest.MockedFunction; @@ -83,7 +82,7 @@ const mockCreateServerStepDefinition = createServerStepDefinition as jest.Mocked const mockResolveConnectorId = resolveConnectorId as jest.MockedFunction; describe('aiClassifyStepDefinition', () => { - let mockCoreSetup: jest.Mocked>; + let mockCoreSetup: jest.Mocked>; let mockInference: jest.Mocked; let mockContextManager: jest.Mocked; let mockContext: StepHandlerContext; @@ -97,13 +96,11 @@ describe('aiClassifyStepDefinition', () => { mockAbortController = new AbortController(); - // Mock schema mockSchema = { parse: jest.fn(), safeParse: jest.fn(), }; - // Mock chat model runnable mockRunnable = { invoke: jest.fn().mockResolvedValue({ parsed: { @@ -119,27 +116,19 @@ describe('aiClassifyStepDefinition', () => { }), }; - // Mock chat model mockChatModel = { invoke: jest.fn(), withStructuredOutput: jest.fn().mockReturnValue(mockRunnable), }; - // Mock inference service mockInference = { getChatModel: jest.fn().mockResolvedValue(mockChatModel), } as any; - // Mock core setup mockCoreSetup = { - getStartServices: jest.fn().mockResolvedValue([ - {}, // core - { inference: mockInference }, // plugins - {}, // own plugin - ]), + getStartServices: jest.fn().mockResolvedValue([{}, { inference: mockInference }, {}]), } as any; - // Mock context manager mockContextManager = { getFakeRequest: jest.fn().mockReturnValue({} as KibanaRequest), getContext: jest.fn(), @@ -147,7 +136,6 @@ describe('aiClassifyStepDefinition', () => { renderInputTemplate: jest.fn(), }; - // Mock step handler context mockContext = { config: { 'connector-id': 'test-connector-id', @@ -182,7 +170,6 @@ describe('aiClassifyStepDefinition', () => { stepType: 'ai.classify', } as any; - // Setup default mock implementations mockResolveConnectorId.mockResolvedValue('resolved-connector-id'); mockBuildStructuredOutputSchema.mockReturnValue(mockSchema as any); mockBuildSystemPart.mockReturnValue([{ role: 'system', content: 'System prompt' }]); diff --git a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_classify_step/step.ts b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_classify_step/step.ts similarity index 81% rename from src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_classify_step/step.ts rename to x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_classify_step/step.ts index 9dbc3805a6f8d..c674850f779b3 100644 --- a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_classify_step/step.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_classify_step/step.ts @@ -1,14 +1,13 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import type { MessageFieldWithRole } from '@langchain/core/messages'; import type { CoreSetup } from '@kbn/core/server'; +import { createServerStepDefinition } from '@kbn/workflows-extensions/server'; import { buildClassificationRequestPart, buildDataPart, @@ -21,14 +20,11 @@ import { AiClassifyStepCommonDefinition, buildStructuredOutputSchema, } from '../../../../common/steps/ai'; -import { createServerStepDefinition } from '../../../step_registry/types'; -import type { WorkflowsExtensionsServerPluginStartDeps } from '../../../types'; +import type { InferenceWorkflowsStartDeps } from '../../../types'; import { AI_CLASSIFY_FEATURE_ID } from '../ai_feature_ids'; import { resolveConnectorId } from '../utils/resolve_connector_id'; -export const aiClassifyStepDefinition = ( - coreSetup: CoreSetup -) => +export const aiClassifyStepDefinition = (coreSetup: CoreSetup) => createServerStepDefinition({ ...AiClassifyStepCommonDefinition, handler: async (context) => { diff --git a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_classify_step/validate_model_response.test.ts b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_classify_step/validate_model_response.test.ts similarity index 96% rename from src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_classify_step/validate_model_response.test.ts rename to x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_classify_step/validate_model_response.test.ts index ff89bef7dc9c1..a1075c6872457 100644 --- a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_classify_step/validate_model_response.test.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_classify_step/validate_model_response.test.ts @@ -1,10 +1,8 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import { ExecutionError } from '@kbn/workflows/server'; diff --git a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_classify_step/validate_model_response.ts b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_classify_step/validate_model_response.ts similarity index 80% rename from src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_classify_step/validate_model_response.ts rename to x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_classify_step/validate_model_response.ts index 74c3ed69836d0..9dd916f51ca43 100644 --- a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_classify_step/validate_model_response.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_classify_step/validate_model_response.ts @@ -1,10 +1,8 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import { ExecutionError } from '@kbn/workflows/server'; diff --git a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_feature_ids.ts b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_feature_ids.ts similarity index 61% rename from src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_feature_ids.ts rename to x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_feature_ids.ts index 25836484bc558..c897139a69014 100644 --- a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_feature_ids.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_feature_ids.ts @@ -1,10 +1,8 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ export const WORKFLOWS_AI_PARENT_FEATURE_ID = 'workflows_ai'; diff --git a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_prompt_step/ai_prompt_step.test.ts b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_prompt_step/ai_prompt_step.test.ts similarity index 91% rename from src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_prompt_step/ai_prompt_step.test.ts rename to x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_prompt_step/ai_prompt_step.test.ts index 8d52e9065c4c3..597f7e74a8428 100644 --- a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_prompt_step/ai_prompt_step.test.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_prompt_step/ai_prompt_step.test.ts @@ -1,16 +1,13 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import type { CoreSetup, KibanaRequest } from '@kbn/core/server'; import type { InferenceServerStart } from '@kbn/inference-plugin/server'; -// Mock external dependencies jest.mock('../utils/resolve_connector_id', () => ({ resolveConnectorId: jest.fn(), })); @@ -23,14 +20,16 @@ jest.mock('../../../../common/steps/ai', () => ({ }, })); -jest.mock('../../../step_registry/types', () => ({ +jest.mock('@kbn/workflows-extensions/server', () => ({ createServerStepDefinition: jest.fn((definition) => definition), })); import { aiPromptStepDefinition } from './step'; -import type { ContextManager, StepHandlerContext } from '../../../step_registry/types'; -import { createServerStepDefinition } from '../../../step_registry/types'; -import type { WorkflowsExtensionsServerPluginStartDeps } from '../../../types'; +import type { StepHandlerContext } from '@kbn/workflows-extensions/server'; + +type ContextManager = StepHandlerContext['contextManager']; +import { createServerStepDefinition } from '@kbn/workflows-extensions/server'; +import type { InferenceWorkflowsStartDeps } from '../../../types'; import { resolveConnectorId } from '../utils/resolve_connector_id'; const mockResolveConnectorId = resolveConnectorId as jest.MockedFunction; @@ -39,7 +38,7 @@ const mockCreateServerStepDefinition = createServerStepDefinition as jest.Mocked >; describe('aiPromptStepDefinition', () => { - let mockCoreSetup: jest.Mocked>; + let mockCoreSetup: jest.Mocked>; let mockInference: jest.Mocked; let mockContextManager: jest.Mocked; let mockContext: StepHandlerContext; @@ -52,7 +51,6 @@ describe('aiPromptStepDefinition', () => { mockAbortController = new AbortController(); - // Mock chat model mockRunnable = { invoke: jest.fn(), }; @@ -62,12 +60,10 @@ describe('aiPromptStepDefinition', () => { withStructuredOutput: jest.fn().mockReturnValue(mockRunnable), }; - // Mock inference service mockInference = { getChatModel: jest.fn().mockResolvedValue(mockChatModel), } as any; - // Mock context manager mockContextManager = { getFakeRequest: jest.fn().mockReturnValue({} as KibanaRequest), getContext: jest.fn(), @@ -75,7 +71,6 @@ describe('aiPromptStepDefinition', () => { renderInputTemplate: jest.fn(), }; - // Mock step handler context mockContext = { config: { 'connector-id': 'test-connector-id', @@ -100,7 +95,6 @@ describe('aiPromptStepDefinition', () => { stepType: 'ai.prompt', }; - // Mock CoreSetup mockCoreSetup = { getStartServices: jest.fn().mockResolvedValue([{}, { inference: mockInference }]), } as any; @@ -304,7 +298,6 @@ describe('aiPromptStepDefinition', () => { }, }); - // Ensure regular invoke is not called when using structured output expect(mockChatModel.invoke).not.toHaveBeenCalled(); }); @@ -419,21 +412,14 @@ describe('aiPromptStepDefinition', () => { await handler(mockContext); - // Verify CoreSetup.getStartServices is called expect(mockCoreSetup.getStartServices).toHaveBeenCalledTimes(1); - - // Verify contextManager.getFakeRequest is called twice (for resolveConnectorId and getChatModel) expect(mockContextManager.getFakeRequest).toHaveBeenCalledTimes(2); - - // Verify resolveConnectorId is called with correct parameters expect(mockResolveConnectorId).toHaveBeenCalledWith( 'test-connector-id', mockInference, expect.any(Object), { featureId: 'ai_prompt', searchInferenceEndpoints: undefined } ); - - // Verify getChatModel is called with correct parameters expect(mockInference.getChatModel).toHaveBeenCalledWith({ connectorId: 'resolved-connector-id', request: expect.any(Object), @@ -442,8 +428,6 @@ describe('aiPromptStepDefinition', () => { maxRetries: 0, }, }); - - // Verify chat model invoke is called with correct parameters expect(mockChatModel.invoke).toHaveBeenCalledWith( [{ role: 'user', content: 'Test prompt' }], { signal: mockAbortController.signal } @@ -463,7 +447,6 @@ describe('aiPromptStepDefinition', () => { await handler(mockContext); - // Verify the same fake request is used in both calls expect(mockResolveConnectorId).toHaveBeenCalledWith( 'test-connector-id', mockInference, diff --git a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_prompt_step/step.ts b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_prompt_step/step.ts similarity index 81% rename from src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_prompt_step/step.ts rename to x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_prompt_step/step.ts index 88df34b146cef..d21381618f0f2 100644 --- a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_prompt_step/step.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_prompt_step/step.ts @@ -1,22 +1,18 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import type { CoreSetup } from '@kbn/core/server'; +import { createServerStepDefinition } from '@kbn/workflows-extensions/server'; import { AiPromptStepCommonDefinition } from '../../../../common/steps/ai'; -import { createServerStepDefinition } from '../../../step_registry/types'; -import type { WorkflowsExtensionsServerPluginStartDeps } from '../../../types'; +import type { InferenceWorkflowsStartDeps } from '../../../types'; import { AI_PROMPT_FEATURE_ID } from '../ai_feature_ids'; import { resolveConnectorId } from '../utils/resolve_connector_id'; -export const aiPromptStepDefinition = ( - coreSetup: CoreSetup -) => +export const aiPromptStepDefinition = (coreSetup: CoreSetup) => createServerStepDefinition({ ...AiPromptStepCommonDefinition, handler: async (context) => { diff --git a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_summarize_step/ai_summarize_step.test.ts b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_summarize_step/ai_summarize_step.test.ts similarity index 92% rename from src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_summarize_step/ai_summarize_step.test.ts rename to x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_summarize_step/ai_summarize_step.test.ts index 52871bbd71863..cb30e23219a48 100644 --- a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_summarize_step/ai_summarize_step.test.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_summarize_step/ai_summarize_step.test.ts @@ -1,16 +1,13 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import type { CoreSetup, KibanaRequest } from '@kbn/core/server'; import type { InferenceServerStart } from '@kbn/inference-plugin/server'; -// Mock external dependencies jest.mock('../utils/resolve_connector_id', () => ({ resolveConnectorId: jest.fn(), })); @@ -31,7 +28,7 @@ jest.mock('../../../../common/steps/ai', () => ({ }, })); -jest.mock('../../../step_registry/types', () => ({ +jest.mock('@kbn/workflows-extensions/server', () => ({ createServerStepDefinition: jest.fn((definition) => definition), })); @@ -42,9 +39,11 @@ import { buildSystemPart, } from './build_prompts'; import { aiSummarizeStepDefinition } from './step'; -import { createServerStepDefinition } from '../../../step_registry/types'; -import type { ContextManager, StepHandlerContext } from '../../../step_registry/types'; -import type { WorkflowsExtensionsServerPluginStartDeps } from '../../../types'; +import { createServerStepDefinition } from '@kbn/workflows-extensions/server'; +import type { StepHandlerContext } from '@kbn/workflows-extensions/server'; + +type ContextManager = StepHandlerContext['contextManager']; +import type { InferenceWorkflowsStartDeps } from '../../../types'; import { resolveConnectorId } from '../utils/resolve_connector_id'; const mockResolveConnectorId = resolveConnectorId as jest.MockedFunction; @@ -61,7 +60,7 @@ const mockCreateServerStepDefinition = createServerStepDefinition as jest.Mocked >; describe('aiSummarizeStepDefinition', () => { - let mockCoreSetup: jest.Mocked>; + let mockCoreSetup: jest.Mocked>; let mockInference: jest.Mocked; let mockContextManager: jest.Mocked; let mockContext: StepHandlerContext; @@ -73,17 +72,14 @@ describe('aiSummarizeStepDefinition', () => { mockAbortController = new AbortController(); - // Mock chat model mockChatModel = { invoke: jest.fn(), }; - // Mock inference service mockInference = { getChatModel: jest.fn().mockResolvedValue(mockChatModel), } as any; - // Mock context manager mockContextManager = { getFakeRequest: jest.fn().mockReturnValue({} as KibanaRequest), getContext: jest.fn(), @@ -91,7 +87,6 @@ describe('aiSummarizeStepDefinition', () => { renderInputTemplate: jest.fn(), }; - // Mock step handler context mockContext = { config: { 'connector-id': 'test-connector-id', @@ -116,12 +111,10 @@ describe('aiSummarizeStepDefinition', () => { stepType: 'ai.summarize', }; - // Mock CoreSetup mockCoreSetup = { getStartServices: jest.fn().mockResolvedValue([{}, { inference: mockInference }]), } as any; - // Mock build functions to return sample message parts mockBuildSystemPart.mockReturnValue([{ role: 'system', content: 'System prompt' }]); mockBuildDataPart.mockReturnValue([{ role: 'user', content: 'Data to summarize' }]); mockBuildRequirementsPart.mockReturnValue([ @@ -171,7 +164,6 @@ describe('aiSummarizeStepDefinition', () => { }, }); - // Verify build functions were called with correct parameters expect(mockBuildSystemPart).toHaveBeenCalledTimes(1); expect(mockBuildDataPart).toHaveBeenCalledWith('Text to summarize'); expect(mockBuildRequirementsPart).toHaveBeenCalledWith({ maxLength: undefined }); @@ -444,7 +436,6 @@ describe('aiSummarizeStepDefinition', () => { await handler(mockContext); - // Verify build functions were called in order const callOrder = [ mockBuildSystemPart.mock.invocationCallOrder[0], mockBuildDataPart.mock.invocationCallOrder[0], diff --git a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_summarize_step/build_prompts.test.ts b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_summarize_step/build_prompts.test.ts similarity index 95% rename from src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_summarize_step/build_prompts.test.ts rename to x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_summarize_step/build_prompts.test.ts index 435ba175da4bf..7c90410af1e1b 100644 --- a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_summarize_step/build_prompts.test.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_summarize_step/build_prompts.test.ts @@ -1,10 +1,8 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import { @@ -324,8 +322,6 @@ describe('buildInstructionsPart', () => { const instructions = ' '; const result = buildInstructionsPart(instructions); - // Should still return the instructions even if just whitespace - // (behavior depends on implementation - adjust if needed) expect(result).toEqual([]); }); }); diff --git a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_summarize_step/build_prompts.ts b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_summarize_step/build_prompts.ts similarity index 84% rename from src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_summarize_step/build_prompts.ts rename to x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_summarize_step/build_prompts.ts index eb9b5e68c74d2..31d15b1f59f53 100644 --- a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_summarize_step/build_prompts.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_summarize_step/build_prompts.ts @@ -1,10 +1,8 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import type { MessageFieldWithRole } from '@langchain/core/messages'; diff --git a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_summarize_step/step.ts b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_summarize_step/step.ts similarity index 75% rename from src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_summarize_step/step.ts rename to x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_summarize_step/step.ts index bb06d795bab24..4677dcfbf7913 100644 --- a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/ai_summarize_step/step.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/ai_summarize_step/step.ts @@ -1,14 +1,13 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import type { MessageFieldWithRole } from '@langchain/core/messages'; import type { CoreSetup } from '@kbn/core/server'; +import { createServerStepDefinition } from '@kbn/workflows-extensions/server'; import { buildDataPart, buildInstructionsPart, @@ -16,14 +15,11 @@ import { buildSystemPart, } from './build_prompts'; import { AiSummarizeStepCommonDefinition } from '../../../../common/steps/ai'; -import { createServerStepDefinition } from '../../../step_registry/types'; -import type { WorkflowsExtensionsServerPluginStartDeps } from '../../../types'; +import type { InferenceWorkflowsStartDeps } from '../../../types'; import { AI_SUMMARIZE_FEATURE_ID } from '../ai_feature_ids'; import { resolveConnectorId } from '../utils/resolve_connector_id'; -export const aiSummarizeStepDefinition = ( - coreSetup: CoreSetup -) => +export const aiSummarizeStepDefinition = (coreSetup: CoreSetup) => createServerStepDefinition({ ...AiSummarizeStepCommonDefinition, handler: async (context) => { diff --git a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/register_inference_features.ts b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/register_inference_features.ts similarity index 83% rename from src/platform/plugins/shared/workflows_extensions/server/steps/ai/register_inference_features.ts rename to x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/register_inference_features.ts index decf3831c89c0..243d0e53cab4b 100644 --- a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/register_inference_features.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/register_inference_features.ts @@ -1,10 +1,8 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import type { SearchInferenceEndpointsPluginSetup } from '@kbn/search-inference-endpoints/server'; diff --git a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/utils/resolve_connector_id.test.ts b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/utils/resolve_connector_id.test.ts similarity index 92% rename from src/platform/plugins/shared/workflows_extensions/server/steps/ai/utils/resolve_connector_id.test.ts rename to x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/utils/resolve_connector_id.test.ts index 95cd294e06624..658b4fa223a46 100644 --- a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/utils/resolve_connector_id.test.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/utils/resolve_connector_id.test.ts @@ -1,10 +1,8 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import type { KibanaRequest } from '@kbn/core/server'; @@ -20,7 +18,6 @@ describe('resolveConnectorId', () => { let mockKibanaRequest: jest.Mocked; let mockSearchInferenceEndpoints: jest.Mocked; - // Helper function to create mock connectors const createMockConnector = (partial: Partial): InferenceConnector => ({ type: InferenceConnectorType.OpenAI, name: 'Mock Connector', @@ -35,11 +32,8 @@ describe('resolveConnectorId', () => { beforeEach(() => { jest.clearAllMocks(); - // Mock KibanaRequest mockKibanaRequest = {} as jest.Mocked; - // Mock InferenceServerStart - need to use 'any' to allow null/undefined returns - // that don't match the strict type signature but are handled by the implementation mockInferencePlugin = { getDefaultConnector: jest.fn(), getConnectorList: jest.fn(), @@ -69,7 +63,6 @@ describe('resolveConnectorId', () => { }); it('should throw an error when no default connector is configured', async () => { - // Using type assertion since the implementation handles null but types don't allow it mockInferencePlugin.getDefaultConnector.mockResolvedValue(null as any); await expect( @@ -80,7 +73,6 @@ describe('resolveConnectorId', () => { }); it('should throw an error when default connector is undefined', async () => { - // Using type assertion since the implementation handles undefined but types don't allow it mockInferencePlugin.getDefaultConnector.mockResolvedValue(undefined as any); await expect( @@ -246,7 +238,7 @@ describe('resolveConnectorId', () => { }); it('should perform case-sensitive name matching', async () => { - const connectorName = 'openai gpt-4'; // Different case + const connectorName = 'openai gpt-4'; await expect( resolveConnectorId(connectorName, mockInferencePlugin, mockKibanaRequest) diff --git a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/utils/resolve_connector_id.ts b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/utils/resolve_connector_id.ts similarity index 82% rename from src/platform/plugins/shared/workflows_extensions/server/steps/ai/utils/resolve_connector_id.ts rename to x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/utils/resolve_connector_id.ts index fe236dcd927e0..2ed8886f51a7a 100644 --- a/src/platform/plugins/shared/workflows_extensions/server/steps/ai/utils/resolve_connector_id.ts +++ b/x-pack/platform/plugins/shared/inference_workflows/server/steps/ai/utils/resolve_connector_id.ts @@ -1,10 +1,8 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the "Elastic License - * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side - * Public License v 1"; you may not use this file except in compliance with, at - * your election, the "Elastic License 2.0", the "GNU Affero General Public - * License v3.0 only", or the "Server Side Public License, v 1". + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. */ import type { KibanaRequest } from '@kbn/core/server'; diff --git a/x-pack/platform/plugins/shared/inference_workflows/server/types.ts b/x-pack/platform/plugins/shared/inference_workflows/server/types.ts new file mode 100644 index 0000000000000..d0f07f925daea --- /dev/null +++ b/x-pack/platform/plugins/shared/inference_workflows/server/types.ts @@ -0,0 +1,23 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import type { InferenceServerStart } from '@kbn/inference-plugin/server'; +import type { WorkflowsExtensionsServerPluginSetup } from '@kbn/workflows-extensions/server'; +import type { + SearchInferenceEndpointsPluginSetup, + SearchInferenceEndpointsPluginStart, +} from '@kbn/search-inference-endpoints/server'; + +export interface InferenceWorkflowsSetupDeps { + workflowsExtensions: WorkflowsExtensionsServerPluginSetup; + searchInferenceEndpoints?: SearchInferenceEndpointsPluginSetup; +} + +export interface InferenceWorkflowsStartDeps { + inference: InferenceServerStart; + searchInferenceEndpoints?: SearchInferenceEndpointsPluginStart; +} diff --git a/x-pack/platform/plugins/shared/inference_workflows/tsconfig.json b/x-pack/platform/plugins/shared/inference_workflows/tsconfig.json new file mode 100644 index 0000000000000..036b4a1dd242d --- /dev/null +++ b/x-pack/platform/plugins/shared/inference_workflows/tsconfig.json @@ -0,0 +1,18 @@ +{ + "extends": "@kbn/tsconfig-base/tsconfig.json", + "compilerOptions": { + "outDir": "target/types" + }, + "include": ["../../../../../typings/**/*", "common/**/*", "public/**/*", "server/**/*"], + "exclude": ["target/**/*"], + "kbn_references": [ + "@kbn/core", + "@kbn/i18n", + "@kbn/zod", + "@kbn/workflows", + "@kbn/workflows-extensions", + "@kbn/inference-plugin", + "@kbn/inference-common", + "@kbn/search-inference-endpoints" + ] +} diff --git a/yarn.lock b/yarn.lock index 23b41de4b98df..14e7db90f367b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7407,6 +7407,10 @@ version "0.0.0" uid "" +"@kbn/inference-workflows-plugin@link:x-pack/platform/plugins/shared/inference_workflows": + version "0.0.0" + uid "" + "@kbn/infra-forge@link:x-pack/platform/packages/private/kbn-infra-forge": version "0.0.0" uid ""