@ty_krystal/sei-ai 0.1.3 → 0.1.4

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.
Files changed (2) hide show
  1. package/dist/index.js +37 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -769,6 +769,7 @@ var OPENAPI_HTTP_METHODS = [
769
769
  ];
770
770
  function buildOpenApiDocSummary(openapiDoc, keyword) {
771
771
  if (!isObject$2(openapiDoc)) throw new SeiMcpError("OpenAPI 文档不是 JSON 对象", "INVALID_REQUEST");
772
+ throwIfOpenApiErrorPayload(openapiDoc);
772
773
  const info = isObject$2(openapiDoc.info) ? openapiDoc.info : {};
773
774
  const rawPaths = openapiDoc.paths;
774
775
  if (!isObject$2(rawPaths)) throw new SeiMcpError("OpenAPI 文档缺少 paths 对象", "INVALID_REQUEST");
@@ -908,6 +909,42 @@ function summarizeSchema(schema) {
908
909
  if (schemaType) return schemaType;
909
910
  return Array.isArray(schema.enum) && schema.enum.length > 0 ? "enum" : "";
910
911
  }
912
+ function throwIfOpenApiErrorPayload(openapiDoc) {
913
+ const rootCause = isObject$2(openapiDoc.rootCause) ? openapiDoc.rootCause : null;
914
+ const topFrame = (Array.isArray(rootCause?.stackTrace) ? rootCause.stackTrace : []).find(isObject$2);
915
+ const rootMessage = normalizeText(rootCause?.message);
916
+ const rootException = normalizeText(rootCause?.exception);
917
+ const message = normalizeText(openapiDoc.message);
918
+ const error = normalizeText(openapiDoc.error);
919
+ const path = normalizeText(openapiDoc.path);
920
+ if (!rootCause && !message && !error) return;
921
+ const parts = [
922
+ message || error,
923
+ rootException,
924
+ rootMessage,
925
+ formatStackFrame(topFrame),
926
+ path ? `path=${path}` : ""
927
+ ].filter(Boolean);
928
+ throw new SeiMcpError(parts.length > 0 ? `OpenAPI 文档生成失败:${parts.join(" | ")}` : "OpenAPI 文档生成失败,服务端返回异常对象", "INVALID_REQUEST", {
929
+ error,
930
+ message,
931
+ path,
932
+ rootCause: rootCause ?? void 0
933
+ });
934
+ }
935
+ function formatStackFrame(frame) {
936
+ if (!isObject$2(frame)) return "";
937
+ const className = normalizeText(frame.className);
938
+ const methodName = normalizeText(frame.methodName);
939
+ const fileName = normalizeText(frame.fileName);
940
+ const lineNumber = Number(frame.lineNumber);
941
+ const locationParts = [className, methodName].filter(Boolean);
942
+ const sourceParts = [fileName, Number.isFinite(lineNumber) && lineNumber > 0 ? String(lineNumber) : ""].filter(Boolean);
943
+ const location = locationParts.join("#");
944
+ const source = sourceParts.join(":");
945
+ if (location && source) return `${location} (${source})`;
946
+ return location || source;
947
+ }
911
948
  function normalizeText(value) {
912
949
  return typeof value === "string" ? value.replace(/\s+/g, " ").trim() : "";
913
950
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ty_krystal/sei-ai",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "SEI MCP server and developer CLI for query, save, query-sql, and api-docs workflows",
5
5
  "keywords": [
6
6
  "sei",