@assistant-ui/react-mcp 0.0.22 → 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/dist/auth/createOAuthProvider.d.ts +1 -1
- package/dist/auth/createOAuthProvider.js.map +1 -1
- package/dist/auth/types.d.ts +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/mcp-scope.d.ts +32 -1
- package/dist/mcp-scope.d.ts.map +1 -1
- package/dist/primitives/elicitation/McpElicitationPrimitiveAccept.d.ts +13 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveAccept.d.ts.map +1 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveAccept.js +106 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveAccept.js.map +1 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveCancel.d.ts +13 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveCancel.d.ts.map +1 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveCancel.js +43 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveCancel.js.map +1 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveDecline.d.ts +13 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveDecline.d.ts.map +1 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveDecline.js +43 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveDecline.js.map +1 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveError.d.ts +13 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveError.d.ts.map +1 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveError.js +38 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveError.js.map +1 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveFields.d.ts +12 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveFields.d.ts.map +1 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveFields.js +53 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveFields.js.map +1 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveItems.d.ts +13 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveItems.d.ts.map +1 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveItems.js +96 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveItems.js.map +1 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveMessage.d.ts +13 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveMessage.d.ts.map +1 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveMessage.js +29 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveMessage.js.map +1 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveRoot.d.ts +13 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveRoot.d.ts.map +1 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveRoot.js +28 -0
- package/dist/primitives/elicitation/McpElicitationPrimitiveRoot.js.map +1 -0
- package/dist/primitives/elicitation/context.d.ts +21 -0
- package/dist/primitives/elicitation/context.d.ts.map +1 -0
- package/dist/primitives/elicitation/context.js +21 -0
- package/dist/primitives/elicitation/context.js.map +1 -0
- package/dist/primitives/elicitation/initialElicitationDraft.d.ts +5 -0
- package/dist/primitives/elicitation/initialElicitationDraft.d.ts.map +1 -0
- package/dist/primitives/elicitation/initialElicitationDraft.js +27 -0
- package/dist/primitives/elicitation/initialElicitationDraft.js.map +1 -0
- package/dist/primitives/elicitation/prepareElicitationContent.d.ts +9 -0
- package/dist/primitives/elicitation/prepareElicitationContent.d.ts.map +1 -0
- package/dist/primitives/elicitation/prepareElicitationContent.js +46 -0
- package/dist/primitives/elicitation/prepareElicitationContent.js.map +1 -0
- package/dist/primitives/elicitation.d.ts +15 -0
- package/dist/primitives/elicitation.d.ts.map +1 -0
- package/dist/primitives/elicitation.js +27 -0
- package/dist/primitives/elicitation.js.map +1 -0
- package/dist/resources/McpManagerResource.d.ts.map +1 -1
- package/dist/resources/McpManagerResource.js +17 -3
- package/dist/resources/McpManagerResource.js.map +1 -1
- package/dist/resources/McpServerResource.d.ts +4 -0
- package/dist/resources/McpServerResource.d.ts.map +1 -1
- package/dist/resources/McpServerResource.js +153 -42
- package/dist/resources/McpServerResource.js.map +1 -1
- package/dist/resources/storage/McpLocalStorage.js +1 -1
- package/dist/resources/storage/McpLocalStorage.js.map +1 -1
- package/dist/resources/validateElicitationContent.d.ts +9 -0
- package/dist/resources/validateElicitationContent.d.ts.map +1 -0
- package/dist/resources/validateElicitationContent.js +47 -0
- package/dist/resources/validateElicitationContent.js.map +1 -0
- package/package.json +7 -6
- package/src/auth/createOAuthProvider.ts +2 -2
- package/src/auth/types.ts +1 -1
- package/src/index.ts +4 -0
- package/src/mcp-scope.ts +32 -0
- package/src/primitives/elicitation/McpElicitationPrimitiveAccept.tsx +48 -0
- package/src/primitives/elicitation/McpElicitationPrimitiveCancel.tsx +37 -0
- package/src/primitives/elicitation/McpElicitationPrimitiveDecline.tsx +37 -0
- package/src/primitives/elicitation/McpElicitationPrimitiveError.tsx +31 -0
- package/src/primitives/elicitation/McpElicitationPrimitiveFields.tsx +56 -0
- package/src/primitives/elicitation/McpElicitationPrimitiveItems.tsx +58 -0
- package/src/primitives/elicitation/McpElicitationPrimitiveMessage.tsx +26 -0
- package/src/primitives/elicitation/McpElicitationPrimitiveRoot.tsx +24 -0
- package/src/primitives/elicitation/context.tsx +45 -0
- package/src/primitives/elicitation/initialElicitationDraft.test.ts +34 -0
- package/src/primitives/elicitation/initialElicitationDraft.ts +39 -0
- package/src/primitives/elicitation/prepareElicitationContent.test.ts +415 -0
- package/src/primitives/elicitation/prepareElicitationContent.ts +116 -0
- package/src/primitives/elicitation.ts +14 -0
- package/src/resources/McpManagerResource.test.ts +173 -3
- package/src/resources/McpManagerResource.ts +37 -3
- package/src/resources/McpServerResource.test.ts +735 -4
- package/src/resources/McpServerResource.ts +237 -29
- package/src/resources/storage/McpLocalStorage.ts +1 -1
- package/src/resources/validateElicitationContent.test.ts +123 -0
- package/src/resources/validateElicitationContent.ts +79 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { ElicitationContext, useMcpElicitation } from "./context.js";
|
|
2
|
+
import { initialElicitationDraft } from "./initialElicitationDraft.js";
|
|
3
|
+
import { useAuiState } from "@assistant-ui/store";
|
|
4
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
5
|
+
import { useState } from "@assistant-ui/tap/react-shim";
|
|
6
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
7
|
+
//#region src/primitives/elicitation/McpElicitationPrimitiveItems.tsx
|
|
8
|
+
const McpElicitationPrimitiveItem = (t0) => {
|
|
9
|
+
const $ = c(12);
|
|
10
|
+
const { elicitation, children } = t0;
|
|
11
|
+
let t1;
|
|
12
|
+
if ($[0] !== elicitation.requestedSchema) {
|
|
13
|
+
t1 = () => initialElicitationDraft(elicitation.requestedSchema);
|
|
14
|
+
$[0] = elicitation.requestedSchema;
|
|
15
|
+
$[1] = t1;
|
|
16
|
+
} else t1 = $[1];
|
|
17
|
+
const [draft, setDraft] = useState(t1);
|
|
18
|
+
let t2;
|
|
19
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
20
|
+
t2 = (name, value) => {
|
|
21
|
+
setDraft((current) => ({
|
|
22
|
+
...current,
|
|
23
|
+
[name]: value
|
|
24
|
+
}));
|
|
25
|
+
};
|
|
26
|
+
$[2] = t2;
|
|
27
|
+
} else t2 = $[2];
|
|
28
|
+
const setField = t2;
|
|
29
|
+
let t3;
|
|
30
|
+
if ($[3] !== draft || $[4] !== elicitation) {
|
|
31
|
+
t3 = {
|
|
32
|
+
elicitation,
|
|
33
|
+
draft,
|
|
34
|
+
setField
|
|
35
|
+
};
|
|
36
|
+
$[3] = draft;
|
|
37
|
+
$[4] = elicitation;
|
|
38
|
+
$[5] = t3;
|
|
39
|
+
} else t3 = $[5];
|
|
40
|
+
const context = t3;
|
|
41
|
+
let t4;
|
|
42
|
+
if ($[6] !== children || $[7] !== elicitation) {
|
|
43
|
+
t4 = typeof children === "function" ? children(elicitation) : children;
|
|
44
|
+
$[6] = children;
|
|
45
|
+
$[7] = elicitation;
|
|
46
|
+
$[8] = t4;
|
|
47
|
+
} else t4 = $[8];
|
|
48
|
+
let t5;
|
|
49
|
+
if ($[9] !== context || $[10] !== t4) {
|
|
50
|
+
t5 = /* @__PURE__ */ jsx(ElicitationContext.Provider, {
|
|
51
|
+
value: context,
|
|
52
|
+
children: t4
|
|
53
|
+
});
|
|
54
|
+
$[9] = context;
|
|
55
|
+
$[10] = t4;
|
|
56
|
+
$[11] = t5;
|
|
57
|
+
} else t5 = $[11];
|
|
58
|
+
return t5;
|
|
59
|
+
};
|
|
60
|
+
const McpElicitationPrimitiveItems = (t0) => {
|
|
61
|
+
const $ = c(7);
|
|
62
|
+
const { children } = t0;
|
|
63
|
+
const elicitations = useAuiState(_temp);
|
|
64
|
+
if (elicitations.length === 0) return null;
|
|
65
|
+
let t1;
|
|
66
|
+
if ($[0] !== children || $[1] !== elicitations) {
|
|
67
|
+
let t2;
|
|
68
|
+
if ($[3] !== children) {
|
|
69
|
+
t2 = (elicitation) => /* @__PURE__ */ jsx(McpElicitationPrimitiveItem, {
|
|
70
|
+
elicitation,
|
|
71
|
+
children
|
|
72
|
+
}, elicitation.id);
|
|
73
|
+
$[3] = children;
|
|
74
|
+
$[4] = t2;
|
|
75
|
+
} else t2 = $[4];
|
|
76
|
+
t1 = elicitations.map(t2);
|
|
77
|
+
$[0] = children;
|
|
78
|
+
$[1] = elicitations;
|
|
79
|
+
$[2] = t1;
|
|
80
|
+
} else t1 = $[2];
|
|
81
|
+
let t2;
|
|
82
|
+
if ($[5] !== t1) {
|
|
83
|
+
t2 = /* @__PURE__ */ jsx(Fragment, { children: t1 });
|
|
84
|
+
$[5] = t1;
|
|
85
|
+
$[6] = t2;
|
|
86
|
+
} else t2 = $[6];
|
|
87
|
+
return t2;
|
|
88
|
+
};
|
|
89
|
+
McpElicitationPrimitiveItems.displayName = "McpElicitationPrimitive.Items";
|
|
90
|
+
function _temp(state) {
|
|
91
|
+
return state.mcpServer.pendingElicitations;
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
export { McpElicitationPrimitiveItems, useMcpElicitation };
|
|
95
|
+
|
|
96
|
+
//# sourceMappingURL=McpElicitationPrimitiveItems.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpElicitationPrimitiveItems.js","names":["FC","ReactNode","useCallback","useMemo","useState","useAuiState","MCPElicitation","ElicitationContext","initialElicitationDraft","useMcpElicitation","McpElicitationPrimitiveItems","Props","children","elicitation","McpElicitationPrimitiveItem","t0","$","_c","t1","requestedSchema","draft","setDraft","t2","Symbol","for","name","value","current","setField","t3","context","t4","t5","elicitations","_temp","length","id","map","displayName","state","mcpServer","pendingElicitations"],"sources":["../../../src/primitives/elicitation/McpElicitationPrimitiveItems.tsx"],"sourcesContent":["import { type FC, type ReactNode, useCallback, useMemo, useState } from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport type { MCPElicitation } from \"../../mcp-scope\";\nimport { ElicitationContext } from \"./context\";\nimport { initialElicitationDraft } from \"./initialElicitationDraft\";\n\nexport { useMcpElicitation } from \"./context\";\n\nexport namespace McpElicitationPrimitiveItems {\n export type Props = {\n children: ReactNode | ((elicitation: MCPElicitation) => ReactNode);\n };\n}\n\nconst McpElicitationPrimitiveItem: FC<{\n elicitation: MCPElicitation;\n children: McpElicitationPrimitiveItems.Props[\"children\"];\n}> = ({ elicitation, children }) => {\n const [draft, setDraft] = useState<Record<string, unknown>>(() =>\n initialElicitationDraft(elicitation.requestedSchema),\n );\n const setField = useCallback((name: string, value: unknown) => {\n setDraft((current) => ({ ...current, [name]: value }));\n }, []);\n const context = useMemo(\n () => ({ elicitation, draft, setField }),\n [elicitation, draft, setField],\n );\n\n return (\n <ElicitationContext.Provider value={context}>\n {typeof children === \"function\" ? children(elicitation) : children}\n </ElicitationContext.Provider>\n );\n};\n\nexport const McpElicitationPrimitiveItems: FC<\n McpElicitationPrimitiveItems.Props\n> = ({ children }) => {\n const elicitations = useAuiState(\n (state) => state.mcpServer.pendingElicitations,\n );\n if (elicitations.length === 0) return null;\n return (\n <>\n {elicitations.map((elicitation) => (\n <McpElicitationPrimitiveItem\n key={elicitation.id}\n elicitation={elicitation}\n >\n {children}\n </McpElicitationPrimitiveItem>\n ))}\n </>\n );\n};\n\nMcpElicitationPrimitiveItems.displayName = \"McpElicitationPrimitive.Items\";\n"],"mappings":";;;;;;;AAcA,MAAMc,+BAGDC,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAC,MAAA,EAAAJ,aAAAD,aAAAG;CAAyB,IAAAG;CAAA,IAAAF,EAAA,OAAAH,YAAAM,iBAAA;EAC+BD,WAC1DV,wBAAwBK,YAAWM,eAAgB;EAACH,EAAA,KAAAH,YAAAM;EAAAH,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CADtD,MAAA,CAAAI,OAAAC,YAA0BjB,SAAkCc,EAE5D;CAAE,IAAAI;CAAA,IAAAN,EAAA,OAAAO,OAAAC,IAAA,2BAAA,GAAA;EAC2BF,MAAAG,MAAAC,UAAA;GAC3BL,UAASM,aAAc;IAAA,GAAKA;KAAUF,OAAOC;GAAM,EAAE;EAAC;EACvDV,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAFD,MAAAY,WAAiBN;CAEV,IAAAO;CAAA,IAAAb,EAAA,OAAAI,SAAAJ,EAAA,OAAAH,aAAA;EAEEgB,KAAA;GAAAhB;GAAAO;GAAAQ;EAA+B;EAACZ,EAAA,KAAAI;EAAAJ,EAAA,KAAAH;EAAAG,EAAA,KAAAa;CAAA,OAAAA,KAAAb,EAAA;CADzC,MAAAc,UACSD;CAEP,IAAAE;CAAA,IAAAf,EAAA,OAAAJ,YAAAI,EAAA,OAAAH,aAAA;EAIGkB,KAAA,OAAOnB,aAAa,aAAaA,SAASC,WAAsB,IAAhED;EAAiEI,EAAA,KAAAJ;EAAAI,EAAA,KAAAH;EAAAG,EAAA,KAAAe;CAAA,OAAAA,KAAAf,EAAA;CAAA,IAAAgB;CAAA,IAAAhB,EAAA,OAAAc,WAAAd,EAAA,QAAAe,IAAA;EADpEC,KAAA,oBAAA,mBAAA,UAAA;GAAoCF,OAAAA;GACjCC,UAAAA;EACH,CAAA;EAA8Bf,EAAA,KAAAc;EAAAd,EAAA,MAAAe;EAAAf,EAAA,MAAAgB;CAAA,OAAAA,KAAAhB,EAAA;CAAA,OAF9BgB;AAE8B;AAIlC,MAAatB,gCAETK,OAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAC,MAAA,EAAAL,aAAAG;CACH,MAAAkB,eAAqB5B,YACnB6B,KACF;CACA,IAAID,aAAYE,WAAY,GAAC,OAAS;CAAK,IAAAjB;CAAA,IAAAF,EAAA,OAAAJ,YAAAI,EAAA,OAAAiB,cAAA;EAAA,IAAAX;EAAA,IAAAN,EAAA,OAAAJ,UAAA;GAGrBU,MAAAT,gBAChB,oBAAC,6BAAD;IAEeA;IAEZD;GAJyB,GACrBC,YAAWuB,EADU;GAM7BpB,EAAA,KAAAJ;GAAAI,EAAA,KAAAM;EAAA,OAAAA,KAAAN,EAAA;EAPAE,KAAAe,aAAYI,IAAKf,EAOjB;EAACN,EAAA,KAAAJ;EAAAI,EAAA,KAAAiB;EAAAjB,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,IAAAM;CAAA,IAAAN,EAAA,OAAAE,IAAA;EARJI,KAAA,oBAAA,UAAA,EAAA,UACGJ,GAOC,CAAA;EACDF,EAAA,KAAAE;EAAAF,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAAA,OATHM;AASG;AAIPZ,6BAA6B4B,cAAc;AAnBvC,SAAAJ,MAAAK,OAAA;CAAA,OAEWA,MAAKC,UAAUC;AAAoB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ComponentRef } from "react";
|
|
2
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
3
|
+
//#region src/primitives/elicitation/McpElicitationPrimitiveMessage.d.ts
|
|
4
|
+
declare namespace McpElicitationPrimitiveMessage {
|
|
5
|
+
type Element = ComponentRef<typeof Primitive.span>;
|
|
6
|
+
type Props = ComponentPropsWithoutRef<typeof Primitive.span>;
|
|
7
|
+
}
|
|
8
|
+
declare const McpElicitationPrimitiveMessage: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement> & {
|
|
9
|
+
asChild?: boolean;
|
|
10
|
+
}, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { McpElicitationPrimitiveMessage };
|
|
13
|
+
//# sourceMappingURL=McpElicitationPrimitiveMessage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpElicitationPrimitiveMessage.d.ts","names":[],"sources":["../../../src/primitives/elicitation/McpElicitationPrimitiveMessage.tsx"],"mappings":";;;kBAQiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,gCAAgC,UAAU;;cAGnD,gDAA8B,0BAAA,qBAAA,gBAAA,mCAAA,eAAA;;4BAUzC,cAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useMcpElicitation } from "./context.js";
|
|
2
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
3
|
+
import { forwardRef } from "@assistant-ui/tap/react-shim";
|
|
4
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/primitives/elicitation/McpElicitationPrimitiveMessage.tsx
|
|
7
|
+
const McpElicitationPrimitiveMessage = forwardRef((props, ref) => {
|
|
8
|
+
const $ = c(4);
|
|
9
|
+
const elicitation = useMcpElicitation();
|
|
10
|
+
const t0 = props.children ?? elicitation.message;
|
|
11
|
+
let t1;
|
|
12
|
+
if ($[0] !== props || $[1] !== ref || $[2] !== t0) {
|
|
13
|
+
t1 = /* @__PURE__ */ jsx(Primitive.span, {
|
|
14
|
+
...props,
|
|
15
|
+
ref,
|
|
16
|
+
children: t0
|
|
17
|
+
});
|
|
18
|
+
$[0] = props;
|
|
19
|
+
$[1] = ref;
|
|
20
|
+
$[2] = t0;
|
|
21
|
+
$[3] = t1;
|
|
22
|
+
} else t1 = $[3];
|
|
23
|
+
return t1;
|
|
24
|
+
});
|
|
25
|
+
McpElicitationPrimitiveMessage.displayName = "McpElicitationPrimitive.Message";
|
|
26
|
+
//#endregion
|
|
27
|
+
export { McpElicitationPrimitiveMessage };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=McpElicitationPrimitiveMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpElicitationPrimitiveMessage.js","names":["ComponentPropsWithoutRef","ComponentRef","forwardRef","Primitive","useMcpElicitation","McpElicitationPrimitiveMessage","Element","span","Props","props","ref","$","_c","elicitation","t0","children","message","t1","displayName"],"sources":["../../../src/primitives/elicitation/McpElicitationPrimitiveMessage.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n} from \"react\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { useMcpElicitation } from \"./context\";\n\nexport namespace McpElicitationPrimitiveMessage {\n export type Element = ComponentRef<typeof Primitive.span>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.span>;\n}\n\nexport const McpElicitationPrimitiveMessage = forwardRef<\n McpElicitationPrimitiveMessage.Element,\n McpElicitationPrimitiveMessage.Props\n>((props, ref) => {\n const elicitation = useMcpElicitation();\n return (\n <Primitive.span {...props} ref={ref}>\n {props.children ?? elicitation.message}\n </Primitive.span>\n );\n});\n\nMcpElicitationPrimitiveMessage.displayName = \"McpElicitationPrimitive.Message\";\n"],"mappings":";;;;;;AAaA,MAAaK,iCAAiCH,YAG5CO,OAAAC,QAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CACA,MAAAC,cAAoBT,kBAAkB;CAGjC,MAAAU,KAAAL,MAAKM,YAAaF,YAAWG;CAAQ,IAAAC;CAAA,IAAAN,EAAA,OAAAF,SAAAE,EAAA,OAAAD,OAAAC,EAAA,OAAAG,IAAA;EADxCG,KAAA,oBAAA,UAAA,MAAA;GAAA,GAAoBR;GAAYC;GAC7BI,UAAAA;EACH,CAAA;EAAiBH,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAG;EAAAH,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAAA,OAFjBM;AAEiB,CAEpB;AAEDZ,+BAA+Ba,cAAc"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ComponentRef } from "react";
|
|
2
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
3
|
+
//#region src/primitives/elicitation/McpElicitationPrimitiveRoot.d.ts
|
|
4
|
+
declare namespace McpElicitationPrimitiveRoot {
|
|
5
|
+
type Element = ComponentRef<typeof Primitive.div>;
|
|
6
|
+
type Props = ComponentPropsWithoutRef<typeof Primitive.div>;
|
|
7
|
+
}
|
|
8
|
+
declare const McpElicitationPrimitiveRoot: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
9
|
+
asChild?: boolean;
|
|
10
|
+
}, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { McpElicitationPrimitiveRoot };
|
|
13
|
+
//# sourceMappingURL=McpElicitationPrimitiveRoot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpElicitationPrimitiveRoot.d.ts","names":[],"sources":["../../../src/primitives/elicitation/McpElicitationPrimitiveRoot.tsx"],"mappings":";;;kBAQiB;OACH,UAAU,oBAAoB,UAAU;OACxC,QAAQ,gCAAgC,UAAU;;cAGnD,6CAA2B,0BAAA,qBAAA,gBAAA,kCAAA,eAAA;;4BAQtC,cAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useMcpElicitation } from "./context.js";
|
|
2
|
+
import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
|
|
3
|
+
import { forwardRef } from "@assistant-ui/tap/react-shim";
|
|
4
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/primitives/elicitation/McpElicitationPrimitiveRoot.tsx
|
|
7
|
+
const McpElicitationPrimitiveRoot = forwardRef((props, ref) => {
|
|
8
|
+
const $ = c(4);
|
|
9
|
+
const elicitation = useMcpElicitation();
|
|
10
|
+
let t0;
|
|
11
|
+
if ($[0] !== elicitation.id || $[1] !== props || $[2] !== ref) {
|
|
12
|
+
t0 = /* @__PURE__ */ jsx(Primitive.div, {
|
|
13
|
+
...props,
|
|
14
|
+
ref,
|
|
15
|
+
"data-elicitation-id": elicitation.id
|
|
16
|
+
});
|
|
17
|
+
$[0] = elicitation.id;
|
|
18
|
+
$[1] = props;
|
|
19
|
+
$[2] = ref;
|
|
20
|
+
$[3] = t0;
|
|
21
|
+
} else t0 = $[3];
|
|
22
|
+
return t0;
|
|
23
|
+
});
|
|
24
|
+
McpElicitationPrimitiveRoot.displayName = "McpElicitationPrimitive.Root";
|
|
25
|
+
//#endregion
|
|
26
|
+
export { McpElicitationPrimitiveRoot };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=McpElicitationPrimitiveRoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpElicitationPrimitiveRoot.js","names":["ComponentPropsWithoutRef","ComponentRef","forwardRef","Primitive","useMcpElicitation","McpElicitationPrimitiveRoot","Element","div","Props","props","ref","$","_c","elicitation","t0","id","displayName"],"sources":["../../../src/primitives/elicitation/McpElicitationPrimitiveRoot.tsx"],"sourcesContent":["import {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n forwardRef,\n} from \"react\";\nimport { Primitive } from \"@radix-ui/react-primitive\";\nimport { useMcpElicitation } from \"./context\";\n\nexport namespace McpElicitationPrimitiveRoot {\n export type Element = ComponentRef<typeof Primitive.div>;\n export type Props = ComponentPropsWithoutRef<typeof Primitive.div>;\n}\n\nexport const McpElicitationPrimitiveRoot = forwardRef<\n McpElicitationPrimitiveRoot.Element,\n McpElicitationPrimitiveRoot.Props\n>((props, ref) => {\n const elicitation = useMcpElicitation();\n return (\n <Primitive.div {...props} ref={ref} data-elicitation-id={elicitation.id} />\n );\n});\n\nMcpElicitationPrimitiveRoot.displayName = \"McpElicitationPrimitive.Root\";\n"],"mappings":";;;;;;AAaA,MAAaK,8BAA8BH,YAGzCO,OAAAC,QAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CACA,MAAAC,cAAoBT,kBAAkB;CAAE,IAAAU;CAAA,IAAAH,EAAA,OAAAE,YAAAE,MAAAJ,EAAA,OAAAF,SAAAE,EAAA,OAAAD,KAAA;EAEtCI,KAAA,oBAAA,UAAA,KAAA;GAAA,GAAmBL;GAAYC;GAA0B,uBAAAG,YAAWE;EAAG,CAAA;EAAIJ,EAAA,KAAAE,YAAAE;EAAAJ,EAAA,KAAAF;EAAAE,EAAA,KAAAD;EAAAC,EAAA,KAAAG;CAAA,OAAAA,KAAAH,EAAA;CAAA,OAA3EG;AAA2E,CAE9E;AAEDT,4BAA4BW,cAAc"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { MCPElicitation } from "../../mcp-scope.js";
|
|
2
|
+
//#region src/primitives/elicitation/context.d.ts
|
|
3
|
+
type ElicitationContextValue = {
|
|
4
|
+
elicitation: MCPElicitation;
|
|
5
|
+
draft: Record<string, unknown>;
|
|
6
|
+
setField: (name: string, value: unknown) => void;
|
|
7
|
+
};
|
|
8
|
+
type ElicitationFieldContextValue = {
|
|
9
|
+
name: string;
|
|
10
|
+
schema: unknown;
|
|
11
|
+
value: unknown;
|
|
12
|
+
setValue: (value: unknown) => void;
|
|
13
|
+
};
|
|
14
|
+
declare const ElicitationContext: import("react").Context<ElicitationContextValue | null>;
|
|
15
|
+
declare const ElicitationFieldContext: import("react").Context<ElicitationFieldContextValue | null>;
|
|
16
|
+
declare const useElicitationContext: () => ElicitationContextValue;
|
|
17
|
+
declare const useMcpElicitation: () => MCPElicitation;
|
|
18
|
+
declare const useMcpElicitationField: () => ElicitationFieldContextValue;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { ElicitationContext, ElicitationContextValue, ElicitationFieldContext, ElicitationFieldContextValue, useElicitationContext, useMcpElicitation, useMcpElicitationField };
|
|
21
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","names":[],"sources":["../../../src/primitives/elicitation/context.tsx"],"mappings":";;KAGY;EACV,aAAa;EACb,OAAO;EACP,WAAW,cAAc;;KAGf;EACV;EACA;EACA;EACA,WAAW;;cAGA,oCAAkB,QAAA;cAIlB,yCAAuB,QAAA;cAGvB,6BAA4B;cAU5B,yBAAwB;cAGxB,8BAA6B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createContext, useContext } from "@assistant-ui/tap/react-shim";
|
|
2
|
+
//#region src/primitives/elicitation/context.tsx
|
|
3
|
+
const ElicitationContext = createContext(null);
|
|
4
|
+
const ElicitationFieldContext = createContext(null);
|
|
5
|
+
const useElicitationContext = () => {
|
|
6
|
+
const context = useContext(ElicitationContext);
|
|
7
|
+
if (!context) throw new Error("useMcpElicitation must be used inside <McpElicitationPrimitive.Items>");
|
|
8
|
+
return context;
|
|
9
|
+
};
|
|
10
|
+
const useMcpElicitation = () => {
|
|
11
|
+
return useElicitationContext().elicitation;
|
|
12
|
+
};
|
|
13
|
+
const useMcpElicitationField = () => {
|
|
14
|
+
const context = useContext(ElicitationFieldContext);
|
|
15
|
+
if (!context) throw new Error("useMcpElicitationField must be used inside <McpElicitationPrimitive.Fields>");
|
|
16
|
+
return context;
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { ElicitationContext, ElicitationFieldContext, useElicitationContext, useMcpElicitation, useMcpElicitationField };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","names":["createContext","useContext","MCPElicitation","ElicitationContextValue","elicitation","draft","Record","setField","name","value","ElicitationFieldContextValue","schema","setValue","ElicitationContext","ElicitationFieldContext","useElicitationContext","context","Error","useMcpElicitation","useMcpElicitationField"],"sources":["../../../src/primitives/elicitation/context.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { MCPElicitation } from \"../../mcp-scope\";\n\nexport type ElicitationContextValue = {\n elicitation: MCPElicitation;\n draft: Record<string, unknown>;\n setField: (name: string, value: unknown) => void;\n};\n\nexport type ElicitationFieldContextValue = {\n name: string;\n schema: unknown;\n value: unknown;\n setValue: (value: unknown) => void;\n};\n\nexport const ElicitationContext = createContext<ElicitationContextValue | null>(\n null,\n);\n\nexport const ElicitationFieldContext =\n createContext<ElicitationFieldContextValue | null>(null);\n\nexport const useElicitationContext = (): ElicitationContextValue => {\n const context = useContext(ElicitationContext);\n if (!context) {\n throw new Error(\n \"useMcpElicitation must be used inside <McpElicitationPrimitive.Items>\",\n );\n }\n return context;\n};\n\nexport const useMcpElicitation = (): MCPElicitation =>\n useElicitationContext().elicitation;\n\nexport const useMcpElicitationField = (): ElicitationFieldContextValue => {\n const context = useContext(ElicitationFieldContext);\n if (!context) {\n throw new Error(\n \"useMcpElicitationField must be used inside <McpElicitationPrimitive.Fields>\",\n );\n }\n return context;\n};\n"],"mappings":";;AAgBA,MAAaa,qBAAqBb,cAChC,IACF;AAEA,MAAac,0BACXd,cAAmD,IAAI;AAEzD,MAAae,8BAAwB;CACnC,MAAAC,UAAgBf,WAAWY,kBAAkB;CAC7C,IAAI,CAACG,SACH,MAAM,IAAIC,MACR,uEACF;CACD,OACMD;AAAO;AAGhB,MAAaE,0BAAoB;CAAA,OAC/BH,sBAAsB,CAAC,CAAAX;AAAY;AAErC,MAAae,+BAAyB;CACpC,MAAAH,UAAgBf,WAAWa,uBAAuB;CAClD,IAAI,CAACE,SACH,MAAM,IAAIC,MACR,6EACF;CACD,OACMD;AAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialElicitationDraft.d.ts","names":[],"sources":["../../../src/primitives/elicitation/initialElicitationDraft.ts"],"mappings":";cAqBa,0BACX,6BACC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/primitives/elicitation/initialElicitationDraft.ts
|
|
2
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3
|
+
const getOwn = (value, key) => Object.hasOwn(value, key) ? value[key] : void 0;
|
|
4
|
+
const matchesType = (type, value) => {
|
|
5
|
+
switch (type) {
|
|
6
|
+
case "string": return typeof value === "string";
|
|
7
|
+
case "number": return typeof value === "number";
|
|
8
|
+
case "integer": return typeof value === "number" && Number.isInteger(value);
|
|
9
|
+
case "boolean": return typeof value === "boolean";
|
|
10
|
+
default: return false;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const initialElicitationDraft = (requestedSchema) => {
|
|
14
|
+
if (!isRecord(requestedSchema)) return {};
|
|
15
|
+
const properties = getOwn(requestedSchema, "properties");
|
|
16
|
+
if (!isRecord(properties)) return {};
|
|
17
|
+
return Object.fromEntries(Object.keys(properties).flatMap((name) => {
|
|
18
|
+
const schema = properties[name];
|
|
19
|
+
if (!isRecord(schema) || !Object.hasOwn(schema, "default")) return [];
|
|
20
|
+
const value = schema.default;
|
|
21
|
+
return matchesType(getOwn(schema, "type"), value) ? [[name, value]] : [];
|
|
22
|
+
}));
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { initialElicitationDraft };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=initialElicitationDraft.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialElicitationDraft.js","names":["isRecord","value","Record","Array","isArray","getOwn","key","Object","hasOwn","undefined","matchesType","type","Number","isInteger","initialElicitationDraft","requestedSchema","properties","fromEntries","keys","flatMap","name","schema","default"],"sources":["../../../src/primitives/elicitation/initialElicitationDraft.ts"],"sourcesContent":["const isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst getOwn = (value: Record<string, unknown>, key: string): unknown =>\n Object.hasOwn(value, key) ? value[key] : undefined;\n\nconst matchesType = (type: unknown, value: unknown): boolean => {\n switch (type) {\n case \"string\":\n return typeof value === \"string\";\n case \"number\":\n return typeof value === \"number\";\n case \"integer\":\n return typeof value === \"number\" && Number.isInteger(value);\n case \"boolean\":\n return typeof value === \"boolean\";\n default:\n return false;\n }\n};\n\nexport const initialElicitationDraft = (\n requestedSchema: unknown,\n): Record<string, unknown> => {\n if (!isRecord(requestedSchema)) return {};\n\n const properties = getOwn(requestedSchema, \"properties\");\n if (!isRecord(properties)) return {};\n\n return Object.fromEntries(\n Object.keys(properties).flatMap((name) => {\n const schema = properties[name];\n if (!isRecord(schema) || !Object.hasOwn(schema, \"default\")) return [];\n\n const value = schema.default;\n return matchesType(getOwn(schema, \"type\"), value) ? [[name, value]] : [];\n }),\n );\n};\n"],"mappings":";AAAA,MAAMA,YAAYC,UAChB,OAAOA,UAAU,YAAYA,UAAU,QAAQ,CAACE,MAAMC,QAAQH,KAAK;AAErE,MAAMI,UAAUJ,OAAgCK,QAC9CC,OAAOC,OAAOP,OAAOK,GAAG,IAAIL,MAAMK,OAAOG,KAAAA;AAE3C,MAAMC,eAAeC,MAAeV,UAA4B;CAC9D,QAAQU,MAAR;EACE,KAAK,UACH,OAAO,OAAOV,UAAU;EAC1B,KAAK,UACH,OAAO,OAAOA,UAAU;EAC1B,KAAK,WACH,OAAO,OAAOA,UAAU,YAAYW,OAAOC,UAAUZ,KAAK;EAC5D,KAAK,WACH,OAAO,OAAOA,UAAU;EAC1B,SACE,OAAO;CACX;AACF;AAEA,MAAaa,2BACXC,oBAC4B;CAC5B,IAAI,CAACf,SAASe,eAAe,GAAG,OAAO,CAAC;CAExC,MAAMC,aAAaX,OAAOU,iBAAiB,YAAY;CACvD,IAAI,CAACf,SAASgB,UAAU,GAAG,OAAO,CAAC;CAEnC,OAAOT,OAAOU,YACZV,OAAOW,KAAKF,UAAU,CAAC,CAACG,SAASC,SAAS;EACxC,MAAMC,SAASL,WAAWI;EAC1B,IAAI,CAACpB,SAASqB,MAAM,KAAK,CAACd,OAAOC,OAAOa,QAAQ,SAAS,GAAG,OAAO,CAAA;EAEnE,MAAMpB,QAAQoB,OAAOC;EACrB,OAAOZ,YAAYL,OAAOgB,QAAQ,MAAM,GAAGpB,KAAK,IAAI,CAAC,CAACmB,MAAMnB,KAAK,CAAC,IAAI,CAAA;CACxE,CAAC,CACH;AACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/primitives/elicitation/prepareElicitationContent.d.ts
|
|
2
|
+
declare const prepareElicitationContent: (requestedSchema: unknown, draft: Record<string, unknown>) => {
|
|
3
|
+
content: Record<string, unknown>;
|
|
4
|
+
missingRequired: readonly string[];
|
|
5
|
+
invalid: readonly string[];
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { prepareElicitationContent };
|
|
9
|
+
//# sourceMappingURL=prepareElicitationContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareElicitationContent.d.ts","names":[],"sources":["../../../src/primitives/elicitation/prepareElicitationContent.ts"],"mappings":";cA4Ca,4BACX,0BACA,OAAO;EAEP,SAAS;EACT;EACA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { validateElicitationContent } from "../../resources/validateElicitationContent.js";
|
|
2
|
+
//#region src/primitives/elicitation/prepareElicitationContent.ts
|
|
3
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4
|
+
const coerceValue = (schema, value) => {
|
|
5
|
+
if (!isRecord(schema) || typeof value !== "string") return value;
|
|
6
|
+
if (schema.type !== "number" && schema.type !== "integer") return value;
|
|
7
|
+
const number = Number(value);
|
|
8
|
+
if (value.trim() === "") return value;
|
|
9
|
+
if (!Number.isFinite(number)) return value;
|
|
10
|
+
if (schema.type === "integer" && !Number.isInteger(number)) return value;
|
|
11
|
+
return number;
|
|
12
|
+
};
|
|
13
|
+
const isBooleanSchema = (schema) => isRecord(schema) && schema.type === "boolean";
|
|
14
|
+
const isNonStringTypedSchema = (schema) => schema.type === "boolean" || schema.type === "number" || schema.type === "integer";
|
|
15
|
+
const schemaAdmitsEmptyString = (schema) => {
|
|
16
|
+
if (!isRecord(schema) || isNonStringTypedSchema(schema)) return false;
|
|
17
|
+
const values = Object.hasOwn(schema, "enum") ? schema.enum : void 0;
|
|
18
|
+
if (Array.isArray(values)) return values.includes("");
|
|
19
|
+
return Object.hasOwn(schema, "default") && schema.default === "";
|
|
20
|
+
};
|
|
21
|
+
const isAbsentDraftValue = (schema, value) => value === void 0 || value === null || value === "" && !schemaAdmitsEmptyString(schema);
|
|
22
|
+
const prepareElicitationContent = (requestedSchema, draft) => {
|
|
23
|
+
const properties = isRecord(requestedSchema) && isRecord(requestedSchema.properties) ? requestedSchema.properties : {};
|
|
24
|
+
const candidateContent = Object.fromEntries(Object.entries(draft).flatMap(([name, value]) => {
|
|
25
|
+
const schema = properties[name];
|
|
26
|
+
if (isAbsentDraftValue(schema, value)) return [];
|
|
27
|
+
return [[name, coerceValue(schema, value)]];
|
|
28
|
+
}));
|
|
29
|
+
const missingRequiredBooleans = validateElicitationContent(requestedSchema, candidateContent).filter(({ property }) => isBooleanSchema(properties[property]) && !Object.hasOwn(candidateContent, property));
|
|
30
|
+
const contentWithBooleanDefaults = {
|
|
31
|
+
...candidateContent,
|
|
32
|
+
...Object.fromEntries(missingRequiredBooleans.map(({ property }) => [property, typeof properties[property].default === "boolean" ? properties[property].default : false]))
|
|
33
|
+
};
|
|
34
|
+
const validationErrors = validateElicitationContent(requestedSchema, contentWithBooleanDefaults);
|
|
35
|
+
const missingRequired = [...new Set(validationErrors.filter(({ property }) => !Object.hasOwn(contentWithBooleanDefaults, property)).map(({ property }) => property))];
|
|
36
|
+
const invalid = [...new Set(validationErrors.filter(({ property }) => Object.hasOwn(contentWithBooleanDefaults, property)).map(({ property }) => property))];
|
|
37
|
+
return {
|
|
38
|
+
content: Object.fromEntries(Object.entries(contentWithBooleanDefaults).filter(([property]) => !invalid.includes(property))),
|
|
39
|
+
missingRequired,
|
|
40
|
+
invalid
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
export { prepareElicitationContent };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=prepareElicitationContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareElicitationContent.js","names":["validateElicitationContent","isRecord","value","Record","Array","isArray","coerceValue","schema","type","number","Number","trim","isFinite","isInteger","isBooleanSchema","isNonStringTypedSchema","schemaAdmitsEmptyString","values","Object","hasOwn","enum","undefined","includes","default","isAbsentDraftValue","prepareElicitationContent","requestedSchema","draft","content","missingRequired","invalid","properties","candidateContent","fromEntries","entries","flatMap","name","missingRequiredBooleans","filter","property","contentWithBooleanDefaults","map","validationErrors","Set"],"sources":["../../../src/primitives/elicitation/prepareElicitationContent.ts"],"sourcesContent":["import { validateElicitationContent } from \"../../resources/validateElicitationContent\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst coerceValue = (schema: unknown, value: unknown): unknown => {\n if (!isRecord(schema) || typeof value !== \"string\") {\n return value;\n }\n if (schema.type !== \"number\" && schema.type !== \"integer\") {\n return value;\n }\n\n const number = Number(value);\n if (value.trim() === \"\") return value;\n if (!Number.isFinite(number)) return value;\n if (schema.type === \"integer\" && !Number.isInteger(number)) {\n return value;\n }\n return number;\n};\n\nconst isBooleanSchema = (schema: unknown): schema is Record<string, unknown> =>\n isRecord(schema) && schema.type === \"boolean\";\n\nconst isNonStringTypedSchema = (schema: Record<string, unknown>): boolean =>\n schema.type === \"boolean\" ||\n schema.type === \"number\" ||\n schema.type === \"integer\";\n\nconst schemaAdmitsEmptyString = (schema: unknown): boolean => {\n if (!isRecord(schema) || isNonStringTypedSchema(schema)) return false;\n\n const values = Object.hasOwn(schema, \"enum\") ? schema.enum : undefined;\n if (Array.isArray(values)) return values.includes(\"\");\n\n return Object.hasOwn(schema, \"default\") && schema.default === \"\";\n};\n\nconst isAbsentDraftValue = (schema: unknown, value: unknown) =>\n value === undefined ||\n value === null ||\n (value === \"\" && !schemaAdmitsEmptyString(schema));\n\nexport const prepareElicitationContent = (\n requestedSchema: unknown,\n draft: Record<string, unknown>,\n): {\n content: Record<string, unknown>;\n missingRequired: readonly string[];\n invalid: readonly string[];\n} => {\n const properties =\n isRecord(requestedSchema) && isRecord(requestedSchema.properties)\n ? requestedSchema.properties\n : {};\n const candidateContent = Object.fromEntries(\n Object.entries(draft).flatMap(([name, value]) => {\n const schema = properties[name];\n if (isAbsentDraftValue(schema, value)) return [];\n return [[name, coerceValue(schema, value)]];\n }),\n );\n const missingRequiredBooleans = validateElicitationContent(\n requestedSchema,\n candidateContent,\n ).filter(\n ({ property }) =>\n isBooleanSchema(properties[property]) &&\n !Object.hasOwn(candidateContent, property),\n );\n const contentWithBooleanDefaults = {\n ...candidateContent,\n ...Object.fromEntries(\n missingRequiredBooleans.map(({ property }) => [\n property,\n typeof properties[property].default === \"boolean\"\n ? properties[property].default\n : false,\n ]),\n ),\n };\n const validationErrors = validateElicitationContent(\n requestedSchema,\n contentWithBooleanDefaults,\n );\n const missingRequired = [\n ...new Set(\n validationErrors\n .filter(\n ({ property }) =>\n !Object.hasOwn(contentWithBooleanDefaults, property),\n )\n .map(({ property }) => property),\n ),\n ];\n const invalid = [\n ...new Set(\n validationErrors\n .filter(({ property }) =>\n Object.hasOwn(contentWithBooleanDefaults, property),\n )\n .map(({ property }) => property),\n ),\n ];\n\n return {\n content: Object.fromEntries(\n Object.entries(contentWithBooleanDefaults).filter(\n ([property]) => !invalid.includes(property),\n ),\n ),\n missingRequired,\n invalid,\n };\n};\n"],"mappings":";;AAEA,MAAMC,YAAYC,UAChB,OAAOA,UAAU,YAAYA,UAAU,QAAQ,CAACE,MAAMC,QAAQH,KAAK;AAErE,MAAMI,eAAeC,QAAiBL,UAA4B;CAChE,IAAI,CAACD,SAASM,MAAM,KAAK,OAAOL,UAAU,UACxC,OAAOA;CAET,IAAIK,OAAOC,SAAS,YAAYD,OAAOC,SAAS,WAC9C,OAAON;CAGT,MAAMO,SAASC,OAAOR,KAAK;CAC3B,IAAIA,MAAMS,KAAK,MAAM,IAAI,OAAOT;CAChC,IAAI,CAACQ,OAAOE,SAASH,MAAM,GAAG,OAAOP;CACrC,IAAIK,OAAOC,SAAS,aAAa,CAACE,OAAOG,UAAUJ,MAAM,GACvD,OAAOP;CAET,OAAOO;AACT;AAEA,MAAMK,mBAAmBP,WACvBN,SAASM,MAAM,KAAKA,OAAOC,SAAS;AAEtC,MAAMO,0BAA0BR,WAC9BA,OAAOC,SAAS,aAChBD,OAAOC,SAAS,YAChBD,OAAOC,SAAS;AAElB,MAAMQ,2BAA2BT,WAA6B;CAC5D,IAAI,CAACN,SAASM,MAAM,KAAKQ,uBAAuBR,MAAM,GAAG,OAAO;CAEhE,MAAMU,SAASC,OAAOC,OAAOZ,QAAQ,MAAM,IAAIA,OAAOa,OAAOC,KAAAA;CAC7D,IAAIjB,MAAMC,QAAQY,MAAM,GAAG,OAAOA,OAAOK,SAAS,EAAE;CAEpD,OAAOJ,OAAOC,OAAOZ,QAAQ,SAAS,KAAKA,OAAOgB,YAAY;AAChE;AAEA,MAAMC,sBAAsBjB,QAAiBL,UAC3CA,UAAUmB,KAAAA,KACVnB,UAAU,QACTA,UAAU,MAAM,CAACc,wBAAwBT,MAAM;AAElD,MAAakB,6BACXC,iBACAC,UAKG;CACH,MAAMI,aACJ9B,SAASyB,eAAe,KAAKzB,SAASyB,gBAAgBK,UAAU,IAC5DL,gBAAgBK,aAChB,CAAC;CACP,MAAMC,mBAAmBd,OAAOe,YAC9Bf,OAAOgB,QAAQP,KAAK,CAAC,CAACQ,SAAS,CAACC,MAAMlC,WAAW;EAC/C,MAAMK,SAASwB,WAAWK;EAC1B,IAAIZ,mBAAmBjB,QAAQL,KAAK,GAAG,OAAO,CAAA;EAC9C,OAAO,CAAC,CAACkC,MAAM9B,YAAYC,QAAQL,KAAK,CAAC,CAAC;CAC5C,CAAC,CACH;CACA,MAAMmC,0BAA0BrC,2BAC9B0B,iBACAM,gBACF,CAAC,CAACM,QACC,EAAEC,eACDzB,gBAAgBiB,WAAWQ,SAAS,KACpC,CAACrB,OAAOC,OAAOa,kBAAkBO,QAAQ,CAC7C;CACA,MAAMC,6BAA6B;EACjC,GAAGR;EACH,GAAGd,OAAOe,YACRI,wBAAwBI,KAAK,EAAEF,eAAe,CAC5CA,UACA,OAAOR,WAAWQ,SAAS,CAAChB,YAAY,YACpCQ,WAAWQ,SAAS,CAAChB,UACrB,KAAK,CACV,CACH;CACF;CACA,MAAMmB,mBAAmB1C,2BACvB0B,iBACAc,0BACF;CACA,MAAMX,kBAAkB,CACtB,GAAG,IAAIc,IACLD,iBACGJ,QACE,EAAEC,eACD,CAACrB,OAAOC,OAAOqB,4BAA4BD,QAAQ,CACvD,CAAC,CACAE,KAAK,EAAEF,eAAeA,QAAQ,CACnC,CAAC;CAEH,MAAMT,UAAU,CACd,GAAG,IAAIa,IACLD,iBACGJ,QAAQ,EAAEC,eACTrB,OAAOC,OAAOqB,4BAA4BD,QAAQ,CACpD,CAAC,CACAE,KAAK,EAAEF,eAAeA,QAAQ,CACnC,CAAC;CAGH,OAAO;EACLX,SAASV,OAAOe,YACdf,OAAOgB,QAAQM,0BAA0B,CAAC,CAACF,QACxC,CAACC,cAAc,CAACT,QAAQR,SAASiB,QAAQ,CAC5C,CACF;EACAV;EACAC;CACF;AACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useMcpElicitation, useMcpElicitationField } from "./elicitation/context.js";
|
|
2
|
+
import { McpElicitationPrimitiveItems } from "./elicitation/McpElicitationPrimitiveItems.js";
|
|
3
|
+
import { McpElicitationPrimitiveRoot } from "./elicitation/McpElicitationPrimitiveRoot.js";
|
|
4
|
+
import { McpElicitationPrimitiveMessage } from "./elicitation/McpElicitationPrimitiveMessage.js";
|
|
5
|
+
import { McpElicitationPrimitiveError } from "./elicitation/McpElicitationPrimitiveError.js";
|
|
6
|
+
import { McpElicitationPrimitiveFields } from "./elicitation/McpElicitationPrimitiveFields.js";
|
|
7
|
+
import { McpElicitationPrimitiveAccept } from "./elicitation/McpElicitationPrimitiveAccept.js";
|
|
8
|
+
import { McpElicitationPrimitiveDecline } from "./elicitation/McpElicitationPrimitiveDecline.js";
|
|
9
|
+
import { McpElicitationPrimitiveCancel } from "./elicitation/McpElicitationPrimitiveCancel.js";
|
|
10
|
+
declare namespace elicitation_d_exports {
|
|
11
|
+
export { McpElicitationPrimitiveAccept as Accept, McpElicitationPrimitiveCancel as Cancel, McpElicitationPrimitiveDecline as Decline, McpElicitationPrimitiveError as Error, McpElicitationPrimitiveFields as Fields, McpElicitationPrimitiveItems as Items, McpElicitationPrimitiveMessage as Message, McpElicitationPrimitiveRoot as Root, useMcpElicitation, useMcpElicitationField };
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { McpElicitationPrimitiveAccept as Accept, McpElicitationPrimitiveCancel as Cancel, McpElicitationPrimitiveDecline as Decline, McpElicitationPrimitiveError as Error, McpElicitationPrimitiveFields as Fields, McpElicitationPrimitiveItems as Items, McpElicitationPrimitiveMessage as Message, McpElicitationPrimitiveRoot as Root, elicitation_d_exports, useMcpElicitation, useMcpElicitationField };
|
|
15
|
+
//# sourceMappingURL=elicitation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elicitation.d.ts","names":[],"sources":["../../src/primitives/elicitation.ts"],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { useMcpElicitation, useMcpElicitationField } from "./elicitation/context.js";
|
|
3
|
+
import { McpElicitationPrimitiveItems } from "./elicitation/McpElicitationPrimitiveItems.js";
|
|
4
|
+
import { McpElicitationPrimitiveRoot } from "./elicitation/McpElicitationPrimitiveRoot.js";
|
|
5
|
+
import { McpElicitationPrimitiveMessage } from "./elicitation/McpElicitationPrimitiveMessage.js";
|
|
6
|
+
import { McpElicitationPrimitiveError } from "./elicitation/McpElicitationPrimitiveError.js";
|
|
7
|
+
import { McpElicitationPrimitiveFields } from "./elicitation/McpElicitationPrimitiveFields.js";
|
|
8
|
+
import { McpElicitationPrimitiveAccept } from "./elicitation/McpElicitationPrimitiveAccept.js";
|
|
9
|
+
import { McpElicitationPrimitiveDecline } from "./elicitation/McpElicitationPrimitiveDecline.js";
|
|
10
|
+
import { McpElicitationPrimitiveCancel } from "./elicitation/McpElicitationPrimitiveCancel.js";
|
|
11
|
+
//#region src/primitives/elicitation.ts
|
|
12
|
+
var elicitation_exports = /* @__PURE__ */ __exportAll({
|
|
13
|
+
Accept: () => McpElicitationPrimitiveAccept,
|
|
14
|
+
Cancel: () => McpElicitationPrimitiveCancel,
|
|
15
|
+
Decline: () => McpElicitationPrimitiveDecline,
|
|
16
|
+
Error: () => McpElicitationPrimitiveError,
|
|
17
|
+
Fields: () => McpElicitationPrimitiveFields,
|
|
18
|
+
Items: () => McpElicitationPrimitiveItems,
|
|
19
|
+
Message: () => McpElicitationPrimitiveMessage,
|
|
20
|
+
Root: () => McpElicitationPrimitiveRoot,
|
|
21
|
+
useMcpElicitation: () => useMcpElicitation,
|
|
22
|
+
useMcpElicitationField: () => useMcpElicitationField
|
|
23
|
+
});
|
|
24
|
+
//#endregion
|
|
25
|
+
export { McpElicitationPrimitiveAccept as Accept, McpElicitationPrimitiveCancel as Cancel, McpElicitationPrimitiveDecline as Decline, McpElicitationPrimitiveError as Error, McpElicitationPrimitiveFields as Fields, McpElicitationPrimitiveItems as Items, McpElicitationPrimitiveMessage as Message, McpElicitationPrimitiveRoot as Root, elicitation_exports, useMcpElicitation, useMcpElicitationField };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=elicitation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elicitation.js","names":["McpElicitationPrimitiveItems","Items","useMcpElicitation","McpElicitationPrimitiveRoot","Root","McpElicitationPrimitiveMessage","Message","McpElicitationPrimitiveError","Error","McpElicitationPrimitiveFields","Fields","useMcpElicitationField","McpElicitationPrimitiveAccept","Accept","McpElicitationPrimitiveDecline","Decline","McpElicitationPrimitiveCancel","Cancel"],"sources":["../../src/primitives/elicitation.ts"],"sourcesContent":["export {\n McpElicitationPrimitiveItems as Items,\n useMcpElicitation,\n} from \"./elicitation/McpElicitationPrimitiveItems\";\nexport { McpElicitationPrimitiveRoot as Root } from \"./elicitation/McpElicitationPrimitiveRoot\";\nexport { McpElicitationPrimitiveMessage as Message } from \"./elicitation/McpElicitationPrimitiveMessage\";\nexport { McpElicitationPrimitiveError as Error } from \"./elicitation/McpElicitationPrimitiveError\";\nexport {\n McpElicitationPrimitiveFields as Fields,\n useMcpElicitationField,\n} from \"./elicitation/McpElicitationPrimitiveFields\";\nexport { McpElicitationPrimitiveAccept as Accept } from \"./elicitation/McpElicitationPrimitiveAccept\";\nexport { McpElicitationPrimitiveDecline as Decline } from \"./elicitation/McpElicitationPrimitiveDecline\";\nexport { McpElicitationPrimitiveCancel as Cancel } from \"./elicitation/McpElicitationPrimitiveCancel\";\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpManagerResource.d.ts","names":[],"sources":["../../src/resources/McpManagerResource.ts"],"mappings":";;;;KAqBY;EACV,aAAa;EACb,UAAU;;EAEV;;EAEA;;EAEA;;
|
|
1
|
+
{"version":3,"file":"McpManagerResource.d.ts","names":[],"sources":["../../src/resources/McpManagerResource.ts"],"mappings":";;;;KAqBY;EACV,aAAa;EACb,UAAU;;EAEV;;EAEA;;EAEA;;cA8QW,gDAAkB,SAAA,sBAAA,OAAA"}
|
|
@@ -12,6 +12,9 @@ function defaultRedirectUri() {
|
|
|
12
12
|
return `${window.location.origin}/mcp/callback`;
|
|
13
13
|
}
|
|
14
14
|
const NO_CONNECTORS = [];
|
|
15
|
+
const reportCustomStorageFailure = (operation, error) => {
|
|
16
|
+
console.error(`[assistant-ui/react-mcp] failed to ${operation} custom servers:`, error);
|
|
17
|
+
};
|
|
15
18
|
const useMcpManagerResource = (props) => {
|
|
16
19
|
const $ = c(72);
|
|
17
20
|
const connectors = props.connectors ?? NO_CONNECTORS;
|
|
@@ -53,8 +56,9 @@ const useMcpManagerResource = (props) => {
|
|
|
53
56
|
records = await storage.loadCustomServers();
|
|
54
57
|
} catch (t4) {
|
|
55
58
|
const error = t4;
|
|
59
|
+
if (!signal.cancelled) reportCustomStorageFailure("load", error);
|
|
56
60
|
markHydrated();
|
|
57
|
-
|
|
61
|
+
return;
|
|
58
62
|
}
|
|
59
63
|
if (signal.cancelled) return;
|
|
60
64
|
setCustomServers((prev) => {
|
|
@@ -90,7 +94,11 @@ const useMcpManagerResource = (props) => {
|
|
|
90
94
|
if ($[10] !== storage) {
|
|
91
95
|
t6 = async (records_0) => {
|
|
92
96
|
if (!hydratedRef.current) return;
|
|
93
|
-
|
|
97
|
+
try {
|
|
98
|
+
await storage.saveCustomServers(records_0);
|
|
99
|
+
} catch (t7) {
|
|
100
|
+
reportCustomStorageFailure("save", t7);
|
|
101
|
+
}
|
|
94
102
|
};
|
|
95
103
|
$[10] = storage;
|
|
96
104
|
$[11] = t6;
|
|
@@ -128,6 +136,8 @@ const useMcpManagerResource = (props) => {
|
|
|
128
136
|
redirectUri,
|
|
129
137
|
autoConnect,
|
|
130
138
|
connectionTimeout: c_0.connectionTimeout ?? connectionTimeout,
|
|
139
|
+
...c_0.cache !== void 0 ? { cache: c_0.cache } : {},
|
|
140
|
+
...c_0.elicitation !== void 0 ? { elicitation: c_0.elicitation } : {},
|
|
131
141
|
onRemove: _temp4
|
|
132
142
|
}));
|
|
133
143
|
$[24] = autoConnect;
|
|
@@ -149,6 +159,8 @@ const useMcpManagerResource = (props) => {
|
|
|
149
159
|
redirectUri,
|
|
150
160
|
autoConnect,
|
|
151
161
|
connectionTimeout: s_0.connectionTimeout ?? connectionTimeout,
|
|
162
|
+
...s_0.cache !== void 0 ? { cache: s_0.cache } : {},
|
|
163
|
+
...s_0.elicitation !== void 0 ? { elicitation: s_0.elicitation } : {},
|
|
152
164
|
onRemove: async () => {
|
|
153
165
|
setCustomServers((prev_0) => prev_0.filter((x) => x.id !== s_0.id));
|
|
154
166
|
}
|
|
@@ -287,13 +299,15 @@ const useMcpManagerResource = (props) => {
|
|
|
287
299
|
let t20;
|
|
288
300
|
if ($[61] === Symbol.for("react.memo_cache_sentinel")) {
|
|
289
301
|
t20 = async (t21) => {
|
|
290
|
-
const { name, url, auth, connectionTimeout: connectionTimeout_0 } = t21;
|
|
302
|
+
const { name, url, auth, connectionTimeout: connectionTimeout_0, cache, elicitation } = t21;
|
|
291
303
|
const record = {
|
|
292
304
|
id: typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `mcp-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
293
305
|
name,
|
|
294
306
|
url,
|
|
295
307
|
auth,
|
|
296
308
|
connectionTimeout: connectionTimeout_0,
|
|
309
|
+
...cache !== void 0 ? { cache } : {},
|
|
310
|
+
...elicitation !== void 0 ? { elicitation } : {},
|
|
297
311
|
createdAt: Date.now()
|
|
298
312
|
};
|
|
299
313
|
setCustomServers((prev_1) => [...prev_1, record]);
|