@ractive-ch/tab-mcp 0.1.0-alpha.1 → 0.2.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/config.d.ts +7 -0
- package/exchange.d.ts +23 -0
- package/index.d.ts +1 -1
- package/index.js +268 -49
- package/index.js.map +11 -10
- package/main.js +437 -215
- package/main.js.map +13 -12
- package/notopen.d.ts +24 -0
- package/package.json +1 -1
- package/session.d.ts +5 -1
package/notopen.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type RpcId } from "./exchange.js";
|
|
2
|
+
/**
|
|
3
|
+
* The relay's answers when the page is not open (DEC-074): HTTP 200 with a
|
|
4
|
+
* JSON-RPC message the AI app's model can act on, instead of an HTTP error
|
|
5
|
+
* status that makes MCP clients re-probe the server's protocol era.
|
|
6
|
+
*/
|
|
7
|
+
/** Why the page is not there: never came, or went away mid-request. */
|
|
8
|
+
export type NotOpenPhase = "not_open" | "gone";
|
|
9
|
+
/** What the relay says about itself in a stand-in `server/discover` result. */
|
|
10
|
+
export interface RelayInfo {
|
|
11
|
+
name: string;
|
|
12
|
+
version: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function isRetryable(method: unknown): boolean;
|
|
15
|
+
/** The text for "the page is not open" (tool results and JSON-RPC errors). */
|
|
16
|
+
export declare function notOpenText(appName: string | undefined): string;
|
|
17
|
+
/** The text for a tool call whose page went away while it ran. */
|
|
18
|
+
export declare function goneDuringCallText(appName: string | undefined): string;
|
|
19
|
+
/**
|
|
20
|
+
* The JSON-RPC message the relay answers with (at HTTP 200) when the page is
|
|
21
|
+
* not open, or `undefined` for a notification (that keeps an HTTP error
|
|
22
|
+
* status: the spec requires one for a notification the server cannot accept).
|
|
23
|
+
*/
|
|
24
|
+
export declare function notOpenAnswer(body: Record<string, unknown>, rpcId: RpcId | undefined, appName: string | undefined, phase: NotOpenPhase, relay: RelayInfo): string | undefined;
|
package/package.json
CHANGED
package/session.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RelayConfig, Site, SiteLimits } from "./config.js";
|
|
2
|
-
import { Exchange, type RpcId } from "./exchange.js";
|
|
2
|
+
import { Exchange, type PageGoneReply, type RpcId } from "./exchange.js";
|
|
3
3
|
import type { Logger } from "./log.js";
|
|
4
4
|
import { PairingCodes } from "./oauth/pairing.js";
|
|
5
5
|
import { type ByeReason, type GrantRef, type Limits, type RelayMessage } from "./protocol.js";
|
|
@@ -21,6 +21,8 @@ export interface SessionHost {
|
|
|
21
21
|
claimAddress(session: TabSession): TabSession | undefined;
|
|
22
22
|
/** Called once when a session is over. */
|
|
23
23
|
released(session: TabSession): void;
|
|
24
|
+
/** Called once when a session is ready for MCP requests (DEC-074). */
|
|
25
|
+
ready?(session: TabSession): void;
|
|
24
26
|
/** The tab pressed Disconnect for one app; false if the grant is not this address's. */
|
|
25
27
|
revokeGrant(session: TabSession, grantId: string): Promise<boolean>;
|
|
26
28
|
/** The tab revokes every grant of its address ("New address"). */
|
|
@@ -38,6 +40,8 @@ export interface ForwardInput {
|
|
|
38
40
|
extraHeaders: Record<string, string>;
|
|
39
41
|
/** Called once with the finished exchange (for the request log line). */
|
|
40
42
|
onDone: (exchange: Exchange) => void;
|
|
43
|
+
/** The answer when the page goes away mid-request (DEC-074). */
|
|
44
|
+
pageGone?: (waiting: boolean) => PageGoneReply;
|
|
41
45
|
}
|
|
42
46
|
/** The limits announced to the tab (protocol: `session.limits`). */
|
|
43
47
|
export declare function limitsOf(limits: SiteLimits | RelayConfig): Limits;
|