Repository navigation
Expand file tree
/
Copy pathprobe.html
More file actions
260 lines (249 loc) · 7.78 KB
/
Copy pathprobe.html
File metadata and controls
260 lines (249 loc) · 7.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Understudy WebMCP probe</title>
<style>
:root {
--ink: #161616;
--paper: #fafafa;
--line: #c8c8c8;
--accent: #153e8a;
--present: #0b6b2c;
--absent: #9b1c1c;
}
html {
color: var(--ink);
background: var(--paper);
font: 16px/1.45 system-ui, sans-serif;
}
body {
margin: 0;
padding: 1.25rem 1.5rem 2.5rem;
}
main {
max-width: 40rem;
}
h1 {
margin: 0 0 0.5rem;
font-size: 1.5rem;
font-weight: 650;
color: var(--accent);
}
h2 {
margin: 1.5rem 0 0.5rem;
font-size: 1rem;
font-weight: 650;
}
p,
li {
margin: 0 0 0.75rem;
}
code {
font-family: ui-monospace, monospace;
font-size: 0.9em;
}
dl {
margin: 0;
border: 1px solid var(--line);
}
div.row {
display: grid;
grid-template-columns: 12rem 1fr;
gap: 0.75rem;
padding: 0.55rem 0.75rem;
border-top: 1px solid var(--line);
}
div.row:first-child {
border-top: 0;
}
dt {
margin: 0;
font-weight: 650;
}
dd {
margin: 0;
overflow-wrap: anywhere;
}
.present {
color: var(--present);
font-weight: 650;
}
.absent {
color: var(--absent);
font-weight: 650;
}
#verdict {
margin: 1rem 0 0;
font-size: 1.05rem;
font-weight: 650;
}
</style>
</head>
<body>
<main>
<h1>Understudy WebMCP probe</h1>
<p>
Day-1 feature detection for <code>document.modelContext</code>. This page
uses that API and ordinary DOM only. If the object is present, it registers
a no-op tool and prints the result.
</p>
<h2>Result</h2>
<dl id="rows"></dl>
<p id="verdict"></p>
<h2>How to read this</h2>
<ul>
<li>
PRESENT plus a successful <code>registerTool</code> means this browser
can host Understudy tools.
</li>
<li>
ABSENT means turn on
<code>chrome://flags/#enable-webmcp-testing</code>, or open this file
in ChatGPT's in-app browser. Humans can still use the app with no agent.
</li>
<li>
This probe registers only on <code>document.modelContext</code>. It does
not call the removed <code>navigator.modelContext</code> getter. That
getter is reported as a side reading.
</li>
</ul>
</main>
<script>
(function () {
var rows = document.getElementById("rows");
var verdict = document.getElementById("verdict");
function addRow(label, value, kind) {
var wrap = document.createElement("div");
wrap.className = "row";
var dt = document.createElement("dt");
dt.textContent = label;
var dd = document.createElement("dd");
if (kind) {
dd.className = kind;
}
dd.textContent = value;
wrap.appendChild(dt);
wrap.appendChild(dd);
rows.appendChild(wrap);
}
function kindFor(present) {
return present ? "present" : "absent";
}
function wordFor(present) {
return present ? "PRESENT" : "ABSENT";
}
function summarizeError(err) {
if (err && typeof err === "object") {
var name = typeof err.name === "string" ? err.name : "Error";
var message = typeof err.message === "string" ? err.message : String(err);
return name + ": " + message;
}
return String(err);
}
var ctx = document.modelContext;
var hasCtx = ctx != null && typeof ctx === "object";
var hasRegister = hasCtx && typeof ctx.registerTool === "function";
var navCtx = navigator.modelContext;
var hasNav = navCtx != null && typeof navCtx === "object";
addRow("document.modelContext", wordFor(hasCtx), kindFor(hasCtx));
addRow(
"registerTool",
wordFor(hasRegister),
kindFor(hasRegister)
);
addRow(
"navigator.modelContext (not used)",
wordFor(hasNav),
kindFor(hasNav)
);
addRow(
"secure context",
wordFor(window.isSecureContext === true),
kindFor(window.isSecureContext === true)
);
addRow("user agent", navigator.userAgent || "(empty)");
if (!hasCtx) {
addRow("registerTool call", "skipped (document.modelContext absent)", "absent");
verdict.textContent =
"WebMCP is absent on this page. Understudy cannot register tools here.";
verdict.className = "absent";
return;
}
if (!hasRegister) {
addRow(
"registerTool call",
"skipped (registerTool is not a function)",
"absent"
);
verdict.textContent =
"document.modelContext is present, but registerTool is missing. No tool was registered.";
verdict.className = "absent";
return;
}
var tool = {
name: "understudy_probe",
description:
"No-op probe. Confirms registerTool accepts a tool in this browser.",
inputSchema: { type: "object", properties: {} },
annotations: { readOnlyHint: true, untrustedContentHint: false },
execute: function () {
return "understudy probe: no-op";
},
};
var controller = new AbortController();
Promise.resolve(ctx.registerTool(tool, { signal: controller.signal }))
.then(function () {
addRow("registerTool call", "resolved", "present");
addRow(
"probe tool",
"understudy_probe left registered until reload (tab-scoped)",
"present"
);
verdict.textContent =
"document.modelContext is present and registerTool accepted a no-op tool.";
verdict.className = "present";
if (typeof ctx.getTools !== "function") {
addRow("getTools", "ABSENT (register already succeeded)", "present");
return;
}
return Promise.resolve(ctx.getTools()).then(
function (list) {
var names = [];
if (Array.isArray(list)) {
for (var i = 0; i < list.length; i++) {
var item = list[i];
if (item && typeof item.name === "string") {
names.push(item.name);
}
}
}
var found = names.indexOf("understudy_probe") !== -1;
addRow(
"getTools",
found
? "understudy_probe is in the tool list"
: "returned, but understudy_probe was not listed",
found ? "present" : "absent"
);
},
function (err) {
addRow(
"getTools",
"threw after register: " + summarizeError(err),
"absent"
);
}
);
})
.catch(function (err) {
addRow("registerTool call", "threw: " + summarizeError(err), "absent");
verdict.textContent =
"document.modelContext is present, but registerTool rejected the no-op tool.";
verdict.className = "absent";
});
})();
</script>
</body>
</html>