@opengeni/core 0.4.4 → 0.4.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeni/core",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "description": "OpenGeni framework-agnostic core: the domain, access, and billing layers (neutral access, off-HTTP V2 surface). Behavior-preserving extraction from apps/api — keeps Hono's HTTPException for error throwing (typed-errors cleanup deferred).",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -38,14 +38,14 @@
38
38
  "dependencies": {
39
39
  "@modelcontextprotocol/sdk": "^1.29.0",
40
40
  "@opengeni/codex": "^0.2.1",
41
- "@opengeni/config": "^0.3.0",
41
+ "@opengeni/config": "^0.4.0",
42
42
  "@opengeni/contracts": "^0.9.0",
43
- "@opengeni/db": "^0.6.0",
44
- "@opengeni/documents": "^0.2.7",
45
- "@opengeni/events": "^0.2.7",
46
- "@opengeni/observability": "^0.2.1",
47
- "@opengeni/runtime": "^0.5.0",
48
- "@opengeni/storage": "^0.2.7",
43
+ "@opengeni/db": "^0.6.1",
44
+ "@opengeni/documents": "^0.2.8",
45
+ "@opengeni/events": "^0.2.8",
46
+ "@opengeni/observability": "^0.3.0",
47
+ "@opengeni/runtime": "^0.6.1",
48
+ "@opengeni/storage": "^0.2.8",
49
49
  "hono": "^4.12.18"
50
50
  }
51
51
  }
@@ -436,7 +436,7 @@ export async function validateMcpCapabilityConnection(
436
436
  };
437
437
  } catch (error) {
438
438
  throw new HTTPException(422, {
439
- message: `MCP capability "${item.name}" could not be enabled because OpenGeni could not initialize ${item.endpointUrl}: ${mcpProbeErrorMessage(error)}`,
439
+ message: `MCP capability "${item.name}" could not be enabled because ${mcpProbeErrorMessage(error, item.endpointUrl)}`,
440
440
  });
441
441
  }
442
442
  }
@@ -461,9 +461,16 @@ async function probeStreamableHttpMcpServer(input: McpCapabilityProbeInput): Pro
461
461
  }
462
462
  }
463
463
 
464
- function mcpProbeErrorMessage(error: unknown): string {
464
+ function mcpProbeErrorMessage(error: unknown, endpointUrl: string): string {
465
465
  const message = error instanceof Error ? error.message : String(error);
466
- return message.replace(/\s+/g, " ").trim().slice(0, 500) || "unknown error";
466
+ const normalized = message.replace(/\s+/g, " ").trim();
467
+ if (
468
+ /404|405|not found|unexpected token|not valid json|invalid json|failed to parse|streamable http error|unable to connect|fetch failed|econnrefused|enotfound|timeout|aborted/i
469
+ .test(normalized)
470
+ ) {
471
+ return `OpenGeni could not reach a valid Streamable HTTP MCP server at ${endpointUrl}. Check the endpoint URL or choose a different catalog entry.`;
472
+ }
473
+ return `OpenGeni could not initialize ${endpointUrl}: ${normalized.slice(0, 500) || "unknown error"}`;
467
474
  }
468
475
 
469
476
  export async function disableCapability(input: {
@@ -785,7 +792,7 @@ async function readSkillMetadata(url: URL, fallbackName: string): Promise<{ name
785
792
  return { name, description, category };
786
793
  }
787
794
 
788
- function applyCapabilityEnablement(
795
+ export function applyCapabilityEnablement(
789
796
  item: CapabilityCatalogItem,
790
797
  installation: CapabilityInstallation | undefined,
791
798
  activePackIds: Set<string>,
@@ -813,9 +820,28 @@ function applyCapabilityEnablement(
813
820
  ...item,
814
821
  enabled,
815
822
  enabledReason: enabled ? "enabled" : null,
823
+ connectionRef: enabled && installation ? installationConnectionRef(installation.config) : null,
816
824
  };
817
825
  }
818
826
 
827
+ /**
828
+ * The connection an installation was enabled with, when the enable-time
829
+ * connectionRef fully resolved to one (config.connectionRef is set only by
830
+ * the enable path — see enableCapability). Headers-enabled and credential-
831
+ * free installations never set it, so this returns null for them.
832
+ */
833
+ function installationConnectionRef(config: Record<string, unknown>): CapabilityCatalogItem["connectionRef"] {
834
+ const ref = config.connectionRef;
835
+ if (!ref || typeof ref !== "object") {
836
+ return null;
837
+ }
838
+ const { connectionId, providerDomain, kind } = ref as Record<string, unknown>;
839
+ if (typeof connectionId !== "string" || typeof providerDomain !== "string" || typeof kind !== "string") {
840
+ return null;
841
+ }
842
+ return { connectionId, providerDomain, kind };
843
+ }
844
+
819
845
  function dedupeCatalogItems(items: CapabilityCatalogItem[]): CapabilityCatalogItem[] {
820
846
  const byId = new Map<string, CapabilityCatalogItem>();
821
847
  for (const item of items) {