Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
3c18b6c
add memfs to deps
pgayvallet Jan 21, 2026
e4879d6
work in progress
pgayvallet Jan 22, 2026
c1bca2f
I totally did that alone
pgayvallet Jan 22, 2026
b136796
move FS files, adapt tool result store and runner
pgayvallet Jan 22, 2026
0f22dcd
Merge remote-tracking branch 'upstream/main' into ab-12348-fs-store
pgayvallet Jan 22, 2026
9942e7e
preparing store interface
pgayvallet Jan 23, 2026
d0d69ff
implement fs_store, update read tool
pgayvallet Jan 23, 2026
710fe39
create base set of tools
pgayvallet Jan 23, 2026
f71fe46
move types to server package
pgayvallet Jan 23, 2026
97f1663
fix unit tests
pgayvallet Jan 26, 2026
5e92995
plug FS tools to agent
pgayvallet Jan 26, 2026
f97f223
Merge remote-tracking branch 'upstream/main' into ab-12348-fs-store
pgayvallet Jan 26, 2026
477cef4
remove memfs
pgayvallet Jan 26, 2026
0b029fb
use constants for tool names
pgayvallet Jan 26, 2026
c17e3e8
fix mocks
pgayvallet Jan 26, 2026
77bf6a0
export class to please TS
pgayvallet Jan 28, 2026
42402db
add folder tree util
pgayvallet Jan 28, 2026
5e51506
cleanup agent execution
pgayvallet Jan 28, 2026
5351aaf
move timestamp to prompt factory
pgayvallet Jan 28, 2026
0fd234b
clean exports
pgayvallet Jan 28, 2026
1b0f548
fix types again
pgayvallet Jan 28, 2026
8534c6d
Merge remote-tracking branch 'upstream/main' into ab-12348-fs-store
pgayvallet Jan 29, 2026
d716cd4
rename filesystem to filestore + cleanup
pgayvallet Jan 29, 2026
36dcac4
change namespace
pgayvallet Jan 29, 2026
72fbe61
remove duplicate instructions
pgayvallet Jan 29, 2026
4a92f7d
add kill switch
pgayvallet Jan 29, 2026
1a1e930
add filestore to descriptions
pgayvallet Jan 29, 2026
c7ffc30
update prompt
pgayvallet Jan 29, 2026
447200b
update prompt again
pgayvallet Jan 29, 2026
e9ce8e4
last time
pgayvallet Jan 29, 2026
0b608e6
skill registration
KDKHD Jan 29, 2026
c21fcde
add skill to the file store
KDKHD Jan 29, 2026
78cadf8
use filestore to build skill prompt
KDKHD Jan 30, 2026
41cb18c
add tool manager & load skill tools
KDKHD Feb 2, 2026
bf820d8
tests
KDKHD Feb 2, 2026
33475d7
Merge branch 'main' of github.com:elastic/kibana into feature/agent-b…
KDKHD Feb 2, 2026
2bbfb8d
Changes from node scripts/eslint_all_files --no-cache --fix
kibanamachine Feb 2, 2026
d694503
improve zod skill type, fix lint and type errors
KDKHD Feb 2, 2026
aed5857
Merge branch 'feature/agent-builder-skills2' of github.com:KDKHD/kiba…
KDKHD Feb 2, 2026
ab85374
Changes from node scripts/eslint_all_files --no-cache --fix
kibanamachine Feb 2, 2026
9244354
minor fixes
KDKHD Feb 2, 2026
5e6506f
Merge branch 'feature/agent-builder-skills2' of github.com:KDKHD/kiba…
KDKHD Feb 2, 2026
81e74b7
fix dynamic tool carry over & limit to 7 skill tools
KDKHD Feb 2, 2026
2d116d3
code review
KDKHD Feb 4, 2026
49b20da
Merge branch 'main' into feature/agent-builder-skills2
KDKHD Feb 4, 2026
e2db8fb
Changes from node scripts/eslint_all_files --no-cache --fix
kibanamachine Feb 4, 2026
4a2c2c2
fix types
KDKHD Feb 4, 2026
6b1f94a
fix test
KDKHD Feb 4, 2026
1d674fc
Merge branch 'main' into feature/agent-builder-skills2
KDKHD Feb 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ export interface Conversation {
*/
export interface ConversationInternalState {
prompt?: PromptStorageState;
/**
* Dynamic tool IDs that were added during conversation rounds.
* These tools are persisted across rounds so they remain available.
*/
dynamic_tool_ids?: string[];
}

export type ConversationWithoutRounds = Omit<Conversation, 'rounds'>;
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import { ToolType } from './definition';
import { internalNamespaces } from '../base/namespaces';

const platformCoreTool = (toolName: string) => {
const platformCoreTool = <TName extends string>(
toolName: TName
): `${typeof internalNamespaces.platformCore}.${TName}` => {
return `${internalNamespaces.platformCore}.${toolName}`;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export const toolIdentifierFromToolCall = (toolCall: ToolCall, mapping: ToolIdMa
return mapping.get(toolCall.toolName) ?? toolCall.toolName;
};

function reverseMap<K, V>(map: Map<K, V>): Map<V, K> {
export function reverseMap<K, V>(map: Map<K, V>): Map<V, K> {
const reversed = new Map<V, K>();
for (const [key, value] of map.entries()) {
if (reversed.has(value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import type {
AttachmentsService,
PromptManager,
ConversationStateManager,
SkillsService,
ToolManager,
} from '../runner';
import type { IFileStore } from '../runner/filestore';
import type { AttachmentStateManager } from '../attachments';
Expand Down Expand Up @@ -91,6 +93,14 @@ export interface AgentHandlerContext {
* Attachment service to interact with attachments.
*/
attachments: AttachmentsService;
/**
* Skills service to interact with skills.
*/
skills: SkillsService;
/**
* Tool manager to manage active tools for the agent.
*/
toolManager: ToolManager;
/**
* Result store to access and add tool results during execution.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { internalNamespaces } from '@kbn/agent-builder-common/base/namespaces';
* This is a manually maintained list of all built-in tools registered in Agent Builder.
* The intention is to force a code review from the Agent Builder team when any team adds a new tool.
*/
export const AGENT_BUILDER_BUILTIN_TOOLS: string[] = [
export const AGENT_BUILDER_BUILTIN_TOOLS = [
// platform core tools are registered from the agent builder plugin so will trigger a review anyway
...Object.values(platformCoreTools),

Expand Down Expand Up @@ -40,22 +40,26 @@ export const AGENT_BUILDER_BUILTIN_TOOLS: string[] = [
`${internalNamespaces.security}.attack_discovery_search`,
`${internalNamespaces.security}.security_labs_search`,
`${internalNamespaces.security}.alerts`,
];
] as const;

export type AgentBuilderBuiltinTool = (typeof AGENT_BUILDER_BUILTIN_TOOLS)[number];

/**
* This is a manually maintained list of all built-in agents registered in Agent Builder.
* The intention is to force a code review from the Agent Builder team when any team adds a new agent.
*/
export const AGENT_BUILDER_BUILTIN_AGENTS: string[] = [
export const AGENT_BUILDER_BUILTIN_AGENTS = [
`${internalNamespaces.observability}.agent`,
'platform.dashboard.dashboard_agent',
`${internalNamespaces.security}.agent`,
];
] as const;

export type AgentBuilderBuiltinAgent = (typeof AGENT_BUILDER_BUILTIN_AGENTS)[number];

export const isAllowedBuiltinTool = (toolName: string) => {
return AGENT_BUILDER_BUILTIN_TOOLS.includes(toolName);
return (AGENT_BUILDER_BUILTIN_TOOLS as readonly string[]).includes(toolName);
};

export const isAllowedBuiltinAgent = (agentName: string) => {
return AGENT_BUILDER_BUILTIN_AGENTS.includes(agentName);
return (AGENT_BUILDER_BUILTIN_AGENTS as readonly string[]).includes(agentName);
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
export enum FileEntryType {
toolResult = 'tool_result',
attachment = 'attachment',
skill = 'skill',
skillReferenceContent = 'skill_reference_content',
}

export type FileEntryMetadata<TExtraMeta extends object = {}> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export type {
} from './model_provider';
export type { ToolResultStore, WritableToolResultStore, ToolResultWithMeta } from './result_store';
export type { AttachmentsService } from './attachments_service';
export type { SkillsService } from './skills_service';
export type { ToolManager } from './tool_manager';
export { ToolManagerToolType } from './tool_manager';
export type { SkillsStore, WritableSkillsStore } from './skills_store';
export type { PromptManager, ToolPromptManager, ConfirmationInfo } from './prompt_manager';
export type { ConversationStateManager, ToolStateManager } from './state_manager';
export { FileEntryType } from './filestore';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* 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 { SkillDefinition, SkillBoundedTool } from '../skills';
import type { ExecutableTool } from './tool_provider';

/**
* Service to access skill type definitions.
*/
export interface SkillsService {
/**
* Returns the list of skill type definitions
*/
list(): SkillDefinition[];
/**
* Returns the skill type definition for a given skill id
*/
getSkillDefinition(skillId: string): SkillDefinition | undefined;
/**
* Convert a skill-scoped tool to a generic executable tool
*/
convertSkillTool(tool: SkillBoundedTool): ExecutableTool;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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 { SkillDefinition } from '../skills';

/**
* Store to access skills during execution
*/
export interface SkillsStore {
has(skillId: string): boolean;
get(resultId: string): SkillDefinition;
}

/**
* Writable version of SkillsStore, used internally by the runner/agent
*/
export interface WritableSkillsStore extends SkillsStore {
add(result: SkillDefinition): void;
delete(skillId: string): boolean;
asReadonly(): SkillsStore;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* 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 { StructuredTool } from '@langchain/core/tools';
import type { BrowserApiToolMetadata } from '@kbn/agent-builder-common';
import type { Logger } from '@kbn/logging';
import type { AgentEventEmitterFn, ExecutableTool } from '..';

export interface ToolManagerParams {
dynamicToolCapacity: number;
}

export type ToolName = string;

export interface AddToolOptions {
dynamic?: boolean;
}

export enum ToolManagerToolType {
executable = 'executable',
browser = 'browser',
}

export interface ExecutableToolInput {
type: ToolManagerToolType.executable;
tools: ExecutableTool | ExecutableTool[];
logger: Logger;
eventEmitter?: AgentEventEmitterFn;
}

export interface BrowserToolInput {
type: ToolManagerToolType.browser;
tools: BrowserApiToolMetadata | BrowserApiToolMetadata[];
}

export type AddToolInput = ExecutableToolInput | BrowserToolInput;

/**
* Interface for managing tools in the agent system.
* Handles both static and dynamic tools with LRU eviction for dynamic tools.
*/
export interface ToolManager {
/**
* Adds tools to the tool manager.
* Supports both executable tools and browser API tools.
* @param input - The tool input configuration (executable or browser)
* @param options - Optional configuration for tool storage (static vs dynamic)
*/
addTools(input: AddToolInput, options?: AddToolOptions): Promise<void>;

/**
* Lists all tools in the tool manager.
* @returns an array of all tools (static and dynamic)
*/
list(): StructuredTool[];

/**
* Records the use of a tool, marking it as recently used.
* This affects LRU eviction for dynamic tools.
* @param name - the name of the tool to record usage for
*/
recordToolUse(langchainToolName: ToolName): void;

/**
* Gets the tool id mapping.
* Maps LangChain tool names to internal tool IDs.
* @returns the tool id mapping
*/
getToolIdMapping(): Map<string, string>;

/**
* Gets the internal tool IDs of all dynamic tools currently in the tool manager.
* Returns internal tool IDs (not LangChain names) for persistence.
* @returns array of internal tool IDs
*/
getDynamicToolIds(): string[];
}
Original file line number Diff line number Diff line change
@@ -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.
*/

export type { SkillDefinition } from './type_definition';
export { validateSkillDefinition } from './type_definition';
export type {
SkillBoundedTool,
BuiltinSkillBoundedTool,
IndexSearchSkillBoundedTool,
WorkflowSkillBoundedTool,
StaticEsqlSkillBoundedTool,
} from './tools';
Original file line number Diff line number Diff line change
@@ -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 { ZodObject } from '@kbn/zod';
import type { EsqlToolDefinition, ToolDefinition } from '@kbn/agent-builder-common';
import type {
IndexSearchToolDefinition,
WorkflowToolDefinition,
} from '@kbn/agent-builder-common/tools';
import type { BuiltinToolDefinition } from '../tools/builtin';

export type BuiltinSkillBoundedTool<RunInput extends ZodObject<any> = ZodObject<any>> = Omit<
BuiltinToolDefinition<RunInput>,
'tags' | 'availability'
>;

type SkillBoundToolMixin<T extends ToolDefinition> = Omit<T, 'readonly' | 'tags'>;

export type StaticEsqlSkillBoundedTool = SkillBoundToolMixin<EsqlToolDefinition>;
export type IndexSearchSkillBoundedTool = SkillBoundToolMixin<IndexSearchToolDefinition>;
export type WorkflowSkillBoundedTool = SkillBoundToolMixin<WorkflowToolDefinition>;

/**
* Definition of a tool which is bounded to a skill instance.
*/
export type SkillBoundedTool<RunInput extends ZodObject<any> = ZodObject<any>> =
| BuiltinSkillBoundedTool<RunInput>
| StaticEsqlSkillBoundedTool
| IndexSearchSkillBoundedTool
| WorkflowSkillBoundedTool;
Comment on lines +30 to +34
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for myself: need to factorize that with the attachment bounded tools later (perfectly fine to keep it that way in the PR, I'll handle it later)

Loading
Loading