@mcp-elements/core 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/LICENSE +21 -0
- package/dist/index.d.ts +535 -0
- package/dist/index.js +887 -0
- package/dist/index.js.map +1 -0
- package/package.json +27 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mayur Rawte
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,535 @@
|
|
|
1
|
+
declare function cn(...inputs: (string | undefined | null | false)[]): string;
|
|
2
|
+
|
|
3
|
+
declare function getFocusableElements(container: HTMLElement): HTMLElement[];
|
|
4
|
+
declare function trapFocus(container: HTMLElement, event: KeyboardEvent): void;
|
|
5
|
+
declare function createClickOutsideHandler(element: HTMLElement, callback: () => void): () => void;
|
|
6
|
+
declare function lockScroll(): () => void;
|
|
7
|
+
|
|
8
|
+
declare const Keys: {
|
|
9
|
+
readonly Enter: "Enter";
|
|
10
|
+
readonly Space: " ";
|
|
11
|
+
readonly Escape: "Escape";
|
|
12
|
+
readonly ArrowUp: "ArrowUp";
|
|
13
|
+
readonly ArrowDown: "ArrowDown";
|
|
14
|
+
readonly ArrowLeft: "ArrowLeft";
|
|
15
|
+
readonly ArrowRight: "ArrowRight";
|
|
16
|
+
readonly Home: "Home";
|
|
17
|
+
readonly End: "End";
|
|
18
|
+
readonly Tab: "Tab";
|
|
19
|
+
};
|
|
20
|
+
type KeyboardDirection = 'horizontal' | 'vertical' | 'both';
|
|
21
|
+
declare function getNextIndex(current: number, total: number, direction: 'next' | 'prev', loop?: boolean): number;
|
|
22
|
+
declare function handleArrowNavigation(event: KeyboardEvent, currentIndex: number, totalItems: number, orientation: KeyboardDirection, onIndexChange: (index: number) => void, loop?: boolean): void;
|
|
23
|
+
|
|
24
|
+
interface DialogConfig {
|
|
25
|
+
modal?: boolean;
|
|
26
|
+
onOpenChange?: (open: boolean) => void;
|
|
27
|
+
}
|
|
28
|
+
declare function createDialog(config?: DialogConfig): {
|
|
29
|
+
id: string;
|
|
30
|
+
getTriggerProps: (isOpen: boolean) => {
|
|
31
|
+
'aria-haspopup': "dialog";
|
|
32
|
+
'aria-expanded': boolean;
|
|
33
|
+
onClick: () => void | undefined;
|
|
34
|
+
};
|
|
35
|
+
getContentProps: (isOpen: boolean) => {
|
|
36
|
+
role: "dialog";
|
|
37
|
+
'aria-modal': boolean;
|
|
38
|
+
'aria-labelledby': string;
|
|
39
|
+
'aria-describedby': string;
|
|
40
|
+
hidden: boolean | undefined;
|
|
41
|
+
onKeyDown: (e: KeyboardEvent) => void;
|
|
42
|
+
};
|
|
43
|
+
getOverlayProps: () => {
|
|
44
|
+
'aria-hidden': true;
|
|
45
|
+
onClick: () => void | undefined;
|
|
46
|
+
};
|
|
47
|
+
getCloseProps: () => {
|
|
48
|
+
'aria-label': string;
|
|
49
|
+
onClick: () => void | undefined;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
interface TabsConfig {
|
|
54
|
+
defaultValue?: string;
|
|
55
|
+
onValueChange?: (value: string) => void;
|
|
56
|
+
}
|
|
57
|
+
interface TabItem {
|
|
58
|
+
value: string;
|
|
59
|
+
disabled?: boolean;
|
|
60
|
+
}
|
|
61
|
+
declare function createTabs(items: TabItem[], config?: TabsConfig): {
|
|
62
|
+
getListProps: () => {
|
|
63
|
+
role: "tablist";
|
|
64
|
+
};
|
|
65
|
+
getTriggerProps: (value: string, activeValue: string) => {
|
|
66
|
+
role: "tab";
|
|
67
|
+
'aria-selected': boolean;
|
|
68
|
+
'aria-controls': string;
|
|
69
|
+
id: string;
|
|
70
|
+
tabIndex: number;
|
|
71
|
+
disabled: boolean;
|
|
72
|
+
onClick: () => void;
|
|
73
|
+
onKeyDown: (e: KeyboardEvent) => void;
|
|
74
|
+
};
|
|
75
|
+
getPanelProps: (value: string, activeValue: string) => {
|
|
76
|
+
role: "tabpanel";
|
|
77
|
+
id: string;
|
|
78
|
+
'aria-labelledby': string;
|
|
79
|
+
hidden: true | undefined;
|
|
80
|
+
tabIndex: number;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
interface AccordionConfig {
|
|
85
|
+
type?: 'single' | 'multiple';
|
|
86
|
+
collapsible?: boolean;
|
|
87
|
+
onValueChange?: (value: string[]) => void;
|
|
88
|
+
}
|
|
89
|
+
interface AccordionItemConfig {
|
|
90
|
+
value: string;
|
|
91
|
+
disabled?: boolean;
|
|
92
|
+
}
|
|
93
|
+
declare function createAccordion(items: AccordionItemConfig[], config?: AccordionConfig): {
|
|
94
|
+
getItemProps: (value: string) => {
|
|
95
|
+
'data-value': string;
|
|
96
|
+
};
|
|
97
|
+
getTriggerProps: (value: string, expandedValues: string[]) => {
|
|
98
|
+
'aria-expanded': boolean;
|
|
99
|
+
'aria-controls': string;
|
|
100
|
+
id: string;
|
|
101
|
+
disabled: boolean;
|
|
102
|
+
onClick: () => void;
|
|
103
|
+
onKeyDown: (e: KeyboardEvent) => void;
|
|
104
|
+
};
|
|
105
|
+
getContentProps: (value: string, expandedValues: string[]) => {
|
|
106
|
+
role: "region";
|
|
107
|
+
id: string;
|
|
108
|
+
'aria-labelledby': string;
|
|
109
|
+
hidden: boolean | undefined;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
interface SelectConfig {
|
|
114
|
+
onValueChange?: (value: string) => void;
|
|
115
|
+
onOpenChange?: (open: boolean) => void;
|
|
116
|
+
}
|
|
117
|
+
interface SelectOption {
|
|
118
|
+
value: string;
|
|
119
|
+
label: string;
|
|
120
|
+
disabled?: boolean;
|
|
121
|
+
}
|
|
122
|
+
declare function createSelect(options: SelectOption[], config?: SelectConfig): {
|
|
123
|
+
getTriggerProps: (isOpen: boolean, selectedValue: string | null, highlightedIndex?: number) => {
|
|
124
|
+
role: "combobox";
|
|
125
|
+
'aria-expanded': boolean;
|
|
126
|
+
'aria-haspopup': "listbox";
|
|
127
|
+
'aria-label': string;
|
|
128
|
+
'aria-activedescendant': string | undefined;
|
|
129
|
+
onClick: () => void | undefined;
|
|
130
|
+
onKeyDown: (e: KeyboardEvent) => void;
|
|
131
|
+
};
|
|
132
|
+
getListProps: () => {
|
|
133
|
+
role: "listbox";
|
|
134
|
+
};
|
|
135
|
+
getOptionProps: (option: SelectOption, isHighlighted: boolean, selectedValue: string | null, _highlightedIndex: number) => {
|
|
136
|
+
role: "option";
|
|
137
|
+
'aria-selected': boolean;
|
|
138
|
+
'aria-disabled': true | undefined;
|
|
139
|
+
'data-highlighted': true | undefined;
|
|
140
|
+
id: string;
|
|
141
|
+
onClick: () => void;
|
|
142
|
+
};
|
|
143
|
+
getContentProps: (isOpen: boolean) => {
|
|
144
|
+
hidden: boolean | undefined;
|
|
145
|
+
};
|
|
146
|
+
handleKeyDown: (e: KeyboardEvent, isOpen: boolean, highlightedIndex: number, onHighlightChange: (index: number) => void) => void;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
interface TooltipConfig {
|
|
150
|
+
delay?: number;
|
|
151
|
+
onOpenChange?: (open: boolean) => void;
|
|
152
|
+
}
|
|
153
|
+
declare function createTooltip(config?: TooltipConfig): {
|
|
154
|
+
getTriggerProps: () => {
|
|
155
|
+
'aria-describedby': string;
|
|
156
|
+
onMouseEnter: () => void;
|
|
157
|
+
onMouseLeave: () => void;
|
|
158
|
+
onFocus: () => void;
|
|
159
|
+
onBlur: () => void;
|
|
160
|
+
};
|
|
161
|
+
getContentProps: (isOpen: boolean) => {
|
|
162
|
+
id: string;
|
|
163
|
+
role: "tooltip";
|
|
164
|
+
hidden: boolean | undefined;
|
|
165
|
+
};
|
|
166
|
+
destroy: () => void;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
interface PopoverConfig {
|
|
170
|
+
onOpenChange?: (open: boolean) => void;
|
|
171
|
+
}
|
|
172
|
+
declare function createPopover(config?: PopoverConfig): {
|
|
173
|
+
getTriggerProps: (isOpen: boolean) => {
|
|
174
|
+
'aria-haspopup': true;
|
|
175
|
+
'aria-expanded': boolean;
|
|
176
|
+
onClick: () => void | undefined;
|
|
177
|
+
};
|
|
178
|
+
getContentProps: (isOpen: boolean) => {
|
|
179
|
+
role: "dialog";
|
|
180
|
+
hidden: true | undefined;
|
|
181
|
+
onKeyDown: (e: KeyboardEvent) => void;
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
interface ToastConfig {
|
|
186
|
+
duration?: number;
|
|
187
|
+
}
|
|
188
|
+
interface Toast {
|
|
189
|
+
id: string;
|
|
190
|
+
title?: string;
|
|
191
|
+
description?: string;
|
|
192
|
+
variant?: 'default' | 'destructive' | 'success';
|
|
193
|
+
duration?: number;
|
|
194
|
+
action?: {
|
|
195
|
+
label: string;
|
|
196
|
+
onClick: () => void;
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
interface ToastState {
|
|
200
|
+
toasts: Toast[];
|
|
201
|
+
}
|
|
202
|
+
declare function createToastManager(config?: ToastConfig): {
|
|
203
|
+
addToast: (toast: Omit<Toast, "id">) => string;
|
|
204
|
+
removeToast: (id: string) => void;
|
|
205
|
+
subscribe: (listener: (state: ToastState) => void) => () => void;
|
|
206
|
+
getState: () => ToastState;
|
|
207
|
+
};
|
|
208
|
+
declare const toast: {
|
|
209
|
+
default: (title: string, description?: string) => string;
|
|
210
|
+
success: (title: string, description?: string) => string;
|
|
211
|
+
destructive: (title: string, description?: string) => string;
|
|
212
|
+
custom: (t: Omit<Toast, "id">) => string;
|
|
213
|
+
dismiss: (id: string) => void;
|
|
214
|
+
subscribe: (listener: (state: ToastState) => void) => () => void;
|
|
215
|
+
getState: () => ToastState;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
interface DrawerConfig {
|
|
219
|
+
side?: 'left' | 'right' | 'top' | 'bottom';
|
|
220
|
+
onOpenChange?: (open: boolean) => void;
|
|
221
|
+
}
|
|
222
|
+
declare function createDrawer(config?: DrawerConfig): {
|
|
223
|
+
getOverlayProps: () => {
|
|
224
|
+
'aria-hidden': true;
|
|
225
|
+
onClick: () => void | undefined;
|
|
226
|
+
};
|
|
227
|
+
getContentProps: (isOpen: boolean) => {
|
|
228
|
+
role: "dialog";
|
|
229
|
+
'aria-modal': boolean;
|
|
230
|
+
hidden: boolean | undefined;
|
|
231
|
+
onKeyDown: (e: KeyboardEvent) => void;
|
|
232
|
+
};
|
|
233
|
+
getCloseProps: () => {
|
|
234
|
+
'aria-label': string;
|
|
235
|
+
onClick: () => void | undefined;
|
|
236
|
+
};
|
|
237
|
+
side: "left" | "right" | "top" | "bottom";
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
interface DropdownMenuConfig {
|
|
241
|
+
onOpenChange?: (open: boolean) => void;
|
|
242
|
+
}
|
|
243
|
+
interface DropdownMenuItem {
|
|
244
|
+
id: string;
|
|
245
|
+
label: string;
|
|
246
|
+
disabled?: boolean;
|
|
247
|
+
type?: 'item' | 'separator' | 'label';
|
|
248
|
+
shortcut?: string;
|
|
249
|
+
onSelect?: () => void;
|
|
250
|
+
}
|
|
251
|
+
declare function createDropdownMenu(items: DropdownMenuItem[], config?: DropdownMenuConfig): {
|
|
252
|
+
getTriggerProps: (isOpen: boolean) => {
|
|
253
|
+
'aria-haspopup': "menu";
|
|
254
|
+
'aria-expanded': boolean;
|
|
255
|
+
onClick: () => void | undefined;
|
|
256
|
+
};
|
|
257
|
+
getContentProps: (isOpen: boolean) => {
|
|
258
|
+
role: "menu";
|
|
259
|
+
hidden: true | undefined;
|
|
260
|
+
};
|
|
261
|
+
getItemProps: (item: DropdownMenuItem, isHighlighted: boolean) => {
|
|
262
|
+
role: "menuitem";
|
|
263
|
+
'aria-disabled': true | undefined;
|
|
264
|
+
'data-highlighted': true | undefined;
|
|
265
|
+
tabIndex: number;
|
|
266
|
+
onClick: () => void;
|
|
267
|
+
};
|
|
268
|
+
handleKeyDown: (e: KeyboardEvent, isOpen: boolean, highlightedIndex: number, onHighlightChange: (index: number) => void) => void;
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
interface SwitchConfig {
|
|
272
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
273
|
+
}
|
|
274
|
+
declare function createSwitch(config?: SwitchConfig): {
|
|
275
|
+
getSwitchProps: (checked: boolean, disabled?: boolean) => {
|
|
276
|
+
role: "switch";
|
|
277
|
+
'aria-checked': boolean;
|
|
278
|
+
'aria-disabled': true | undefined;
|
|
279
|
+
tabIndex: number;
|
|
280
|
+
onClick: () => void;
|
|
281
|
+
onKeyDown: (e: KeyboardEvent) => void;
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
interface BaseMetadata {
|
|
286
|
+
name: string;
|
|
287
|
+
title?: string;
|
|
288
|
+
}
|
|
289
|
+
interface Icons {
|
|
290
|
+
icons?: Array<{
|
|
291
|
+
src: string;
|
|
292
|
+
mimeType?: string;
|
|
293
|
+
sizes?: string[];
|
|
294
|
+
theme?: 'light' | 'dark';
|
|
295
|
+
}>;
|
|
296
|
+
}
|
|
297
|
+
interface Implementation extends BaseMetadata, Icons {
|
|
298
|
+
version: string;
|
|
299
|
+
description?: string;
|
|
300
|
+
websiteUrl?: string;
|
|
301
|
+
}
|
|
302
|
+
interface ServerCapabilities {
|
|
303
|
+
experimental?: Record<string, object>;
|
|
304
|
+
logging?: object;
|
|
305
|
+
completions?: object;
|
|
306
|
+
prompts?: {
|
|
307
|
+
listChanged?: boolean;
|
|
308
|
+
};
|
|
309
|
+
resources?: {
|
|
310
|
+
subscribe?: boolean;
|
|
311
|
+
listChanged?: boolean;
|
|
312
|
+
};
|
|
313
|
+
tools?: {
|
|
314
|
+
listChanged?: boolean;
|
|
315
|
+
};
|
|
316
|
+
tasks?: {
|
|
317
|
+
list?: object;
|
|
318
|
+
cancel?: object;
|
|
319
|
+
requests?: {
|
|
320
|
+
tools?: {
|
|
321
|
+
call?: object;
|
|
322
|
+
};
|
|
323
|
+
};
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
interface JsonSchema {
|
|
327
|
+
$schema?: string;
|
|
328
|
+
type: 'object' | 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'null';
|
|
329
|
+
properties?: Record<string, JsonSchema>;
|
|
330
|
+
required?: string[];
|
|
331
|
+
additionalProperties?: boolean;
|
|
332
|
+
description?: string;
|
|
333
|
+
title?: string;
|
|
334
|
+
format?: string;
|
|
335
|
+
enum?: unknown[];
|
|
336
|
+
default?: unknown;
|
|
337
|
+
minimum?: number;
|
|
338
|
+
maximum?: number;
|
|
339
|
+
minLength?: number;
|
|
340
|
+
maxLength?: number;
|
|
341
|
+
pattern?: string;
|
|
342
|
+
items?: JsonSchema;
|
|
343
|
+
}
|
|
344
|
+
interface Tool extends BaseMetadata, Icons {
|
|
345
|
+
description?: string;
|
|
346
|
+
inputSchema: JsonSchema & {
|
|
347
|
+
type: 'object';
|
|
348
|
+
};
|
|
349
|
+
outputSchema?: JsonSchema & {
|
|
350
|
+
type: 'object';
|
|
351
|
+
};
|
|
352
|
+
annotations?: {
|
|
353
|
+
title?: string;
|
|
354
|
+
readOnlyHint?: boolean;
|
|
355
|
+
destructiveHint?: boolean;
|
|
356
|
+
idempotentHint?: boolean;
|
|
357
|
+
openWorldHint?: boolean;
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
interface Resource extends BaseMetadata, Icons {
|
|
361
|
+
uri: string;
|
|
362
|
+
mimeType?: string;
|
|
363
|
+
description?: string;
|
|
364
|
+
size?: number;
|
|
365
|
+
}
|
|
366
|
+
interface Prompt extends BaseMetadata, Icons {
|
|
367
|
+
description?: string;
|
|
368
|
+
arguments?: Array<{
|
|
369
|
+
name: string;
|
|
370
|
+
description?: string;
|
|
371
|
+
required?: boolean;
|
|
372
|
+
}>;
|
|
373
|
+
}
|
|
374
|
+
type ContentBlock = {
|
|
375
|
+
type: 'text';
|
|
376
|
+
text: string;
|
|
377
|
+
} | {
|
|
378
|
+
type: 'image';
|
|
379
|
+
data: string;
|
|
380
|
+
mimeType: string;
|
|
381
|
+
} | {
|
|
382
|
+
type: 'audio';
|
|
383
|
+
data: string;
|
|
384
|
+
mimeType: string;
|
|
385
|
+
} | {
|
|
386
|
+
type: 'resource';
|
|
387
|
+
resource: Resource & {
|
|
388
|
+
text?: string;
|
|
389
|
+
blob?: string;
|
|
390
|
+
};
|
|
391
|
+
};
|
|
392
|
+
interface CallToolResult {
|
|
393
|
+
content: ContentBlock[];
|
|
394
|
+
isError?: boolean;
|
|
395
|
+
structuredContent?: Record<string, unknown>;
|
|
396
|
+
}
|
|
397
|
+
interface UiResource {
|
|
398
|
+
uri: string;
|
|
399
|
+
mimeType: string;
|
|
400
|
+
content: string;
|
|
401
|
+
metadata?: Record<string, unknown>;
|
|
402
|
+
}
|
|
403
|
+
type ToolCallStatus = 'idle' | 'pending' | 'running' | 'done' | 'error' | 'cancelled';
|
|
404
|
+
interface ScopeDescriptor {
|
|
405
|
+
raw: string;
|
|
406
|
+
resource: string;
|
|
407
|
+
permissions: string[];
|
|
408
|
+
description?: string;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
declare function parseScope(raw: string): ScopeDescriptor;
|
|
412
|
+
declare function parseScopes(scopeString: string): ScopeDescriptor[];
|
|
413
|
+
|
|
414
|
+
interface ToolStateSnapshot {
|
|
415
|
+
status: ToolCallStatus;
|
|
416
|
+
tool?: string;
|
|
417
|
+
args?: Record<string, unknown>;
|
|
418
|
+
result?: CallToolResult;
|
|
419
|
+
error?: Error;
|
|
420
|
+
startedAt?: number;
|
|
421
|
+
endedAt?: number;
|
|
422
|
+
}
|
|
423
|
+
interface ToolStateApi extends Readonly<ToolStateSnapshot> {
|
|
424
|
+
start(input: {
|
|
425
|
+
tool: string;
|
|
426
|
+
args: Record<string, unknown>;
|
|
427
|
+
}): void;
|
|
428
|
+
markRunning(): void;
|
|
429
|
+
markDone(result: CallToolResult): void;
|
|
430
|
+
markError(error: Error): void;
|
|
431
|
+
cancel(): void;
|
|
432
|
+
reset(): void;
|
|
433
|
+
subscribe(fn: (snapshot: ToolStateSnapshot) => void): () => void;
|
|
434
|
+
}
|
|
435
|
+
declare function createToolState(): ToolStateApi;
|
|
436
|
+
|
|
437
|
+
type FieldKind = 'text' | 'textarea' | 'email' | 'url' | 'date' | 'number' | 'switch' | 'select' | 'multiselect' | 'unknown';
|
|
438
|
+
interface FieldDescriptor {
|
|
439
|
+
key: string;
|
|
440
|
+
kind: FieldKind;
|
|
441
|
+
label: string;
|
|
442
|
+
help?: string;
|
|
443
|
+
required: boolean;
|
|
444
|
+
defaultValue?: unknown;
|
|
445
|
+
options?: Array<{
|
|
446
|
+
value: string;
|
|
447
|
+
label: string;
|
|
448
|
+
}>;
|
|
449
|
+
min?: number;
|
|
450
|
+
max?: number;
|
|
451
|
+
minLength?: number;
|
|
452
|
+
maxLength?: number;
|
|
453
|
+
pattern?: string;
|
|
454
|
+
}
|
|
455
|
+
declare function schemaToFields(schema: JsonSchema): FieldDescriptor[];
|
|
456
|
+
|
|
457
|
+
interface PkcePair {
|
|
458
|
+
codeVerifier: string;
|
|
459
|
+
codeChallenge: string;
|
|
460
|
+
codeChallengeMethod: 'S256';
|
|
461
|
+
}
|
|
462
|
+
declare function generatePkcePair(): Promise<PkcePair>;
|
|
463
|
+
interface AuthUrlInput {
|
|
464
|
+
authorizationEndpoint: string;
|
|
465
|
+
clientId: string;
|
|
466
|
+
redirectUri: string;
|
|
467
|
+
scope: string;
|
|
468
|
+
codeChallenge: string;
|
|
469
|
+
state: string;
|
|
470
|
+
resource?: string;
|
|
471
|
+
}
|
|
472
|
+
declare function buildAuthUrl(input: AuthUrlInput): string;
|
|
473
|
+
interface TokenExchangeInput {
|
|
474
|
+
clientId: string;
|
|
475
|
+
code: string;
|
|
476
|
+
redirectUri: string;
|
|
477
|
+
codeVerifier: string;
|
|
478
|
+
}
|
|
479
|
+
declare function buildTokenExchangeBody(input: TokenExchangeInput): string;
|
|
480
|
+
interface TokenRefreshInput {
|
|
481
|
+
clientId: string;
|
|
482
|
+
refreshToken: string;
|
|
483
|
+
scope?: string;
|
|
484
|
+
}
|
|
485
|
+
declare function buildTokenRefreshBody(input: TokenRefreshInput): string;
|
|
486
|
+
type OAuthStatus = 'idle' | 'authorizing' | 'authorized' | 'denied' | 'error';
|
|
487
|
+
interface OAuthTokens {
|
|
488
|
+
accessToken: string;
|
|
489
|
+
tokenType: string;
|
|
490
|
+
expiresIn?: number;
|
|
491
|
+
refreshToken?: string;
|
|
492
|
+
scope?: string;
|
|
493
|
+
}
|
|
494
|
+
interface OAuthFlowSnapshot {
|
|
495
|
+
status: OAuthStatus;
|
|
496
|
+
verifier?: string;
|
|
497
|
+
state?: string;
|
|
498
|
+
tokens?: OAuthTokens;
|
|
499
|
+
error?: {
|
|
500
|
+
code: string;
|
|
501
|
+
message?: string;
|
|
502
|
+
originalError?: Error;
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
interface OAuthFlowApi extends Readonly<OAuthFlowSnapshot> {
|
|
506
|
+
start(input: {
|
|
507
|
+
verifier: string;
|
|
508
|
+
state: string;
|
|
509
|
+
}): void;
|
|
510
|
+
markAuthorized(tokens: OAuthTokens): void;
|
|
511
|
+
markDenied(code: string, message?: string): void;
|
|
512
|
+
markError(error: Error): void;
|
|
513
|
+
reset(): void;
|
|
514
|
+
subscribe(fn: (s: OAuthFlowSnapshot) => void): () => void;
|
|
515
|
+
}
|
|
516
|
+
declare function createOAuthFlow(): OAuthFlowApi;
|
|
517
|
+
|
|
518
|
+
interface AppMessageEnvelope {
|
|
519
|
+
id: string;
|
|
520
|
+
type: string;
|
|
521
|
+
payload?: unknown;
|
|
522
|
+
}
|
|
523
|
+
declare function encodeEnvelope(env: AppMessageEnvelope): AppMessageEnvelope;
|
|
524
|
+
declare function decodeEnvelope(raw: unknown): AppMessageEnvelope | null;
|
|
525
|
+
interface AppBridgeConfig {
|
|
526
|
+
postMessage: (env: AppMessageEnvelope) => void;
|
|
527
|
+
}
|
|
528
|
+
interface AppBridge {
|
|
529
|
+
send(env: AppMessageEnvelope): void;
|
|
530
|
+
receive(raw: unknown): void;
|
|
531
|
+
onMessage(fn: (env: AppMessageEnvelope) => void): () => void;
|
|
532
|
+
}
|
|
533
|
+
declare function createAppBridge(config: AppBridgeConfig): AppBridge;
|
|
534
|
+
|
|
535
|
+
export { type AccordionConfig, type AccordionItemConfig, type AppBridge, type AppBridgeConfig, type AppMessageEnvelope, type AuthUrlInput, type BaseMetadata, type CallToolResult, type ContentBlock, type DialogConfig, type DrawerConfig, type DropdownMenuConfig, type DropdownMenuItem, type FieldDescriptor, type FieldKind, type Icons, type Implementation, type JsonSchema, type KeyboardDirection, Keys, type OAuthFlowApi, type OAuthFlowSnapshot, type OAuthStatus, type OAuthTokens, type PkcePair, type PopoverConfig, type Prompt, type Resource, type ScopeDescriptor, type SelectConfig, type SelectOption, type ServerCapabilities, type SwitchConfig, type TabItem, type TabsConfig, type Toast, type ToastConfig, type ToastState, type TokenExchangeInput, type TokenRefreshInput, type Tool, type ToolCallStatus, type ToolStateApi, type ToolStateSnapshot, type TooltipConfig, type UiResource, buildAuthUrl, buildTokenExchangeBody, buildTokenRefreshBody, cn, createAccordion, createAppBridge, createClickOutsideHandler, createDialog, createDrawer, createDropdownMenu, createOAuthFlow, createPopover, createSelect, createSwitch, createTabs, createToastManager, createToolState, createTooltip, decodeEnvelope, encodeEnvelope, generatePkcePair, getFocusableElements, getNextIndex, handleArrowNavigation, lockScroll, parseScope, parseScopes, schemaToFields, toast, trapFocus };
|