Skip to content
Draft
Changes from all commits
Commits
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
58 changes: 58 additions & 0 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ interface ModelContext : EventTarget {
undefined registerTool(ModelContextTool tool, optional ModelContextRegisterToolOptions options = {});

attribute EventHandler ontoolchange;
attribute EventHandler ontoolactivated;
attribute EventHandler ontoolcancel;
};
</xmp>

Expand Down Expand Up @@ -589,6 +591,56 @@ The <dfn method for=ModelContextClient>requestUserInteraction(<var ignore>callba

</div>

<h4 id="tool-activated-event">ToolActivatedEvent Interface</h4>

The {{ToolActivatedEvent}} interface represents a {{ModelContext/toolactivated}} event that is dispatched at {{ModelContext}} when a tool is invoked by an [=agent=].

<xmp class="idl">
[Exposed=Window, SecureContext]
interface ToolActivatedEvent : Event {
constructor(DOMString type, optional ToolActivatedEventInit eventInitDict = {});
readonly attribute DOMString toolName;
readonly attribute Element? element;
};

dictionary ToolActivatedEventInit : EventInit {
DOMString toolName = "";
Element? element = null;
};
</xmp>

<dl class="domintro" dfn-type=attribute dfn-for=ToolActivatedEvent>
: <dfn>toolName</dfn>
:: Returns the name of the tool that was activated.
: <dfn>element</dfn>
:: Returns the form element associated with the tool, if any.
</dl>

<h4 id="tool-cancel-event">ToolCancelEvent Interface</h4>

The {{ToolCancelEvent}} interface represents a {{ModelContext/toolcancel}} event that is dispatched at {{ModelContext}} when a tool's invocation is canceled by an [=agent=].

<xmp class="idl">
[Exposed=Window, SecureContext]
interface ToolCancelEvent : Event {
constructor(DOMString type, optional ToolCancelEventInit eventInitDict = {});
readonly attribute DOMString toolName;
readonly attribute Element? element;
};

dictionary ToolCancelEventInit : EventInit {
DOMString toolName = "";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looking at this interface, I'm seeing a potential problem with multiple agents and concurrent activations of the same tool. Which one should be cancelled if all we know is the tool name? I'll comment on the issue.

Element? element = null;
};
</xmp>

<dl class="domintro" dfn-type=attribute dfn-for=ToolCancelEvent>
: <dfn>toolName</dfn>
:: Returns the name of the tool that was canceled.
: <dfn>element</dfn>
:: Returns the form element associated with the tool, if any.
</dl>

<h3 id="declarative-api">Declarative WebMCP</h3>

This section is entirely a TODO. For now, refer to the [explainer draft](https://github.com/webmachinelearning/webmcp/pull/76).
Expand Down Expand Up @@ -631,6 +683,12 @@ that must be supported, as [=event handler IDL attributes=], by all {{ModelConte
<tr>
<td><dfn attribute for="ModelContext">ontoolchange</dfn>
<td><dfn event for="ModelContext">toolchange</dfn>
<tr>
<td><dfn attribute for="ModelContext">ontoolactivated</dfn>
<td><dfn event for="ModelContext">toolactivated</dfn>
<tr>
<td><dfn attribute for="ModelContext">ontoolcancel</dfn>
<td><dfn event for="ModelContext">toolcancel</dfn>
</table>

<h3 id="permissions-policy">Permissions policy integration</h3>
Expand Down
Loading