@mcp-b/embedded-agent 1.2.8 → 1.2.10
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 +74 -19
- package/dist/FormToolUI-Dhl3il9B.js.map +1 -1
- package/dist/jsx.d.ts +118 -29
- package/dist/styles/globals.css +1 -1
- package/dist/web-component.d.ts +90 -36
- package/dist/web-component.d.ts.map +1 -1
- package/dist/web-component.js +1106 -163
- package/dist/web-component.js.map +1 -1
- package/package.json +4 -3
package/dist/web-component.d.ts
CHANGED
|
@@ -1,45 +1,99 @@
|
|
|
1
|
+
import { TicketAuth, TicketAuth as TicketAuth$1 } from "@char-ai/auth";
|
|
2
|
+
|
|
1
3
|
//#region src/web-component.d.ts
|
|
4
|
+
|
|
2
5
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
* Connection options for the imperative connect() method.
|
|
7
|
+
* Supports two authentication methods:
|
|
8
|
+
* - `idToken`: Direct IDP token authentication (SPA-friendly)
|
|
9
|
+
* - `ticketAuth`: Pre-fetched ticket authentication (SSR-friendly)
|
|
10
|
+
*/
|
|
11
|
+
interface ConnectOptions {
|
|
12
|
+
/**
|
|
13
|
+
* IDP token (ID token) for authentication.
|
|
14
|
+
* Token is stored as a JavaScript property (not as a DOM attribute),
|
|
15
|
+
* preventing exposure to DOM inspection and session replay tools.
|
|
16
|
+
*
|
|
17
|
+
* Either `idToken` or `ticketAuth` must be provided, but not both.
|
|
18
|
+
*/
|
|
19
|
+
idToken?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Pre-fetched ticket for SSR-friendly authentication.
|
|
22
|
+
* Use this when your server has already exchanged the IDP token for a ticket.
|
|
23
|
+
*
|
|
24
|
+
* Benefits:
|
|
25
|
+
* - IDP token never exposed to browser (in SSR mode)
|
|
26
|
+
* - No JWKS fetch on every connection (validation done once)
|
|
27
|
+
* - Ticket is short-lived (60s default) and single-use
|
|
28
|
+
*
|
|
29
|
+
* Either `idToken` or `ticketAuth` must be provided, but not both.
|
|
30
|
+
*/
|
|
31
|
+
ticketAuth?: TicketAuth$1;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Base Web Component from r2wc
|
|
22
35
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
|
|
27
|
-
|
|
36
|
+
* Converts EmbeddedAgent to a <webmcp-agent> custom element.
|
|
37
|
+
* Attributes map to props in kebab-case (e.g., dev-mode -> devMode).
|
|
38
|
+
* Note: Auth props (authToken, ticketAuth) are internal only - use connect() method.
|
|
39
|
+
*/
|
|
40
|
+
declare const BaseWebMCPAgentElement: CustomElementConstructor;
|
|
41
|
+
/**
|
|
42
|
+
* Extended Web Component with secure connect() method
|
|
28
43
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
44
|
+
* The connect() method allows passing the auth token imperatively without
|
|
45
|
+
* exposing it as a DOM attribute. This prevents token leakage via:
|
|
46
|
+
* - Session replay tools (e.g., FullStory, LogRocket)
|
|
47
|
+
* - Error monitoring (e.g., Sentry, DataDog)
|
|
48
|
+
* - DOM snapshots and inspection
|
|
49
|
+
* - Browser extensions
|
|
34
50
|
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```
|
|
37
|
-
* webmcp-agent
|
|
38
|
-
*
|
|
39
|
-
* --char-radius: 12px;
|
|
40
|
-
* }
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* const agent = document.querySelector('webmcp-agent')
|
|
54
|
+
* agent.connect({ idToken: 'eyJhbGciOi...' })
|
|
41
55
|
* ```
|
|
42
56
|
*/
|
|
57
|
+
declare class WebMCPAgentElement extends BaseWebMCPAgentElement {
|
|
58
|
+
/**
|
|
59
|
+
* Connect to the Char agent with authentication.
|
|
60
|
+
*
|
|
61
|
+
* The token is stored as a JavaScript property (not as a DOM attribute),
|
|
62
|
+
* preventing exposure to DOM inspection and session replay tools.
|
|
63
|
+
* This is the recommended way to authenticate.
|
|
64
|
+
*
|
|
65
|
+
* @param options.idToken - IDP token (ID token) for authentication
|
|
66
|
+
* @returns true if connection was initiated, false if idToken was missing
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* // Vanilla JS
|
|
71
|
+
* const agent = document.querySelector('webmcp-agent')
|
|
72
|
+
* const success = agent.connect({ idToken: session.idToken })
|
|
73
|
+
* if (!success) {
|
|
74
|
+
* console.error('Failed to connect - missing token')
|
|
75
|
+
* }
|
|
76
|
+
*
|
|
77
|
+
* // React with ref
|
|
78
|
+
* const agentRef = useRef(null)
|
|
79
|
+
* useEffect(() => {
|
|
80
|
+
* agentRef.current?.connect({ idToken: session.idToken })
|
|
81
|
+
* }, [session.idToken])
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
connect(options: ConnectOptions): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Disconnect from the Char agent.
|
|
87
|
+
* Clears the authentication token.
|
|
88
|
+
* @returns true if disconnection succeeded, false if an error occurred
|
|
89
|
+
*/
|
|
90
|
+
disconnect(): boolean;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Type declaration for the WebMCP Agent custom element.
|
|
94
|
+
* Useful for TypeScript consumers using refs.
|
|
95
|
+
*/
|
|
96
|
+
|
|
43
97
|
/**
|
|
44
98
|
* Register the <webmcp-agent> custom element
|
|
45
99
|
*
|
|
@@ -48,5 +102,5 @@
|
|
|
48
102
|
*/
|
|
49
103
|
declare function registerWebMCPAgent(tagName?: string): void;
|
|
50
104
|
//#endregion
|
|
51
|
-
export { registerWebMCPAgent };
|
|
105
|
+
export { ConnectOptions, type TicketAuth, type WebMCPAgentElement, registerWebMCPAgent };
|
|
52
106
|
//# sourceMappingURL=web-component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-component.d.ts","names":[],"sources":["../src/web-component.tsx"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"web-component.d.ts","names":[],"sources":["../src/web-component.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;UA0EiB,cAAA;;;;;;;;;;;;;;;;;;;;eAqBH;;;;;;;;;cA6KR,wBAAsB;;;;;;;;;;;;;;;;;cAqCtB,kBAAA,SAA2B,sBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA2Bf;;;;;;;;;;;;;;;;;;;iBAoEF,mBAAA"}
|