157 lines
6.8 KiB
Rust
157 lines
6.8 KiB
Rust
use indoc::indoc;
|
|
use rmcp::model::{Tool, ToolAnnotations};
|
|
use rmcp::object;
|
|
|
|
pub const PLATFORM_READ_RESOURCE_TOOL_NAME: &str = "platform__read_resource";
|
|
pub const PLATFORM_LIST_RESOURCES_TOOL_NAME: &str = "platform__list_resources";
|
|
pub const PLATFORM_SEARCH_AVAILABLE_EXTENSIONS_TOOL_NAME: &str =
|
|
"platform__search_available_extensions";
|
|
pub const PLATFORM_MANAGE_EXTENSIONS_TOOL_NAME: &str = "platform__manage_extensions";
|
|
pub const PLATFORM_MANAGE_SCHEDULE_TOOL_NAME: &str = "platform__manage_schedule";
|
|
|
|
pub fn read_resource_tool() -> Tool {
|
|
Tool::new(
|
|
PLATFORM_READ_RESOURCE_TOOL_NAME.to_string(),
|
|
indoc! {r#"
|
|
Read a resource from an extension.
|
|
|
|
Resources allow extensions to share data that provide context to LLMs, such as
|
|
files, database schemas, or application-specific information. This tool searches for the
|
|
resource URI in the provided extension, and reads in the resource content. If no extension
|
|
is provided, the tool will search all extensions for the resource.
|
|
"#}.to_string(),
|
|
object!({
|
|
"type": "object",
|
|
"required": ["uri"],
|
|
"properties": {
|
|
"uri": {"type": "string", "description": "Resource URI"},
|
|
"extension_name": {"type": "string", "description": "Optional extension name"}
|
|
}
|
|
})
|
|
).annotate(ToolAnnotations {
|
|
title: Some("Read a resource".to_string()),
|
|
read_only_hint: Some(true),
|
|
destructive_hint: Some(false),
|
|
idempotent_hint: Some(false),
|
|
open_world_hint: Some(false),
|
|
})
|
|
}
|
|
|
|
pub fn list_resources_tool() -> Tool {
|
|
Tool::new(
|
|
PLATFORM_LIST_RESOURCES_TOOL_NAME.to_string(),
|
|
indoc! {r#"
|
|
List resources from an extension(s).
|
|
|
|
Resources allow extensions to share data that provide context to LLMs, such as
|
|
files, database schemas, or application-specific information. This tool lists resources
|
|
in the provided extension, and returns a list for the user to browse. If no extension
|
|
is provided, the tool will search all extensions for the resource.
|
|
"#}
|
|
.to_string(),
|
|
object!({
|
|
"type": "object",
|
|
"properties": {
|
|
"extension_name": {"type": "string", "description": "Optional extension name"}
|
|
}
|
|
}),
|
|
)
|
|
.annotate(ToolAnnotations {
|
|
title: Some("List resources".to_string()),
|
|
read_only_hint: Some(true),
|
|
destructive_hint: Some(false),
|
|
idempotent_hint: Some(false),
|
|
open_world_hint: Some(false),
|
|
})
|
|
}
|
|
|
|
pub fn search_available_extensions_tool() -> Tool {
|
|
Tool::new(
|
|
PLATFORM_SEARCH_AVAILABLE_EXTENSIONS_TOOL_NAME.to_string(),
|
|
"Searches for additional extensions available to help complete tasks.
|
|
Use this tool when you're unable to find a specific feature or functionality you need to complete your task, or when standard approaches aren't working.
|
|
These extensions might provide the exact tools needed to solve your problem.
|
|
If you find a relevant one, consider using your tools to enable it.".to_string(),
|
|
object!({
|
|
"type": "object",
|
|
"required": [],
|
|
"properties": {}
|
|
})
|
|
).annotate(ToolAnnotations {
|
|
title: Some("Discover extensions".to_string()),
|
|
read_only_hint: Some(true),
|
|
destructive_hint: Some(false),
|
|
idempotent_hint: Some(false),
|
|
open_world_hint: Some(false),
|
|
})
|
|
}
|
|
|
|
pub fn manage_extensions_tool() -> Tool {
|
|
Tool::new(
|
|
PLATFORM_MANAGE_EXTENSIONS_TOOL_NAME.to_string(),
|
|
"Tool to manage extensions and tools in goose context.
|
|
Enable or disable extensions to help complete tasks.
|
|
Enable or disable an extension by providing the extension name.
|
|
"
|
|
.to_string(),
|
|
object!({
|
|
"type": "object",
|
|
"required": ["action", "extension_name"],
|
|
"properties": {
|
|
"action": {"type": "string", "description": "The action to perform", "enum": ["enable", "disable"]},
|
|
"extension_name": {"type": "string", "description": "The name of the extension to enable"}
|
|
}
|
|
}),
|
|
).annotate(ToolAnnotations {
|
|
title: Some("Enable or disable an extension".to_string()),
|
|
read_only_hint: Some(false),
|
|
destructive_hint: Some(false),
|
|
idempotent_hint: Some(false),
|
|
open_world_hint: Some(false),
|
|
})
|
|
}
|
|
|
|
pub fn manage_schedule_tool() -> Tool {
|
|
Tool::new(
|
|
PLATFORM_MANAGE_SCHEDULE_TOOL_NAME.to_string(),
|
|
indoc! {r#"
|
|
Manage scheduled recipe execution for this Goose instance.
|
|
|
|
Actions:
|
|
- "list": List all scheduled jobs
|
|
- "create": Create a new scheduled job from a recipe file
|
|
- "run_now": Execute a scheduled job immediately
|
|
- "pause": Pause a scheduled job
|
|
- "unpause": Resume a paused job
|
|
- "delete": Remove a scheduled job
|
|
- "kill": Terminate a currently running job
|
|
- "inspect": Get details about a running job
|
|
- "sessions": List execution history for a job
|
|
- "session_content": Get the full content (messages) of a specific session
|
|
"#}
|
|
.to_string(),
|
|
object!({
|
|
"type": "object",
|
|
"required": ["action"],
|
|
"properties": {
|
|
"action": {
|
|
"type": "string",
|
|
"enum": ["list", "create", "run_now", "pause", "unpause", "delete", "kill", "inspect", "sessions", "session_content"]
|
|
},
|
|
"job_id": {"type": "string", "description": "Job identifier for operations on existing jobs"},
|
|
"recipe_path": {"type": "string", "description": "Path to recipe file for create action"},
|
|
"cron_expression": {"type": "string", "description": "A cron expression for create action. Supports both 5-field (minute hour day month weekday) and 6-field (second minute hour day month weekday) formats. 5-field expressions are automatically converted to 6-field by prepending '0' for seconds."},
|
|
"execution_mode": {"type": "string", "description": "Execution mode for create action: 'foreground' or 'background'", "enum": ["foreground", "background"], "default": "background"},
|
|
"limit": {"type": "integer", "description": "Limit for sessions list", "default": 50},
|
|
"session_id": {"type": "string", "description": "Session identifier for session_content action"}
|
|
}
|
|
}),
|
|
).annotate(ToolAnnotations {
|
|
title: Some("Manage scheduled recipes".to_string()),
|
|
read_only_hint: Some(false),
|
|
destructive_hint: Some(true), // Can kill jobs
|
|
idempotent_hint: Some(false),
|
|
open_world_hint: Some(false),
|
|
})
|
|
}
|