Repository navigation
Replace document.modelContext.getTools() with window.getTools() - #408
beaufortfrancois wants to merge 2 commits into
Conversation
| property descriptor's `[[Value]]` is set to an anonymous built-in function, created in the | ||
| [=current realm=], that performs the same steps as the {{Window/getTools()}} operation on |O|, | ||
| even if |O|'s [=relevant settings object=] is not a [=secure context=] (and therefore | ||
| `originalDesc` is undefined). |
There was a problem hiding this comment.
I think this makes sense, but curious if there is any policy or dictate that mentions this is required for all new properties we add here? Going to cc @camillelamy here in case she has opinions on this.
| <div algorithm> | ||
| The <dfn method for=Window>getTools(<var>options</var>)</dfn> method steps are: | ||
|
|
||
| 1. Let |callerSettings| be the [=incumbent settings object=]. |
There was a problem hiding this comment.
See https://html.spec.whatwg.org/C#concept-incumbent-everything (the warning). Is there any way around this? I guess this is the same problem that motivated our switch to ToolObserver, although it's a little less bad if we avoid "incumbent" here, and instead construct Tool objects in the target realm?
That'd match how window.open() works:
const w = window.open("https://example.com");
console.log(w instanceof Window); // false! Interesting, huh?and I don't think there's an issue with that (the fact that the returned Window is almost never an instance of the caller's Window constructor). Since WebMCP doesn't otherwise require knowlege of the "source" (the incumbent) here, I think it might be best to avoid incumbent altogether, and swallow the fact that the Tool objects are constructed in the "other" realm.
Let me loop in @jakearchibald here, and I'd be remiss if I didn't /cc @annevk for posterity who might have a quick opinion about this too, since it's such a core part of HTML.
Part of #236. Implements the
window.getTools()portion ofgeneralized-tool-calling.md(#375), focusing only on tool discovery viawindow.getTools()(leavingToolManager,ToolObserver,Tool.execute(), and permissions policy updates forModelContextto follow-up PRs).Note: This PR was drafted with AI assistance and reviewed by me.
Spec changes (
index.bs)getTools()fromModelContexttopartial interface Window([SecureContext]) and renamedModelContextGetToolOptionstoGetToolsOptions.CrossOriginProperties,cross-origin accessible window property name, andCrossOriginGetOwnPropertyHelperfor"getTools"when the current settings object is a secure context.window.getTools()tothis's associatedDocument(resolving to[]if not fully active), dropped the"tools"Permissions Policy check, and ensured the returned promise, errors, andToolobjects are always created in the incumbent realm (queued on the incumbent global object).Documentation updates
README.md,declarative-api-explainer.md, andgeneralized-tool-calling.mdforwindow.getTools()andGetToolsOptions.fromOrigins.Preview | Diff