@mcp-b/char 0.0.6 → 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 +76 -362
- package/dist/custom-elements.json +2180 -0
- package/dist/display-mode-policy.d.ts +82 -0
- package/dist/display-mode-policy.d.ts.map +1 -0
- package/dist/display-mode-policy.js +87 -0
- package/dist/display-mode-policy.js.map +1 -0
- package/dist/index.d.ts +707 -326
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2370 -15521
- package/dist/index.js.map +1 -1
- package/dist/shell-component.d.ts +379 -0
- package/dist/shell-component.d.ts.map +1 -0
- package/dist/shell-component.js +2504 -0
- package/dist/shell-component.js.map +1 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/utils.d.ts +161 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +393 -0
- package/dist/utils.js.map +1 -0
- package/dist/web-component-standalone.iife.js +1255 -2358
- package/dist/web-component-standalone.iife.js.map +1 -1
- package/dist/web-component.d.ts +381 -180
- package/dist/web-component.d.ts.map +1 -1
- package/dist/web-component.js +1138 -15740
- package/dist/web-component.js.map +1 -1
- package/package.json +23 -115
- package/THIRD_PARTY_NOTICES.md +0 -52
- package/dist/VoiceHandoffPanel-CIFIJSDs.js +0 -244
- package/dist/VoiceHandoffPanel-CIFIJSDs.js.map +0 -1
- package/dist/button-BLnLZvxR.js +0 -105
- package/dist/button-BLnLZvxR.js.map +0 -1
- package/dist/realtimekit.d.ts +0 -15
- package/dist/realtimekit.d.ts.map +0 -1
- package/dist/realtimekit.js +0 -89
- package/dist/realtimekit.js.map +0 -1
- package/dist/styles/globals.css +0 -2
- package/dist/styles.d.ts +0 -2
- package/dist/web-component-standalone.css +0 -37
- package/dist/web-component-standalone.css.map +0 -1
package/dist/web-component.d.ts
CHANGED
|
@@ -1,250 +1,451 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
//#region ../auth/dist/security/ticket.d.ts
|
|
2
|
+
//#region src/types.d.ts
|
|
5
3
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Server-issued ticket auth payload.
|
|
5
|
+
* Used for SSR-friendly authentication flows.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
8
|
*/
|
|
9
9
|
interface TicketAuth {
|
|
10
|
-
/**
|
|
10
|
+
/** Short-lived server-issued ticket used to start an authenticated session. */
|
|
11
11
|
ticket: string;
|
|
12
|
-
/**
|
|
12
|
+
/** End-user identifier associated with the issued ticket. */
|
|
13
13
|
userId: string;
|
|
14
|
-
/** Organization
|
|
14
|
+
/** Organization identifier used to scope the authenticated session. */
|
|
15
15
|
orgId: string;
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Development-only embed controls used by local host integrations.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
19
22
|
interface DevModeConfig {
|
|
20
|
-
/**
|
|
21
|
-
* Your Anthropic API key for chat.
|
|
22
|
-
* Required for anonymous mode (no authToken).
|
|
23
|
-
*/
|
|
24
23
|
anthropicApiKey?: string;
|
|
25
|
-
/** Your OpenAI API key for voice mode (optional) */
|
|
26
24
|
openaiApiKey?: string;
|
|
27
|
-
/** Use window.location.origin instead of production API (for internal development) */
|
|
28
25
|
useLocalApi?: boolean;
|
|
29
26
|
}
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region src/web-component.d.ts
|
|
32
27
|
/**
|
|
33
28
|
* Connection options for the imperative connect() method.
|
|
34
|
-
*
|
|
35
|
-
*
|
|
29
|
+
*
|
|
30
|
+
* Supports two mutually exclusive authentication strategies:
|
|
31
|
+
* - `idToken` + `clientId`: Direct IDP token authentication (SPA-friendly)
|
|
36
32
|
* - `ticketAuth`: Pre-fetched ticket authentication (SSR-friendly)
|
|
33
|
+
*
|
|
34
|
+
* Exactly one strategy must be provided. The discriminated union prevents
|
|
35
|
+
* combining `idToken` and `ticketAuth` at the type level.
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
37
38
|
*/
|
|
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
|
-
|
|
39
|
+
type ConnectOptions = {
|
|
40
|
+
/** IDP token (ID token) for authentication. */idToken: string; /** OIDC client ID for audience validation. Required with `idToken`. */
|
|
41
|
+
clientId?: string; /** Optional organization context for multi-tenant same-origin dashboards. */
|
|
42
|
+
organizationId?: string; /** Must not be provided when using `idToken` authentication. */
|
|
43
|
+
ticketAuth?: never;
|
|
44
|
+
} | {
|
|
45
|
+
/** Pre-fetched ticket for SSR-friendly authentication. */ticketAuth: TicketAuth; /** Must not be provided when using `ticketAuth` authentication. */
|
|
46
|
+
idToken?: never; /** Must not be provided when using `ticketAuth` authentication. */
|
|
47
|
+
clientId?: never; /** Must not be provided when using `ticketAuth` authentication. */
|
|
48
|
+
organizationId?: never;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Host visual theme hint.
|
|
52
|
+
*
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
type CharTheme = 'light' | 'dark';
|
|
56
|
+
/**
|
|
57
|
+
* Allowed display modes for the host shell and embedded runtime.
|
|
58
|
+
*
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
type CharDisplayMode = 'inline' | 'fullscreen' | 'pip';
|
|
62
|
+
/**
|
|
63
|
+
* Host platform hint for embedded UI adaptations.
|
|
64
|
+
*
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
type CharPlatform = 'web' | 'desktop' | 'mobile';
|
|
68
|
+
/**
|
|
69
|
+
* Host-provided style payload applied inside the iframe.
|
|
70
|
+
*
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
interface CharHostStyles {
|
|
74
|
+
variables?: Record<string, string>;
|
|
75
|
+
fonts?: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Host container size constraints.
|
|
79
|
+
*
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
interface CharContainerDimensions {
|
|
83
|
+
width?: number;
|
|
84
|
+
height?: number;
|
|
85
|
+
maxWidth?: number;
|
|
86
|
+
maxHeight?: number;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Lightweight device capability hints from the host environment.
|
|
90
|
+
*
|
|
91
|
+
* @public
|
|
92
|
+
*/
|
|
93
|
+
interface CharDeviceCapabilities {
|
|
94
|
+
touch?: boolean;
|
|
95
|
+
hover?: boolean;
|
|
96
|
+
pointerFine?: boolean;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Safe-area inset values detected on the host.
|
|
100
|
+
*
|
|
101
|
+
* @public
|
|
102
|
+
*/
|
|
103
|
+
interface CharSafeAreaInsets {
|
|
104
|
+
top?: number;
|
|
105
|
+
right?: number;
|
|
106
|
+
bottom?: number;
|
|
107
|
+
left?: number;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Host shell capability flags advertised to the iframe runtime.
|
|
111
|
+
*
|
|
112
|
+
* @public
|
|
113
|
+
*/
|
|
114
|
+
interface CharHostCapabilities {
|
|
115
|
+
supportedDisplayModes?: CharDisplayMode[];
|
|
116
|
+
supportsOpenLink?: boolean;
|
|
117
|
+
supportsTeardown?: boolean;
|
|
118
|
+
maxContainerWidth?: number;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Host context payload sent from the embedding page to the iframe runtime.
|
|
122
|
+
*
|
|
123
|
+
* @public
|
|
124
|
+
*/
|
|
125
|
+
interface CharHostContext {
|
|
126
|
+
theme?: CharTheme;
|
|
127
|
+
styles?: CharHostStyles;
|
|
128
|
+
displayMode?: CharDisplayMode;
|
|
129
|
+
availableDisplayModes?: CharDisplayMode[];
|
|
130
|
+
containerDimensions?: CharContainerDimensions;
|
|
131
|
+
locale?: string;
|
|
132
|
+
timeZone?: string;
|
|
133
|
+
platform?: CharPlatform;
|
|
134
|
+
deviceCapabilities?: CharDeviceCapabilities;
|
|
135
|
+
safeAreaInsets?: CharSafeAreaInsets;
|
|
136
|
+
userAgent?: string;
|
|
137
|
+
hostCapabilities?: CharHostCapabilities;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Payload for the `char-size-changed` event.
|
|
141
|
+
*
|
|
142
|
+
* @public
|
|
143
|
+
*/
|
|
144
|
+
interface CharSizeChangedDetail {
|
|
145
|
+
width?: number;
|
|
146
|
+
height?: number;
|
|
147
|
+
displayMode?: CharDisplayMode;
|
|
67
148
|
}
|
|
68
149
|
/**
|
|
69
|
-
*
|
|
150
|
+
* Payload for the `char-request-display-mode` event.
|
|
70
151
|
*
|
|
71
|
-
*
|
|
72
|
-
* Attributes map to props in kebab-case (e.g., dev-mode -> devMode).
|
|
73
|
-
* Note: Auth props (authToken, ticketAuth) are internal only - use connect() method.
|
|
152
|
+
* @public
|
|
74
153
|
*/
|
|
75
|
-
|
|
154
|
+
interface CharRequestDisplayModeDetail {
|
|
155
|
+
mode?: CharDisplayMode;
|
|
156
|
+
}
|
|
76
157
|
/**
|
|
77
|
-
*
|
|
158
|
+
* Payload for the `char-error` event.
|
|
78
159
|
*
|
|
79
|
-
*
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
160
|
+
* @public
|
|
161
|
+
*/
|
|
162
|
+
interface CharErrorDetail {
|
|
163
|
+
code: string;
|
|
164
|
+
message?: string;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Payload for the `char-open-link` event.
|
|
85
168
|
*
|
|
86
|
-
* @
|
|
87
|
-
* ```ts
|
|
88
|
-
* const agent = document.querySelector('char-agent')
|
|
89
|
-
* agent.connect({ idToken: 'eyJhbGciOi...' })
|
|
90
|
-
* ```
|
|
169
|
+
* @public
|
|
91
170
|
*/
|
|
92
|
-
|
|
171
|
+
interface CharOpenLinkDetail {
|
|
172
|
+
requestId: string;
|
|
173
|
+
url: string;
|
|
174
|
+
ok: boolean;
|
|
175
|
+
}
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/web-component.d.ts
|
|
178
|
+
/**
|
|
179
|
+
* `<char-agent>` custom element.
|
|
180
|
+
*
|
|
181
|
+
* Creates an iframe pointing to the SaaS app's /embed/ entrypoint and relays
|
|
182
|
+
* auth, styles, dark mode, display mode, and MCP messages via postMessage.
|
|
183
|
+
*
|
|
184
|
+
* Uses a unified `char-context` message with diffing (only changed fields
|
|
185
|
+
* are sent) instead of separate messages per concern.
|
|
186
|
+
*
|
|
187
|
+
* @public
|
|
188
|
+
*/
|
|
189
|
+
declare class CharAgentElement extends HTMLElement {
|
|
190
|
+
static observedAttributes: string[];
|
|
191
|
+
/**
|
|
192
|
+
* React 19-friendly property form of `dev-mode`.
|
|
193
|
+
* Read once during `connectedCallback`.
|
|
194
|
+
*/
|
|
195
|
+
devMode?: DevModeConfig;
|
|
196
|
+
/**
|
|
197
|
+
* React 19-friendly property form of `api-base`.
|
|
198
|
+
* Read once during `connectedCallback`.
|
|
199
|
+
*/
|
|
200
|
+
apiBase?: string;
|
|
201
|
+
/** Active iframe element owned by this custom element instance. */
|
|
202
|
+
private _iframe;
|
|
203
|
+
/** MCP relay between host window and embed iframe. */
|
|
204
|
+
private _proxy;
|
|
205
|
+
/** Indicates whether the iframe has emitted `char-ready`. */
|
|
206
|
+
private _iframeReady;
|
|
207
|
+
/** Bound window message handler for iframe-originated events. */
|
|
208
|
+
private _messageListener;
|
|
209
|
+
/** Observer that tracks host theme mutations. */
|
|
210
|
+
private _darkModeObserver;
|
|
211
|
+
/** Media query object for `prefers-color-scheme`. */
|
|
212
|
+
private _darkModeMediaQuery;
|
|
213
|
+
/** Registered media query callback. */
|
|
214
|
+
private _darkModeMediaHandler;
|
|
215
|
+
/** Observer that tracks host style/class mutations. */
|
|
216
|
+
private _styleObserver;
|
|
217
|
+
/** Observer that tracks container size changes. */
|
|
218
|
+
private _containerResizeObserver;
|
|
219
|
+
/** In-flight teardown request waiting for iframe acknowledgement. */
|
|
220
|
+
private _teardownPending;
|
|
221
|
+
/** Monotonic sequence used to construct teardown request IDs. */
|
|
222
|
+
private _teardownSequence;
|
|
223
|
+
/** Re-entrancy guard used during disconnect lifecycle. */
|
|
224
|
+
private _isDisconnecting;
|
|
225
|
+
/** Last host context snapshot used for delta emission. */
|
|
226
|
+
private _hostContext;
|
|
227
|
+
/** Pending credentials that are flushed when the iframe is ready. */
|
|
228
|
+
private _pendingAuth;
|
|
229
|
+
/**
|
|
230
|
+
* Mount lifecycle: builds iframe runtime, starts proxying, and starts host observers.
|
|
231
|
+
* The existing runtime is reused when reconnecting during fast detach/reattach cycles.
|
|
232
|
+
*/
|
|
233
|
+
connectedCallback(): void;
|
|
234
|
+
/**
|
|
235
|
+
* Determines whether this instance already has an initialized runtime.
|
|
236
|
+
*/
|
|
237
|
+
private _hasActiveRuntime;
|
|
238
|
+
/**
|
|
239
|
+
* Parses and validates the iframe origin from the configured API base URL.
|
|
240
|
+
*
|
|
241
|
+
* @throws Error When `apiBase` is not a valid URL.
|
|
242
|
+
*/
|
|
243
|
+
private _resolveIframeOrigin;
|
|
244
|
+
/**
|
|
245
|
+
* Creates a fully configured iframe element for the embed runtime.
|
|
246
|
+
*/
|
|
247
|
+
private _createIframe;
|
|
248
|
+
/**
|
|
249
|
+
* Creates the message listener that filters by source/origin and dispatches typed events.
|
|
250
|
+
*/
|
|
251
|
+
private _createMessageListener;
|
|
252
|
+
/**
|
|
253
|
+
* Routes validated iframe messages to local handlers and host DOM events.
|
|
254
|
+
*/
|
|
255
|
+
private _handleIframeMessage;
|
|
256
|
+
/**
|
|
257
|
+
* Emits a host-facing custom event without detail payload.
|
|
258
|
+
*/
|
|
259
|
+
private _emitCharEvent;
|
|
260
|
+
/**
|
|
261
|
+
* Emits a host-facing custom event with detail payload.
|
|
262
|
+
*/
|
|
263
|
+
private _emitCharEventWithDetail;
|
|
264
|
+
/**
|
|
265
|
+
* Emits a standardized `char-error` event.
|
|
266
|
+
*/
|
|
267
|
+
private _emitCharError;
|
|
268
|
+
/**
|
|
269
|
+
* Unmount lifecycle: requests iframe teardown and releases all host resources.
|
|
270
|
+
*/
|
|
271
|
+
disconnectedCallback(): void;
|
|
272
|
+
/**
|
|
273
|
+
* Releases iframe, observers, listeners, and pending teardown state.
|
|
274
|
+
*/
|
|
275
|
+
private _finalizeDisconnect;
|
|
276
|
+
/**
|
|
277
|
+
* Reacts to observed attribute updates after iframe readiness.
|
|
278
|
+
* Attributes that affect iframe boot configuration are intentionally ignored
|
|
279
|
+
* after mount (`dev-mode`, `enable-debug-tools`, `api-base`).
|
|
280
|
+
*/
|
|
281
|
+
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
|
|
93
282
|
/**
|
|
94
283
|
* Connect to the Char agent with authentication.
|
|
95
284
|
*
|
|
96
285
|
* The token is stored as a JavaScript property (not as a DOM attribute),
|
|
97
286
|
* preventing exposure to DOM inspection and session replay tools.
|
|
98
|
-
* This is the recommended way to authenticate.
|
|
99
|
-
*
|
|
100
|
-
* @param options.idToken - IDP token (ID token) for authentication
|
|
101
|
-
* @param options.clientId - OIDC client ID (required when using idToken)
|
|
102
|
-
* @param options.ticketAuth - Pre-fetched ticket (alternative to idToken)
|
|
103
|
-
* @returns true if connection was initiated, false if validation failed
|
|
104
287
|
*
|
|
105
|
-
* @
|
|
106
|
-
*
|
|
107
|
-
* // Vanilla JS
|
|
108
|
-
* const agent = document.querySelector('char-agent')
|
|
109
|
-
* const success = agent.connect({
|
|
110
|
-
* idToken: session.idToken,
|
|
111
|
-
* clientId: 'your-oidc-client-id'
|
|
112
|
-
* })
|
|
113
|
-
*
|
|
114
|
-
* // React with ref
|
|
115
|
-
* const agentRef = useRef(null)
|
|
116
|
-
* useEffect(() => {
|
|
117
|
-
* agentRef.current?.connect({
|
|
118
|
-
* idToken: session.idToken,
|
|
119
|
-
* clientId: 'your-oidc-client-id'
|
|
120
|
-
* })
|
|
121
|
-
* }, [session.idToken])
|
|
122
|
-
* ```
|
|
288
|
+
* @param options - Authentication payload for either ID token or ticket auth.
|
|
289
|
+
* @returns `true` when the payload is accepted; `false` when validation fails.
|
|
123
290
|
*/
|
|
124
291
|
connect(options: ConnectOptions): boolean;
|
|
292
|
+
/**
|
|
293
|
+
* Convenience method for declarative wrappers.
|
|
294
|
+
* Applies auth when provided, otherwise clears auth.
|
|
295
|
+
*
|
|
296
|
+
* @param options - Auth payload to connect, or `null` to disconnect.
|
|
297
|
+
* @returns Result from `connect()` or `disconnect()`.
|
|
298
|
+
*/
|
|
299
|
+
setAuth(options: ConnectOptions | null): boolean;
|
|
125
300
|
/**
|
|
126
301
|
* Disconnect from the Char agent.
|
|
127
302
|
* Clears the authentication token.
|
|
128
|
-
*
|
|
303
|
+
*
|
|
304
|
+
* @returns `true` when the disconnect message was sent; `false` when the iframe was not ready.
|
|
129
305
|
*/
|
|
130
306
|
disconnect(): boolean;
|
|
131
307
|
/**
|
|
132
|
-
*
|
|
308
|
+
* Resolves the current iframe origin when mounted.
|
|
309
|
+
*/
|
|
310
|
+
private _getIframeOrigin;
|
|
311
|
+
/**
|
|
312
|
+
* Update the host context sent to the iframe.
|
|
313
|
+
* Only changed fields are transmitted (diffing pattern).
|
|
133
314
|
*
|
|
134
|
-
*
|
|
135
|
-
|
|
136
|
-
|
|
315
|
+
* @param hostContext - Partial host context patch to merge and emit.
|
|
316
|
+
*/
|
|
317
|
+
setHostContext(hostContext: CharHostContext): void;
|
|
318
|
+
/**
|
|
319
|
+
* Build and send the full initial context after iframe signals char-ready.
|
|
137
320
|
*
|
|
138
|
-
*
|
|
139
|
-
* before unmounting, preventing the race condition.
|
|
321
|
+
* @param iframeOrigin - Trusted origin used for postMessage target filtering.
|
|
140
322
|
*/
|
|
141
|
-
|
|
323
|
+
private _sendInitialContext;
|
|
324
|
+
/**
|
|
325
|
+
* Send a context delta to the iframe.
|
|
326
|
+
*
|
|
327
|
+
* @param changes - Minimal context patch derived from diffing.
|
|
328
|
+
*/
|
|
329
|
+
private _sendContextDelta;
|
|
330
|
+
/**
|
|
331
|
+
* Post authentication credentials to the iframe.
|
|
332
|
+
*
|
|
333
|
+
* @param iframeOrigin - Trusted origin used for postMessage target filtering.
|
|
334
|
+
*/
|
|
335
|
+
private _postAuth;
|
|
336
|
+
/**
|
|
337
|
+
* Requests graceful iframe teardown and resolves once acknowledged or timed out.
|
|
338
|
+
*
|
|
339
|
+
* @param iframeOrigin - Trusted origin used for postMessage target filtering.
|
|
340
|
+
* @param reason - Lifecycle reason for teardown.
|
|
341
|
+
* @returns Promise resolved when teardown flow completes.
|
|
342
|
+
*/
|
|
343
|
+
private _requestTeardown;
|
|
344
|
+
/**
|
|
345
|
+
* Completes an in-flight teardown promise when the iframe acknowledges it.
|
|
346
|
+
*
|
|
347
|
+
* @param requestId - Optional request identifier to match against pending teardown.
|
|
348
|
+
*/
|
|
349
|
+
private _resolvePendingTeardown;
|
|
350
|
+
/**
|
|
351
|
+
* Handles open-link requests from the iframe with protocol allowlisting.
|
|
352
|
+
* This allowlist intentionally mirrors the iframe-side pre-filter.
|
|
353
|
+
*
|
|
354
|
+
* @param requestId - Link request identifier supplied by the iframe.
|
|
355
|
+
* @param url - Requested URL string.
|
|
356
|
+
* @param iframeOrigin - Trusted origin used for postMessage target filtering.
|
|
357
|
+
*/
|
|
358
|
+
private _handleOpenLinkRequest;
|
|
359
|
+
/**
|
|
360
|
+
* Observe dark mode changes and forward to iframe via unified context.
|
|
361
|
+
*/
|
|
362
|
+
private _observeDarkMode;
|
|
363
|
+
/**
|
|
364
|
+
* Observe style attribute changes on <char-agent> to detect CSS variable updates.
|
|
365
|
+
* Re-extracts variables and sends delta via unified context.
|
|
366
|
+
*/
|
|
367
|
+
private _observeStyleChanges;
|
|
368
|
+
/**
|
|
369
|
+
* Observe host element dimensions to provide containerDimensions context.
|
|
370
|
+
*/
|
|
371
|
+
private _observeContainerDimensions;
|
|
372
|
+
/**
|
|
373
|
+
* Resolve devMode from property (React 19) or attribute.
|
|
374
|
+
*
|
|
375
|
+
* @returns Parsed dev-mode configuration when valid.
|
|
376
|
+
*/
|
|
377
|
+
private _resolveDevMode;
|
|
378
|
+
/**
|
|
379
|
+
* Resolve apiBase override from property (React 19) or attribute.
|
|
380
|
+
*
|
|
381
|
+
* @returns Sanitized API base URL without trailing slash.
|
|
382
|
+
*/
|
|
383
|
+
private _resolveApiBaseOverride;
|
|
142
384
|
}
|
|
143
385
|
/**
|
|
144
386
|
* Type declaration for the Char custom element.
|
|
145
387
|
* Useful for TypeScript consumers using refs.
|
|
388
|
+
*
|
|
389
|
+
* @public
|
|
146
390
|
*/
|
|
147
391
|
/**
|
|
148
|
-
*
|
|
392
|
+
* Legacy alias for `CharAgentElement`.
|
|
149
393
|
*
|
|
150
|
-
*
|
|
151
|
-
* Styles are injected into the shadow root by ShadowRoot component.
|
|
394
|
+
* @public
|
|
152
395
|
*/
|
|
153
|
-
|
|
396
|
+
type CharElement = CharAgentElement;
|
|
154
397
|
/**
|
|
155
|
-
*
|
|
156
|
-
* returns CharAgentElement automatically without manual type casting.
|
|
398
|
+
* Backward-compatible alias for `CharAgentElement`.
|
|
157
399
|
*
|
|
158
|
-
* @
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
400
|
+
* @public
|
|
401
|
+
*/
|
|
402
|
+
type WebMCPAgentElement = CharAgentElement;
|
|
403
|
+
/**
|
|
404
|
+
* Register the <char-agent> custom element.
|
|
405
|
+
* Called automatically when importing this module.
|
|
162
406
|
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
* ```
|
|
407
|
+
* @param tagName - Optional custom tag name override.
|
|
408
|
+
*
|
|
409
|
+
* @public
|
|
167
410
|
*/
|
|
411
|
+
declare function registerChar(tagName?: string): void;
|
|
168
412
|
declare global {
|
|
169
413
|
interface HTMLElementTagNameMap {
|
|
170
414
|
'char-agent': CharAgentElement;
|
|
171
415
|
}
|
|
416
|
+
namespace JSX {
|
|
417
|
+
interface IntrinsicElements {
|
|
418
|
+
'char-agent': {
|
|
419
|
+
/** Development mode configuration (JSON string for HTML attributes). */'dev-mode'?: string; /** Property form of dev mode config. */
|
|
420
|
+
devMode?: DevModeConfig; /** Explicit API base override, e.g. `https://staging-app.usechar.ai`. */
|
|
421
|
+
'api-base'?: string; /** Property form of API base override. */
|
|
422
|
+
apiBase?: string; /** Enable debug tools for inspecting embedded agent internal state. */
|
|
423
|
+
'enable-debug-tools'?: boolean; /** Display mode for host orchestration: `pip` is collapsed launcher mode. */
|
|
424
|
+
'display-mode'?: CharDisplayMode; /** Callback when the close button inside the agent panel is clicked. */
|
|
425
|
+
onClose?: () => void; /** Imperative ref to the custom element instance. */
|
|
426
|
+
ref?: unknown;
|
|
427
|
+
[key: string]: unknown;
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
}
|
|
172
431
|
}
|
|
173
|
-
declare module 'react' {
|
|
432
|
+
declare module 'react/jsx-runtime' {
|
|
174
433
|
namespace JSX {
|
|
175
434
|
interface IntrinsicElements {
|
|
176
|
-
'char-agent':
|
|
177
|
-
/**
|
|
178
|
-
* Controlled open state.
|
|
179
|
-
* When provided, the host controls whether the agent UI is open or collapsed.
|
|
180
|
-
*/
|
|
181
|
-
open?: boolean;
|
|
182
|
-
/**
|
|
183
|
-
* Development mode configuration (JSON string for HTML attributes).
|
|
184
|
-
*
|
|
185
|
-
* @example React 18 (JSON string attribute)
|
|
186
|
-
* ```tsx
|
|
187
|
-
* <char-agent
|
|
188
|
-
* dev-mode={JSON.stringify({
|
|
189
|
-
* anthropicApiKey: import.meta.env.VITE_ANTHROPIC_API_KEY
|
|
190
|
-
* })}
|
|
191
|
-
* />
|
|
192
|
-
* ```
|
|
193
|
-
*/
|
|
435
|
+
'char-agent': {
|
|
194
436
|
'dev-mode'?: string;
|
|
195
|
-
/**
|
|
196
|
-
* React 19 only: Pass devMode as an object property directly.
|
|
197
|
-
* React 19 automatically sets object properties on custom elements.
|
|
198
|
-
*
|
|
199
|
-
* @example
|
|
200
|
-
* ```tsx
|
|
201
|
-
* <char-agent devMode={{ anthropicApiKey: 'sk-...' }} />
|
|
202
|
-
* ```
|
|
203
|
-
*/
|
|
204
437
|
devMode?: DevModeConfig;
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
* @default false
|
|
208
|
-
*/
|
|
438
|
+
'api-base'?: string;
|
|
439
|
+
apiBase?: string;
|
|
209
440
|
'enable-debug-tools'?: boolean;
|
|
210
|
-
|
|
211
|
-
* Callback when the close button inside the agent panel is clicked.
|
|
212
|
-
*
|
|
213
|
-
* NOTE: r2wc does not support function callbacks as attributes.
|
|
214
|
-
* Instead, listen for the 'char-close' custom event:
|
|
215
|
-
*
|
|
216
|
-
* @example
|
|
217
|
-
* ```tsx
|
|
218
|
-
* const [isOpen, setIsOpen] = useState(true);
|
|
219
|
-
*
|
|
220
|
-
* useEffect(() => {
|
|
221
|
-
* const handleClose = () => setIsOpen(false);
|
|
222
|
-
* document.addEventListener('char-close', handleClose);
|
|
223
|
-
* return () => document.removeEventListener('char-close', handleClose);
|
|
224
|
-
* }, []);
|
|
225
|
-
*
|
|
226
|
-
* return <char-agent open={isOpen} />;
|
|
227
|
-
* ```
|
|
228
|
-
*/
|
|
441
|
+
'display-mode'?: CharDisplayMode;
|
|
229
442
|
onClose?: () => void;
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
*
|
|
234
|
-
* @example
|
|
235
|
-
* ```tsx
|
|
236
|
-
* const agentRef = useRef<CharAgentElement>(null);
|
|
237
|
-
* useEffect(() => {
|
|
238
|
-
* agentRef.current?.connect({ idToken: session.idToken });
|
|
239
|
-
* }, [session.idToken]);
|
|
240
|
-
* return <char-agent ref={agentRef} />;
|
|
241
|
-
* ```
|
|
242
|
-
*/
|
|
243
|
-
ref?: React.Ref<CharAgentElement>;
|
|
244
|
-
}, CharAgentElement>;
|
|
443
|
+
ref?: unknown;
|
|
444
|
+
[key: string]: unknown;
|
|
445
|
+
};
|
|
245
446
|
}
|
|
246
447
|
}
|
|
247
448
|
} //# sourceMappingURL=web-component.d.ts.map
|
|
248
449
|
//#endregion
|
|
249
|
-
export { type CharAgentElement, ConnectOptions, type DevModeConfig, type TicketAuth, registerChar };
|
|
450
|
+
export { type CharAgentElement, type CharContainerDimensions, type CharDeviceCapabilities, type CharDisplayMode, CharElement, type CharErrorDetail, type CharHostCapabilities, type CharHostContext, type CharHostStyles, type CharOpenLinkDetail, type CharPlatform, type CharRequestDisplayModeDetail, type CharSafeAreaInsets, type CharSizeChangedDetail, type CharTheme, type ConnectOptions, type DevModeConfig, type TicketAuth, WebMCPAgentElement, registerChar };
|
|
250
451
|
//# sourceMappingURL=web-component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-component.d.ts","names":[
|
|
1
|
+
{"version":3,"file":"web-component.d.ts","names":[],"sources":["../src/types.ts","../src/web-component.tsx"],"mappings":";;;AAMA;;;;;UAAiB,UAAA;EAMhB;EAJA,MAAA;EAIK;EAFL,MAAA;EAU6B;EAR7B,KAAA;AAAA;;;;;;UAQgB,aAAA;EAChB,eAAA;EACA,YAAA;EACA,WAAA;AAAA;;;;;;;;;;;AA0CD;;KA3BY,cAAA;EA2BS,+CAxBlB,OAAA,UA+BS;EA7BT,QAAA;EAEA,cAAA,WA2BwB;EAzBxB,UAAA;AAAA;4DAIA,UAAA,EAAY,UAAA,EA4BS;EA1BrB,OAAA,UAiC4B;EA/B5B,QAAA,UAgCgB;EA9BhB,cAAA;AAAA;;;;AAuCH;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