@kontext-dev/js-sdk 0.1.1 → 1.0.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.
Files changed (39) hide show
  1. package/dist/adapters/ai/index.cjs +135 -58
  2. package/dist/adapters/ai/index.cjs.map +1 -1
  3. package/dist/adapters/ai/index.js +135 -58
  4. package/dist/adapters/ai/index.js.map +1 -1
  5. package/dist/adapters/cloudflare/index.cjs +28 -70
  6. package/dist/adapters/cloudflare/index.cjs.map +1 -1
  7. package/dist/adapters/cloudflare/index.js +28 -70
  8. package/dist/adapters/cloudflare/index.js.map +1 -1
  9. package/dist/client/index.cjs +33 -9
  10. package/dist/client/index.cjs.map +1 -1
  11. package/dist/client/index.js +33 -9
  12. package/dist/client/index.js.map +1 -1
  13. package/dist/index.cjs +42 -9
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.js +42 -9
  16. package/dist/index.js.map +1 -1
  17. package/dist/management/index.cjs.map +1 -1
  18. package/dist/management/index.d.cts +2 -2
  19. package/dist/management/index.d.ts +2 -2
  20. package/dist/management/index.js.map +1 -1
  21. package/dist/mcp/index.cjs +28 -8
  22. package/dist/mcp/index.cjs.map +1 -1
  23. package/dist/mcp/index.d.cts +5 -1
  24. package/dist/mcp/index.d.ts +5 -1
  25. package/dist/mcp/index.js +28 -8
  26. package/dist/mcp/index.js.map +1 -1
  27. package/dist/oauth/index.cjs.map +1 -1
  28. package/dist/oauth/index.d.cts +1 -1
  29. package/dist/oauth/index.d.ts +1 -1
  30. package/dist/oauth/index.js.map +1 -1
  31. package/dist/server/index.cjs +9 -0
  32. package/dist/server/index.cjs.map +1 -1
  33. package/dist/server/index.d.cts +1 -1
  34. package/dist/server/index.d.ts +1 -1
  35. package/dist/server/index.js +9 -0
  36. package/dist/server/index.js.map +1 -1
  37. package/dist/{types-CzhnlJHW.d.cts → types-C6ep5fVw.d.cts} +2 -0
  38. package/dist/{types-CzhnlJHW.d.ts → types-C6ep5fVw.d.ts} +2 -0
  39. package/package.json +1 -1
@@ -462,6 +462,7 @@ var KontextMcp = class {
462
462
  config;
463
463
  storage;
464
464
  oauthProvider;
465
+ clientSessionId = typeof globalThis.crypto?.randomUUID === "function" ? globalThis.crypto.randomUUID() : `kontext-sdk-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
465
466
  transport = null;
466
467
  client = null;
467
468
  _isConnected = false;
@@ -633,7 +634,22 @@ var KontextMcp = class {
633
634
  const url = typeof item.url === "string" ? item.url : "";
634
635
  if (!id || !url) return null;
635
636
  const category = item.category === "internal_mcp_credentials" ? "internal_mcp_credentials" : "gateway_remote_mcp";
636
- const connectType = item.connectType === "credentials" || item.connectType === "oauth" || item.connectType === "none" ? item.connectType : category === "internal_mcp_credentials" ? "credentials" : item.authMode === "oauth" ? "oauth" : "none";
637
+ const rawConnectType = item.connectType;
638
+ if (typeof rawConnectType !== "string") {
639
+ throw new KontextError(
640
+ "Runtime integration connectType is required in API response.",
641
+ "kontext_runtime_integrations_invalid_response",
642
+ { meta: { integrationId: id, connectType: rawConnectType } }
643
+ );
644
+ }
645
+ const connectType = rawConnectType === "credentials" || rawConnectType === "oauth" || rawConnectType === "user_token" || rawConnectType === "none" ? rawConnectType : null;
646
+ if (!connectType) {
647
+ throw new KontextError(
648
+ `Unknown runtime integration connectType "${rawConnectType}".`,
649
+ "kontext_runtime_integrations_invalid_response",
650
+ { meta: { integrationId: id, connectType: rawConnectType } }
651
+ );
652
+ }
637
653
  const rawConnection = item.connection && typeof item.connection === "object" ? item.connection : void 0;
638
654
  const connected = rawConnection && typeof rawConnection.connected === "boolean" ? rawConnection.connected : false;
639
655
  const status = rawConnection?.status === "connected" ? "connected" : "disconnected";
@@ -644,6 +660,9 @@ var KontextMcp = class {
644
660
  category,
645
661
  connectType,
646
662
  authMode: item.authMode === "oauth" || item.authMode === "user_token" || item.authMode === "server_token" || item.authMode === "none" ? item.authMode : void 0,
663
+ tokenLabel: typeof item.tokenLabel === "string" ? item.tokenLabel : void 0,
664
+ tokenHelpUrl: typeof item.tokenHelpUrl === "string" ? item.tokenHelpUrl : void 0,
665
+ tokenPlaceholder: typeof item.tokenPlaceholder === "string" ? item.tokenPlaceholder : void 0,
647
666
  credentialSchema: item.credentialSchema,
648
667
  requiresOauth: typeof item.requiresOauth === "boolean" ? item.requiresOauth : void 0,
649
668
  connection: rawConnection ? {
@@ -781,13 +800,14 @@ var KontextMcp = class {
781
800
  if (this.config.onElicitationUrl) {
782
801
  capabilities.elicitation = { url: {} };
783
802
  }
784
- this.client = new Client(
785
- {
786
- name: this.config.clientName ?? "kontext-sdk",
787
- version: this.config.clientVersion ?? "0.0.1"
788
- },
789
- { capabilities }
790
- );
803
+ const clientInfo = {
804
+ name: this.config.clientName ?? "kontext-sdk",
805
+ version: this.config.clientVersion ?? "0.0.1",
806
+ sessionId: this.clientSessionId
807
+ };
808
+ this.client = new Client(clientInfo, {
809
+ capabilities
810
+ });
791
811
  if (this.config.onElicitationUrl) {
792
812
  const onElicitationUrl = this.config.onElicitationUrl;
793
813
  this.client.setRequestHandler(ElicitRequestSchema, async (request) => {
@@ -2041,7 +2061,11 @@ function createKontextOrchestrator(config) {
2041
2061
  }
2042
2062
 
2043
2063
  // src/client/index.ts
2044
- var META_TOOL_NAMES = /* @__PURE__ */ new Set(["SEARCH_TOOLS", "EXECUTE_TOOL"]);
2064
+ var META_TOOL_NAMES = /* @__PURE__ */ new Set([
2065
+ "SEARCH_TOOLS",
2066
+ "EXECUTE_TOOL",
2067
+ "REQUEST_CAPABILITY"
2068
+ ]);
2045
2069
  function hasMetaTools(tools) {
2046
2070
  let hasSearch = false;
2047
2071
  let hasExecute = false;