modality-kit 0.14.10 → 0.14.12
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/index.js +19 -12
- package/dist/types/index.d.ts +1 -1
- package/dist/types/util_response.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -36,18 +36,8 @@ var ContentType = [
|
|
|
36
36
|
"resource_link",
|
|
37
37
|
"resource"
|
|
38
38
|
];
|
|
39
|
-
function
|
|
40
|
-
const data = structuredClone(successData);
|
|
39
|
+
function mergeResponsesContent(result, content) {
|
|
41
40
|
const contentData = content ? structuredClone(content) : null;
|
|
42
|
-
const result = {
|
|
43
|
-
isError: false,
|
|
44
|
-
content: [
|
|
45
|
-
{
|
|
46
|
-
type: "text",
|
|
47
|
-
text: JSON.stringify(data)
|
|
48
|
-
}
|
|
49
|
-
]
|
|
50
|
-
};
|
|
51
41
|
if (Array.isArray(contentData)) {
|
|
52
42
|
result.content.push(...contentData.map((item) => {
|
|
53
43
|
if (typeof item === "string") {
|
|
@@ -59,10 +49,26 @@ function formatSuccessResponse(successData, content) {
|
|
|
59
49
|
}
|
|
60
50
|
}));
|
|
61
51
|
} else if (contentData != null) {
|
|
62
|
-
result.content.push({
|
|
52
|
+
result.content.push({
|
|
53
|
+
type: "text",
|
|
54
|
+
text: typeof contentData === "string" ? contentData : JSON.stringify(contentData)
|
|
55
|
+
});
|
|
63
56
|
}
|
|
64
57
|
return result;
|
|
65
58
|
}
|
|
59
|
+
function formatSuccessResponse(successData, content) {
|
|
60
|
+
const data = structuredClone(successData);
|
|
61
|
+
const result = {
|
|
62
|
+
isError: false,
|
|
63
|
+
content: [
|
|
64
|
+
{
|
|
65
|
+
type: "text",
|
|
66
|
+
text: JSON.stringify(data)
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
};
|
|
70
|
+
return mergeResponsesContent(result, content);
|
|
71
|
+
}
|
|
66
72
|
function formatErrorResponse(errorData, operation, meta) {
|
|
67
73
|
let errorResponse;
|
|
68
74
|
let isError = true;
|
|
@@ -6013,6 +6019,7 @@ class SimpleCache {
|
|
|
6013
6019
|
}
|
|
6014
6020
|
export {
|
|
6015
6021
|
withErrorHandling,
|
|
6022
|
+
mergeResponsesContent,
|
|
6016
6023
|
loadVersion,
|
|
6017
6024
|
isTestEnvironment,
|
|
6018
6025
|
getLoggerInstance,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { formatErrorResponse, formatSuccessResponse } from "./util_response";
|
|
1
|
+
export { formatErrorResponse, formatSuccessResponse, mergeResponsesContent } from "./util_response";
|
|
2
2
|
export { getLoggerInstance, type ModalityLogger } from "./util_logger";
|
|
3
3
|
export { withErrorHandling } from "./util_error";
|
|
4
4
|
export { ErrorCode } from "./ErrorCode";
|
|
@@ -25,6 +25,7 @@ interface ErrorData extends Record<string, any> {
|
|
|
25
25
|
message: string;
|
|
26
26
|
operation?: string;
|
|
27
27
|
}
|
|
28
|
+
export declare function mergeResponsesContent(result: CallToolResult, content: any): CallToolResult;
|
|
28
29
|
export declare function formatSuccessResponse(successData: SuccessData, content?: any): CallToolResult;
|
|
29
30
|
/**
|
|
30
31
|
* Format an error response for MCP tools using generic error data
|
package/package.json
CHANGED