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
62 changes: 61 additions & 1 deletion index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,12 @@ The {{ModelContext}} interface provides methods for web applications to register

<xmp class="idl">
[Exposed=Window, SecureContext]
interface ModelContext {
interface ModelContext : EventTarget {
undefined registerTool(ModelContextTool tool);
undefined unregisterTool(DOMString name);

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

Expand All @@ -198,6 +201,13 @@ is a [=model context=] [=struct=] created alongside the {{ModelContext}}.
</dd>
</dl>

<dl dfn-type=attribute dfn-for=ModelContext>
: <dfn>ontoolactivated</dfn>
:: An [=event handler IDL attribute=] for the {{ModelContext/toolactivated}} event type.
: <dfn>ontoolcancel</dfn>
:: An [=event handler IDL attribute=] for the {{ModelContext/toolcancel}} event type.
</dl>


<div algorithm>
The <dfn method for=ModelContext>registerTool(<var>tool</var>)</dfn> method steps are:
Expand Down Expand Up @@ -353,6 +363,56 @@ The <dfn method for=ModelContextClient>requestUserInteraction(<var ignore>callba

</div>

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

The {{ToolActivatedEvent}} interface represents a <dfn event for=ModelContext>toolactivated</dfn> event that is dispatched at {{Navigator/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 <dfn event for=ModelContext>toolcancel</dfn> event that is dispatched at {{Navigator/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
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