Skip to content

Commit 7994a52

Browse files
feat(copilot): Add scope property to tool manifests and update repository
- Add optional 'scope' property to ManifestUaiAgentTool.meta - Update frontend tool repository to read scope from manifest - Change filter from m.api to m.meta.parameters for accurate frontend tool detection - Add scopes to frontend tools using kebab-case format: - set_property_value: entity-write - get_page_info: navigation - show_weather: web - get_current_time, confirm_action: no scope (defaults to 'general') This aligns with the tool permission system defined in Core, where scopes are defined by AIToolScopeBase classes with AIToolScopeAttribute. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 7babd11 commit 7994a52

4 files changed

Lines changed: 19 additions & 9 deletions

File tree

Umbraco.AI.Agent.Copilot/src/Umbraco.AI.Agent.Copilot/Client/src/copilot/tools/entity/manifests.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const setPropertyValueManifest: ManifestUaiAgentTool = {
2121
"Only supports TextBox and TextArea properties. " +
2222
"Use the entity context to see available properties and their current values.",
2323
icon: "icon-edit",
24+
scope: "entity-write",
2425
parameters: {
2526
type: "object",
2627
properties: {

Umbraco.AI.Agent.Copilot/src/Umbraco.AI.Agent.Copilot/Client/src/copilot/tools/examples/manifests.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const getCurrentTimeManifest: ManifestUaiAgentTool = {
1111
name: "Get Current Time Tool",
1212
api: () => import("./get-current-time.api.js"),
1313
meta: {
14-
toolName: "getCurrentTime",
14+
toolName: "get_current_time",
1515
label: "Get Current Time",
1616
description: "Get the current date and time in the user's timezone. Use this when you need to know the current time.",
1717
icon: "icon-time",
@@ -39,10 +39,11 @@ const getPageInfoManifest: ManifestUaiAgentTool = {
3939
name: "Get Page Info Tool",
4040
api: () => import("./get-page-info.api.js"),
4141
meta: {
42-
toolName: "getPageInfo",
42+
toolName: "get_page_info",
4343
label: "Get Page Info",
4444
description: "Get information about the current Umbraco backoffice page including URL, section, and context.",
4545
icon: "icon-info",
46+
scope: "navigation",
4647
parameters: {
4748
type: "object",
4849
properties: {},
@@ -62,10 +63,11 @@ const showWeatherManifest: ManifestUaiAgentTool = {
6263
api: () => import("./show-weather.api.js"),
6364
element: () => import("./show-weather.element.js"),
6465
meta: {
65-
toolName: "showWeather",
66+
toolName: "show_weather",
6667
label: "Weather",
6768
description: "Get and display the current weather for a location. Shows a visual weather card with temperature, conditions, and details.",
6869
icon: "icon-cloud",
70+
scope: "web",
6971
parameters: {
7072
type: "object",
7173
properties: {
@@ -91,7 +93,7 @@ const confirmActionManifest: ManifestUaiAgentTool = {
9193
name: "Confirm Action Tool",
9294
api: () => import("./confirm-action.api.js"),
9395
meta: {
94-
toolName: "confirmAction",
96+
toolName: "confirm_action",
9597
label: "Confirm Action",
9698
description:
9799
"Ask the user to confirm an action before executing it. Use this when you need explicit user approval for an operation.",

Umbraco.AI.Agent.Copilot/src/Umbraco.AI.Agent.Copilot/Client/src/copilot/tools/frontend-tool.repository.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,22 @@ export class UaiFrontendToolRepository
1717
}
1818

1919
/**
20-
* Get all available frontend tools (tools with api property).
20+
* Get all available frontend tools (tools with parameters defined).
21+
* Backend tools don't define parameters - they come from the server.
2122
* @returns Array of frontend tool metadata
2223
*/
2324
async getTools(): Promise<UaiFrontendToolData[]> {
24-
const allManifests = umbExtensionsRegistry.getByType('uaiAgentTool') as ManifestUaiAgentTool[];
2525

26-
// Filter to only tools with api (frontend execution)
27-
const frontendToolManifests = allManifests.filter((m) => m.api);
26+
const frontendToolManifests = umbExtensionsRegistry.getByTypeAndFilter<
27+
"uaiAgentTool",
28+
ManifestUaiAgentTool
29+
>("uaiAgentTool", (m) => Boolean(m.api));
2830

2931
return frontendToolManifests.map((m) => ({
3032
id: m.meta.toolName,
3133
name: m.meta.label || m.meta.toolName,
3234
description: m.meta.description || '',
33-
scopeId: 'frontend', // All copilot tools use 'frontend' scope
35+
scopeId: m.meta.scope || 'general', // Read scope from manifest, default to 'general'
3436
}));
3537
}
3638
}

Umbraco.AI.Agent.Copilot/src/Umbraco.AI.Agent.Copilot/Client/src/copilot/tools/uai-agent-tool.extension.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ export interface ManifestUaiAgentTool
148148
parameters?: Record<string, unknown>;
149149
/** Icon to display with the tool */
150150
icon?: string;
151+
/**
152+
* Tool scope for permission grouping (e.g., 'entity.write', 'navigation').
153+
* Used to control which agents can access this tool.
154+
*/
155+
scope?: string;
151156
/**
152157
* HITL approval configuration.
153158
* When specified, tool pauses for user approval before execution.

0 commit comments

Comments
 (0)