@ractive-ch/tab-mcp 0.1.0-alpha.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +131 -0
- package/index.d.ts +1 -1
- package/index.js +13 -13
- package/index.js.map +6 -6
- package/main.js +13 -13
- package/main.js.map +6 -6
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -509,7 +509,7 @@ function installCrashLogging(logger, exit = (code) => process.exit(code)) {
|
|
|
509
509
|
};
|
|
510
510
|
}
|
|
511
511
|
// package.json
|
|
512
|
-
var version = "0.1.0
|
|
512
|
+
var version = "0.1.0";
|
|
513
513
|
|
|
514
514
|
// src/address.ts
|
|
515
515
|
var BASE32_ALPHABET = "abcdefghijklmnopqrstuvwxyz234567";
|
|
@@ -1300,7 +1300,7 @@ function renderPage(title, body) {
|
|
|
1300
1300
|
<body>
|
|
1301
1301
|
<main>
|
|
1302
1302
|
${body}
|
|
1303
|
-
<footer>tab-mcp relay. It passes requests between AI
|
|
1303
|
+
<footer>tab-mcp relay. It passes requests between AI apps and web pages and does not store their contents.</footer>
|
|
1304
1304
|
</main>
|
|
1305
1305
|
</body>
|
|
1306
1306
|
</html>`;
|
|
@@ -1401,7 +1401,7 @@ var MESSAGES = {
|
|
|
1401
1401
|
wrong: "That code is not right. Check the code shown in the page and try again.",
|
|
1402
1402
|
expired: "That code has expired. The page now shows a new code: enter that one.",
|
|
1403
1403
|
locked: "Too many wrong codes. The page now shows a new code: enter that one.",
|
|
1404
|
-
inactive: "The page is not showing a code right now. In the page, open \u201CConnect your AI
|
|
1404
|
+
inactive: "The page is not showing a code right now. In the page, open \u201CConnect your AI app\u201D to see one, then enter it here.",
|
|
1405
1405
|
malformed: "Enter the 6 digits shown in the page.",
|
|
1406
1406
|
limited: "Too many attempts for this page. Wait a few minutes and try again. If it keeps happening, someone else may be guessing: use \u201CNew address\u201D in the page."
|
|
1407
1407
|
};
|
|
@@ -1410,7 +1410,7 @@ var codePairing = {
|
|
|
1410
1410
|
render() {
|
|
1411
1411
|
return `<p><label for="code">Code shown in the page</label>
|
|
1412
1412
|
<input id="code" name="code" type="text" inputmode="numeric" autocomplete="one-time-code" pattern="[0-9 ]{6,7}" maxlength="7" required autofocus aria-describedby="code-help"></p>
|
|
1413
|
-
<p id="code-help" class="help">In the page, \u201CConnect your AI
|
|
1413
|
+
<p id="code-help" class="help">In the page, \u201CConnect your AI app\u201D shows a 6-digit code. It changes every 2 minutes.</p>`;
|
|
1414
1414
|
},
|
|
1415
1415
|
check(target, form, admit) {
|
|
1416
1416
|
const result = target.codes.check(form.get("code") ?? "", Date.now(), admit);
|
|
@@ -1607,7 +1607,7 @@ class AuthorizationServer {
|
|
|
1607
1607
|
#errorPage(status, message) {
|
|
1608
1608
|
return this.#page(status, "This connection cannot be made", `<h1>This connection cannot be made</h1>
|
|
1609
1609
|
<p role="alert">${escapeHtml(message)}</p>
|
|
1610
|
-
<p>Go back to your AI
|
|
1610
|
+
<p>Go back to your AI app and try again. If it keeps happening, the AI app may not work with this relay.</p>`);
|
|
1611
1611
|
}
|
|
1612
1612
|
#errorUrl(redirectUri, state, error, description) {
|
|
1613
1613
|
const url = new URL(redirectUri);
|
|
@@ -1625,8 +1625,8 @@ class AuthorizationServer {
|
|
|
1625
1625
|
const url = this.#errorUrl(redirectUri, state, error, description);
|
|
1626
1626
|
const host = hostOf(redirectUri);
|
|
1627
1627
|
return this.#page(400, "This connection cannot be made", `<h1>This connection cannot be made</h1>
|
|
1628
|
-
<p role="alert">The AI
|
|
1629
|
-
<p>You can go back to the AI
|
|
1628
|
+
<p role="alert">The AI app sent a request this relay cannot accept: ${escapeHtml(description)} (${escapeHtml(error)}).</p>
|
|
1629
|
+
<p>You can go back to the AI app at ${escapeHtml(host)} to tell it, or close this page.</p>
|
|
1630
1630
|
<div class="actions"><a class="button" href="${escapeHtml(url)}">Go back to ${escapeHtml(host)}</a></div>`);
|
|
1631
1631
|
}
|
|
1632
1632
|
#redirectError(redirectUri, state, error, description) {
|
|
@@ -1776,7 +1776,7 @@ class AuthorizationServer {
|
|
|
1776
1776
|
const body = `<h1>Open the page first</h1>
|
|
1777
1777
|
${errorHtml}
|
|
1778
1778
|
<p><strong>${escapeHtml(client.name)}</strong> (${escapeHtml(client.host)}) wants to use the tools of a web page, but that page is not open right now.</p>
|
|
1779
|
-
<p>Open the page, click \u201CConnect your AI
|
|
1779
|
+
<p>Open the page, click \u201CConnect your AI app\u201D, then try again here.</p>
|
|
1780
1780
|
<div class="actions">
|
|
1781
1781
|
<a class="button primary" href="${escapeHtml(retryUrl)}">Try again</a>
|
|
1782
1782
|
<a class="button" href="${escapeHtml(cancelUrl)}">Cancel</a>
|
|
@@ -1790,7 +1790,7 @@ ${errorHtml}
|
|
|
1790
1790
|
return this.#errorPage(403, "This form can only be sent from this page.");
|
|
1791
1791
|
}
|
|
1792
1792
|
if (!this.#attemptsPerIp.take(ip)) {
|
|
1793
|
-
return this.#errorPage(429, "Too many attempts from your network. Wait a few minutes, then start again from your AI
|
|
1793
|
+
return this.#errorPage(429, "Too many attempts from your network. Wait a few minutes, then start again from your AI app.");
|
|
1794
1794
|
}
|
|
1795
1795
|
const type = (req.headers.get("content-type") ?? "").split(";")[0]?.trim();
|
|
1796
1796
|
if (type !== "application/x-www-form-urlencoded") {
|
|
@@ -1929,7 +1929,7 @@ ${errorHtml}
|
|
|
1929
1929
|
const body = `<h1>Open the page first</h1>
|
|
1930
1930
|
${errorHtml}
|
|
1931
1931
|
<p>${clientLabel} wants to use the tools of a web page, but that page is not open right now.</p>
|
|
1932
|
-
<p>Open the page, click \u201CConnect your AI
|
|
1932
|
+
<p>Open the page, click \u201CConnect your AI app\u201D, then try again here.</p>
|
|
1933
1933
|
<form method="post" action="/authorize">
|
|
1934
1934
|
${hidden}
|
|
1935
1935
|
<div class="actions">
|
|
@@ -1958,7 +1958,7 @@ ${method.render(session)}
|
|
|
1958
1958
|
${cancel}
|
|
1959
1959
|
</div>
|
|
1960
1960
|
</form>
|
|
1961
|
-
<p class="help">After you connect, your browser goes back to ${escapeHtml(hostOf(pending.redirectUri))}. Only connect AI
|
|
1961
|
+
<p class="help">After you connect, your browser goes back to ${escapeHtml(hostOf(pending.redirectUri))}. Only connect AI apps you started yourself.</p>`;
|
|
1962
1962
|
return this.#page(status, heading, body, targets, extra);
|
|
1963
1963
|
}
|
|
1964
1964
|
async token(req, ip) {
|
|
@@ -3337,7 +3337,7 @@ function startRelay(options, hooks) {
|
|
|
3337
3337
|
const session = sessions.get(addressId);
|
|
3338
3338
|
if (session === undefined || !session.ready) {
|
|
3339
3339
|
logDone(503, method, { reason: "page_not_open" });
|
|
3340
|
-
return rpcError(503, rpcId, RelayErrorCode.pageNotOpen, 'The page is not open. Open the web page that offers these tools and click "Connect your AI
|
|
3340
|
+
return rpcError(503, rpcId, RelayErrorCode.pageNotOpen, 'The page is not open. Open the web page that offers these tools and click "Connect your AI app".', corsHeaders);
|
|
3341
3341
|
}
|
|
3342
3342
|
if (session.pending.size >= session.limits.maxConcurrentRequests) {
|
|
3343
3343
|
logDone(429, method);
|
|
@@ -3623,5 +3623,5 @@ var shutdown = () => {
|
|
|
3623
3623
|
process.on("SIGTERM", shutdown);
|
|
3624
3624
|
process.on("SIGINT", shutdown);
|
|
3625
3625
|
|
|
3626
|
-
//# debugId=
|
|
3626
|
+
//# debugId=9CA2F401657AE02764756E2164756E21
|
|
3627
3627
|
//# sourceMappingURL=main.js.map
|