modality-kit 0.12.0 → 0.12.2

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 CHANGED
@@ -31,51 +31,6 @@ var setupAITools = (aiTools, mcpServer) => {
31
31
  }
32
32
  return aiTools;
33
33
  };
34
- // src/util_response.ts
35
- function formatSuccessResponse(content, meta) {
36
- const { instructions, ...restContent } = content;
37
- return JSON.stringify({
38
- success: true,
39
- instructions,
40
- content: restContent,
41
- meta
42
- });
43
- }
44
- function formatErrorResponse(errorData, operation, meta) {
45
- let errorResponse;
46
- if (typeof errorData === "string") {
47
- errorResponse = {
48
- success: false,
49
- error: errorData,
50
- operation,
51
- meta
52
- };
53
- } else if (errorData instanceof Error) {
54
- errorResponse = {
55
- success: false,
56
- error: errorData.message,
57
- operation,
58
- meta
59
- };
60
- } else if (typeof errorData === "object" && errorData !== null && typeof errorData.message === "string") {
61
- const errObj = errorData;
62
- errorResponse = {
63
- success: errObj.success || false,
64
- error: errObj.message,
65
- code: errObj.code,
66
- operation: errObj.operation || operation,
67
- meta
68
- };
69
- } else {
70
- errorResponse = {
71
- success: false,
72
- error: "Unknown error",
73
- operation,
74
- meta
75
- };
76
- }
77
- return JSON.stringify(errorResponse);
78
- }
79
34
  // src/util_logger.ts
80
35
  var levels = [null, "debug", "info", "warn", "error", "success"];
81
36
 
@@ -157,11 +112,13 @@ class ModalityLogger {
157
112
  case "info": {
158
113
  const { message, ...restPayload } = payload;
159
114
  console.info(message);
160
- console.dir(restPayload, {
161
- depth: null,
162
- colors: true,
163
- maxArrayLength: null
164
- });
115
+ if (Object.keys(restPayload).length) {
116
+ console.dir(restPayload, {
117
+ depth: null,
118
+ colors: true,
119
+ maxArrayLength: null
120
+ });
121
+ }
165
122
  break;
166
123
  }
167
124
  case "warn": {
@@ -228,6 +185,7 @@ class ModalityLogger {
228
185
  }
229
186
  }
230
187
  var getLoggerInstance = ModalityLogger.getInstance.bind(ModalityLogger);
188
+
231
189
  // src/util_error.ts
232
190
  var logger = getLoggerInstance("Safe to Handle");
233
191
 
@@ -261,6 +219,61 @@ function withErrorHandling(fn, operation) {
261
219
  }
262
220
  };
263
221
  }
222
+
223
+ // src/util_response.ts
224
+ function formatSuccessResponse(content, meta) {
225
+ const { instructions, ...restContent } = content;
226
+ return JSON.stringify({
227
+ success: true,
228
+ instructions,
229
+ content: restContent,
230
+ meta
231
+ });
232
+ }
233
+ function formatErrorResponse(errorData, operation, meta) {
234
+ let errorResponse;
235
+ if (typeof errorData === "string") {
236
+ errorResponse = {
237
+ success: false,
238
+ error: errorData,
239
+ operation,
240
+ meta
241
+ };
242
+ } else if (errorData instanceof Error) {
243
+ errorResponse = {
244
+ success: false,
245
+ error: errorData.message,
246
+ operation,
247
+ meta
248
+ };
249
+ } else if (errorData instanceof ErrorCode) {
250
+ errorResponse = {
251
+ success: false,
252
+ error: errorData.message,
253
+ code: errorData.code,
254
+ reason: errorData.cause?.message,
255
+ operation,
256
+ meta
257
+ };
258
+ } else if (typeof errorData === "object" && errorData !== null && typeof errorData.message === "string") {
259
+ const errObj = errorData;
260
+ errorResponse = {
261
+ success: errObj.success || false,
262
+ error: errObj.message,
263
+ code: errObj.code,
264
+ operation: errObj.operation || operation,
265
+ meta
266
+ };
267
+ } else {
268
+ errorResponse = {
269
+ success: false,
270
+ error: "Unknown error",
271
+ operation,
272
+ meta
273
+ };
274
+ }
275
+ return JSON.stringify(errorResponse);
276
+ }
264
277
  // src/schemas/schemas_symbol.ts
265
278
  var exports_schemas_symbol = {};
266
279
  __export(exports_schemas_symbol, {
@@ -14,6 +14,7 @@ export interface McpErrorResponse {
14
14
  error: string;
15
15
  code?: string;
16
16
  operation?: string;
17
+ reason?: string;
17
18
  meta?: Record<string, any>;
18
19
  }
19
20
  interface SuccessData {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.12.0",
2
+ "version": "0.12.2",
3
3
  "name": "modality-kit",
4
4
  "repository": {
5
5
  "type": "git",