From 3e0df083aeb31176451b89075c94bda059565a52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Beaufort?= Date: Wed, 19 Aug 2026 11:09:03 +0200 Subject: [PATCH] Add ToolActivatedEvent and ToolCancelEvent event interfaces --- index.bs | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/index.bs b/index.bs index 69bed7e..c94d347 100644 --- a/index.bs +++ b/index.bs @@ -283,7 +283,10 @@ To cancel a pending tool execution given a [=traversable navigable=] 1. [=AbortController/signal abort|Signal abort=] on |localExecution|'s [=local pending tool execution/abort controller=]. - Issue(#146): Fire the "toolcanceled" event at |targetDocument|'s relevant global object. + 1. [=Fire an event=] named {{ModelContext/toolcancel}} at |targetDocument|'s + [=Document/associated ModelContext|associated ModelContext=], using + {{ToolCancelEvent}}, with its {{ToolCancelEvent/toolName}} attribute initialized to + |execution|'s [=pending tool execution/tool name=]. @@ -478,7 +481,9 @@ internal value=] |uuid|, are as follows: 1. If |inputObject| [=Object type|is not an Object=] is false, then run |completionSteps| given null and false, and abort these steps. - Issue(#146): Specify and fire the "toolactivated" event. +1. [=Fire an event=] named {{ModelContext/toolactivated}} at |targetDocument|'s [=Document/associated + ModelContext|associated ModelContext=], using {{ToolActivatedEvent}}, with its + {{ToolActivatedEvent/toolName}} attribute initialized to |tool|'s {{ModelContextTool/name}}. 1. Let |controller| be a [=new=] {{AbortController}} created in |targetDocument|'s [=relevant realm=]. @@ -607,6 +612,8 @@ interface ModelContext : EventTarget { Promise executeTool(RegisteredTool tool, optional object inputObject = {}, optional ModelContextExecuteToolOptions options = {}); attribute EventHandler ontoolchange; + attribute EventHandler ontoolactivated; + attribute EventHandler ontoolcancel; }; @@ -1304,8 +1311,58 @@ that must be supported, as [=event handler IDL attributes=], by all {{ModelConte ontoolchange toolchange + + ontoolactivated + toolactivated + + ontoolcancel + toolcancel +

ToolActivatedEvent Interface

+ +The {{ToolActivatedEvent}} interface represents a {{ModelContext/toolactivated}} event that is +dispatched at a {{ModelContext}} object when the execution of a tool begins. + + +[Exposed=Window, SecureContext] +interface ToolActivatedEvent : Event { + constructor(DOMString type, optional ToolActivatedEventInit eventInitDict = {}); + readonly attribute DOMString toolName; +}; + +dictionary ToolActivatedEventInit : EventInit { + DOMString toolName = ""; +}; + + +
+ : toolName + :: Returns the name of the tool whose execution has started. +
+ +

ToolCancelEvent Interface

+ +The {{ToolCancelEvent}} interface represents a {{ModelContext/toolcancel}} event that is dispatched +at a {{ModelContext}} object when the execution of a tool is cancelled. + + +[Exposed=Window, SecureContext] +interface ToolCancelEvent : Event { + constructor(DOMString type, optional ToolCancelEventInit eventInitDict = {}); + readonly attribute DOMString toolName; +}; + +dictionary ToolCancelEventInit : EventInit { + DOMString toolName = ""; +}; + + +
+ : toolName + :: Returns the name of the tool whose execution was cancelled. +
+

Permissions policy integration

Access to the APIs in this specification is gated behind the [=policy-controlled feature=] "