@kya-os/mcp-i 0.1.0-alpha.3.9 → 1.2.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 (328) hide show
  1. package/README.md +350 -213
  2. package/dist/149.js +1 -0
  3. package/dist/189.js +1 -0
  4. package/dist/261.js +1 -0
  5. package/dist/28.js +1 -0
  6. package/dist/295.js +1 -0
  7. package/dist/460.js +1 -0
  8. package/dist/570.js +1 -0
  9. package/dist/634.js +1 -0
  10. package/dist/647.js +1 -0
  11. package/dist/67.js +1 -0
  12. package/dist/739.js +1 -0
  13. package/dist/742.js +1 -0
  14. package/dist/904.js +1 -0
  15. package/dist/938.js +1 -0
  16. package/dist/auth/api-key.d.ts +16 -0
  17. package/dist/auth/api-key.js +82 -0
  18. package/dist/auth/jwt.d.ts +43 -0
  19. package/dist/auth/jwt.js +51 -0
  20. package/dist/auth/oauth/factory.d.ts +12 -0
  21. package/dist/auth/oauth/factory.js +36 -0
  22. package/dist/auth/oauth/index.d.ts +5 -0
  23. package/dist/auth/oauth/index.js +27 -0
  24. package/dist/auth/oauth/providers/proxy-provider.d.ts +13 -0
  25. package/dist/auth/oauth/providers/proxy-provider.js +159 -0
  26. package/dist/auth/oauth/router.d.ts +4 -0
  27. package/dist/auth/oauth/router.js +294 -0
  28. package/dist/auth/oauth/storage/memory-storage.d.ts +12 -0
  29. package/dist/auth/oauth/storage/memory-storage.js +40 -0
  30. package/dist/auth/oauth/types.d.ts +112 -0
  31. package/dist/cache/__tests__/cloudflare-kv-nonce-cache.test.d.ts +4 -0
  32. package/dist/cache/__tests__/cloudflare-kv-nonce-cache.test.js +176 -0
  33. package/dist/cache/__tests__/concurrency.test.d.ts +5 -0
  34. package/dist/cache/__tests__/concurrency.test.js +300 -0
  35. package/dist/cache/__tests__/dynamodb-nonce-cache.test.d.ts +4 -0
  36. package/dist/cache/__tests__/dynamodb-nonce-cache.test.js +176 -0
  37. package/dist/cache/__tests__/memory-nonce-cache.test.d.ts +4 -0
  38. package/dist/cache/__tests__/memory-nonce-cache.test.js +132 -0
  39. package/dist/cache/__tests__/nonce-cache-factory-simple.test.d.ts +4 -0
  40. package/dist/cache/__tests__/nonce-cache-factory-simple.test.js +133 -0
  41. package/dist/cache/__tests__/nonce-cache-factory.test.d.ts +4 -0
  42. package/dist/cache/__tests__/nonce-cache-factory.test.js +252 -0
  43. package/dist/cache/__tests__/redis-nonce-cache.test.d.ts +4 -0
  44. package/dist/cache/__tests__/redis-nonce-cache.test.js +95 -0
  45. package/dist/cache/cloudflare-kv-nonce-cache.d.ts +14 -0
  46. package/dist/cache/cloudflare-kv-nonce-cache.js +93 -0
  47. package/dist/cache/dynamodb-nonce-cache.d.ts +15 -0
  48. package/dist/cache/dynamodb-nonce-cache.js +92 -0
  49. package/dist/cache/index.d.ts +16 -0
  50. package/dist/cache/index.js +32 -0
  51. package/dist/cache/memory-nonce-cache.d.ts +44 -0
  52. package/dist/cache/memory-nonce-cache.js +105 -0
  53. package/dist/cache/nonce-cache-factory.d.ts +20 -0
  54. package/dist/cache/nonce-cache-factory.js +208 -0
  55. package/dist/cache/redis-nonce-cache.d.ts +14 -0
  56. package/dist/cache/redis-nonce-cache.js +53 -0
  57. package/dist/compiler/compiler-context.d.ts +23 -0
  58. package/dist/compiler/compiler-context.js +24 -0
  59. package/dist/compiler/config/constants.d.ts +41 -0
  60. package/dist/compiler/config/constants.js +45 -0
  61. package/dist/compiler/config/index.d.ts +252 -0
  62. package/dist/compiler/config/index.js +15 -0
  63. package/dist/compiler/config/injection.d.ts +26 -0
  64. package/dist/compiler/config/injection.js +58 -0
  65. package/dist/compiler/config/schemas/experimental/index.d.ts +91 -0
  66. package/dist/compiler/config/schemas/experimental/index.js +16 -0
  67. package/dist/compiler/config/schemas/experimental/oauth.d.ts +74 -0
  68. package/dist/compiler/config/schemas/experimental/oauth.js +25 -0
  69. package/dist/compiler/config/schemas/index.d.ts +6 -0
  70. package/dist/compiler/config/schemas/index.js +17 -0
  71. package/dist/compiler/config/schemas/paths.d.ts +9 -0
  72. package/dist/compiler/config/schemas/paths.js +12 -0
  73. package/dist/compiler/config/schemas/transport/http.d.ts +82 -0
  74. package/dist/compiler/config/schemas/transport/http.js +33 -0
  75. package/dist/compiler/config/schemas/transport/stdio.d.ts +9 -0
  76. package/dist/compiler/config/schemas/transport/stdio.js +15 -0
  77. package/dist/compiler/config/schemas/webpack.d.ts +3 -0
  78. package/dist/compiler/config/schemas/webpack.js +15 -0
  79. package/dist/compiler/config/types.d.ts +1 -0
  80. package/dist/compiler/config/types.js +2 -0
  81. package/dist/compiler/config/utils.d.ts +20 -0
  82. package/dist/compiler/config/utils.js +36 -0
  83. package/dist/compiler/generate-env-code.d.ts +1 -0
  84. package/dist/compiler/generate-env-code.js +8 -0
  85. package/dist/compiler/generate-import-code.d.ts +1 -0
  86. package/dist/compiler/generate-import-code.js +24 -0
  87. package/dist/compiler/get-webpack-config/get-entries.d.ts +3 -0
  88. package/dist/compiler/get-webpack-config/get-entries.js +29 -0
  89. package/dist/compiler/get-webpack-config/get-externals.d.ts +7 -0
  90. package/dist/compiler/get-webpack-config/get-externals.js +88 -0
  91. package/dist/compiler/get-webpack-config/get-injected-variables.d.ts +8 -0
  92. package/dist/compiler/get-webpack-config/get-injected-variables.js +25 -0
  93. package/dist/compiler/get-webpack-config/index.d.ts +4 -0
  94. package/dist/compiler/get-webpack-config/index.js +101 -0
  95. package/dist/compiler/get-webpack-config/plugins.d.ts +8 -0
  96. package/dist/compiler/get-webpack-config/plugins.js +132 -0
  97. package/dist/compiler/get-webpack-config/resolve-tsconfig-paths.d.ts +9 -0
  98. package/dist/compiler/get-webpack-config/resolve-tsconfig-paths.js +40 -0
  99. package/dist/compiler/index.d.ts +6 -0
  100. package/dist/compiler/index.js +194 -0
  101. package/dist/compiler/on-first-build.d.ts +3 -0
  102. package/dist/compiler/on-first-build.js +58 -0
  103. package/dist/compiler/parse-xmcp-config.d.ts +9 -0
  104. package/dist/compiler/parse-xmcp-config.js +155 -0
  105. package/dist/compiler/start-http-server.d.ts +1 -0
  106. package/dist/compiler/start-http-server.js +34 -0
  107. package/dist/index.d.ts +12 -0
  108. package/dist/index.js +38 -0
  109. package/dist/index.js.LICENSE.txt +49 -0
  110. package/dist/runtime/__tests__/audit.test.d.ts +4 -0
  111. package/dist/runtime/__tests__/audit.test.js +328 -0
  112. package/dist/runtime/__tests__/identity.test.d.ts +4 -0
  113. package/dist/runtime/__tests__/identity.test.js +164 -0
  114. package/dist/runtime/__tests__/mcpi-runtime.test.d.ts +4 -0
  115. package/dist/runtime/__tests__/mcpi-runtime.test.js +372 -0
  116. package/dist/runtime/__tests__/proof.test.d.ts +4 -0
  117. package/dist/runtime/__tests__/proof.test.js +302 -0
  118. package/dist/runtime/__tests__/session.test.d.ts +4 -0
  119. package/dist/runtime/__tests__/session.test.js +254 -0
  120. package/dist/runtime/__tests__/well-known.test.d.ts +4 -0
  121. package/dist/runtime/__tests__/well-known.test.js +312 -0
  122. package/dist/runtime/adapter-express.js +2 -0
  123. package/dist/runtime/adapter-express.js.LICENSE.txt +252 -0
  124. package/dist/runtime/adapter-nextjs.js +2 -0
  125. package/dist/runtime/adapter-nextjs.js.LICENSE.txt +53 -0
  126. package/dist/runtime/adapters/express/index.d.ts +2 -0
  127. package/dist/runtime/adapters/express/index.js +48 -0
  128. package/dist/runtime/adapters/nextjs/index.d.ts +8 -0
  129. package/dist/runtime/adapters/nextjs/index.js +18 -0
  130. package/dist/runtime/audit.d.ts +93 -0
  131. package/dist/runtime/audit.js +212 -0
  132. package/dist/runtime/debug.d.ts +118 -0
  133. package/dist/runtime/debug.js +612 -0
  134. package/dist/runtime/delegation-hooks.d.ts +85 -0
  135. package/dist/runtime/delegation-hooks.js +116 -0
  136. package/dist/runtime/demo.d.ts +71 -0
  137. package/dist/runtime/demo.js +135 -0
  138. package/dist/runtime/headers.d.ts +1 -0
  139. package/dist/runtime/headers.js +9 -0
  140. package/dist/runtime/http.js +2 -0
  141. package/dist/runtime/http.js.LICENSE.txt +252 -0
  142. package/dist/runtime/identity.d.ts +105 -0
  143. package/dist/runtime/identity.js +232 -0
  144. package/dist/runtime/index.d.ts +16 -0
  145. package/dist/runtime/index.js +56 -0
  146. package/dist/runtime/mcpi-runtime.d.ts +164 -0
  147. package/dist/runtime/mcpi-runtime.js +352 -0
  148. package/dist/runtime/proof.d.ts +87 -0
  149. package/dist/runtime/proof.js +223 -0
  150. package/dist/runtime/session.d.ts +88 -0
  151. package/dist/runtime/session.js +216 -0
  152. package/dist/runtime/stdio.js +2 -0
  153. package/dist/runtime/stdio.js.LICENSE.txt +1 -0
  154. package/dist/runtime/templates/home.d.ts +2 -0
  155. package/dist/runtime/templates/home.js +50 -0
  156. package/dist/runtime/transports/http/base-streamable-http.d.ts +25 -0
  157. package/dist/runtime/transports/http/base-streamable-http.js +16 -0
  158. package/dist/runtime/transports/http/http-context.d.ts +9 -0
  159. package/dist/runtime/transports/http/http-context.js +8 -0
  160. package/dist/runtime/transports/http/index.js +55 -0
  161. package/dist/runtime/transports/http/setup-cors.d.ts +4 -0
  162. package/dist/runtime/transports/http/setup-cors.js +24 -0
  163. package/dist/runtime/transports/http/stateless-streamable-http.d.ts +39 -0
  164. package/dist/runtime/transports/http/stateless-streamable-http.js +331 -0
  165. package/dist/runtime/transports/stdio/index.d.ts +1 -0
  166. package/dist/runtime/transports/stdio/index.js +51 -0
  167. package/dist/runtime/utils/server.d.ts +42 -0
  168. package/dist/runtime/utils/server.js +39 -0
  169. package/dist/runtime/utils/tools.d.ts +8 -0
  170. package/dist/runtime/utils/tools.js +115 -0
  171. package/dist/runtime/verifier-middleware.d.ts +76 -0
  172. package/dist/runtime/verifier-middleware.js +322 -0
  173. package/dist/runtime/well-known.d.ts +151 -0
  174. package/dist/runtime/well-known.js +258 -0
  175. package/dist/storage/config.d.ts +28 -0
  176. package/dist/storage/config.js +79 -0
  177. package/dist/storage/delegation.d.ts +59 -0
  178. package/dist/storage/delegation.js +130 -0
  179. package/dist/storage/merkle-verifier.d.ts +84 -0
  180. package/dist/storage/merkle-verifier.js +261 -0
  181. package/dist/test/__tests__/nonce-cache-integration.test.d.ts +1 -0
  182. package/dist/test/__tests__/nonce-cache-integration.test.js +116 -0
  183. package/dist/test/__tests__/nonce-cache.test.d.ts +1 -0
  184. package/dist/test/__tests__/nonce-cache.test.js +122 -0
  185. package/dist/test/__tests__/runtime-integration.test.d.ts +4 -0
  186. package/dist/test/__tests__/runtime-integration.test.js +192 -0
  187. package/dist/test/__tests__/test-infrastructure.test.d.ts +4 -0
  188. package/dist/test/__tests__/test-infrastructure.test.js +178 -0
  189. package/dist/test/deterministic-keys.d.ts +31 -0
  190. package/dist/test/deterministic-keys.js +108 -0
  191. package/dist/test/examples/test-usage-example.d.ts +140 -0
  192. package/dist/test/examples/test-usage-example.js +175 -0
  193. package/dist/test/index.d.ts +11 -0
  194. package/dist/test/index.js +27 -0
  195. package/dist/test/local-verification.d.ts +28 -0
  196. package/dist/test/local-verification.js +342 -0
  197. package/dist/test/mock-identity-provider.d.ts +96 -0
  198. package/dist/test/mock-identity-provider.js +243 -0
  199. package/dist/test/runtime-integration.d.ts +63 -0
  200. package/dist/test/runtime-integration.js +140 -0
  201. package/dist/test/test-environment.d.ts +26 -0
  202. package/dist/test/test-environment.js +50 -0
  203. package/dist/types/declarations.d.ts +1 -0
  204. package/dist/types/declarations.js +6 -0
  205. package/dist/types/middleware.d.ts +2 -0
  206. package/dist/types/middleware.js +2 -0
  207. package/dist/types/tool.d.ts +80 -0
  208. package/dist/types/tool.js +2 -0
  209. package/dist/utils/cli-icons.d.ts +3 -0
  210. package/dist/utils/cli-icons.js +7 -0
  211. package/dist/utils/constants.d.ts +6 -0
  212. package/dist/utils/constants.js +13 -0
  213. package/dist/utils/context.d.ts +33 -0
  214. package/dist/utils/context.js +58 -0
  215. package/dist/utils/file-watcher.d.ts +19 -0
  216. package/dist/utils/file-watcher.js +49 -0
  217. package/dist/utils/fs-utils.d.ts +2 -0
  218. package/dist/utils/fs-utils.js +22 -0
  219. package/dist/utils/path-validation.d.ts +3 -0
  220. package/dist/utils/path-validation.js +56 -0
  221. package/dist/utils/spawn-process.d.ts +9 -0
  222. package/dist/utils/spawn-process.js +50 -0
  223. package/dist/utils/subscribable.d.ts +12 -0
  224. package/dist/utils/subscribable.js +44 -0
  225. package/package.json +91 -77
  226. package/dist/cjs/auto.js +0 -16
  227. package/dist/cjs/cli-mode.d.ts +0 -16
  228. package/dist/cjs/cli-mode.js +0 -32
  229. package/dist/cjs/crypto.d.ts +0 -16
  230. package/dist/cjs/crypto.js +0 -212
  231. package/dist/cjs/dev-helper.d.ts +0 -3
  232. package/dist/cjs/dev-helper.js +0 -46
  233. package/dist/cjs/encrypted-storage.d.ts +0 -11
  234. package/dist/cjs/encrypted-storage.js +0 -73
  235. package/dist/cjs/index.d.ts +0 -56
  236. package/dist/cjs/index.js +0 -727
  237. package/dist/cjs/logger.d.ts +0 -32
  238. package/dist/cjs/logger.js +0 -85
  239. package/dist/cjs/nextjs.d.ts +0 -10
  240. package/dist/cjs/nextjs.js +0 -83
  241. package/dist/cjs/platform-info.d.ts +0 -36
  242. package/dist/cjs/platform-info.js +0 -274
  243. package/dist/cjs/polling.d.ts +0 -13
  244. package/dist/cjs/polling.js +0 -52
  245. package/dist/cjs/registry/index.d.ts +0 -12
  246. package/dist/cjs/registry/index.js +0 -56
  247. package/dist/cjs/registry/knowthat.d.ts +0 -17
  248. package/dist/cjs/registry/knowthat.js +0 -173
  249. package/dist/cjs/rotation.d.ts +0 -35
  250. package/dist/cjs/rotation.js +0 -102
  251. package/dist/cjs/storage.d.ts +0 -41
  252. package/dist/cjs/storage.js +0 -163
  253. package/dist/cjs/transport.d.ts +0 -35
  254. package/dist/cjs/transport.js +0 -300
  255. package/dist/cjs/types.d.ts +0 -206
  256. package/dist/cjs/vercel-adapter.d.ts +0 -8
  257. package/dist/cjs/vercel-adapter.js +0 -67
  258. package/dist/esm/auto.d.ts +0 -13
  259. package/dist/esm/auto.d.ts.map +0 -1
  260. package/dist/esm/auto.js +0 -30
  261. package/dist/esm/auto.js.map +0 -1
  262. package/dist/esm/cli-mode.d.ts +0 -52
  263. package/dist/esm/cli-mode.d.ts.map +0 -1
  264. package/dist/esm/cli-mode.js +0 -59
  265. package/dist/esm/cli-mode.js.map +0 -1
  266. package/dist/esm/crypto.d.ts +0 -51
  267. package/dist/esm/crypto.d.ts.map +0 -1
  268. package/dist/esm/crypto.js +0 -230
  269. package/dist/esm/crypto.js.map +0 -1
  270. package/dist/esm/dev-helper.d.ts +0 -15
  271. package/dist/esm/dev-helper.d.ts.map +0 -1
  272. package/dist/esm/dev-helper.js +0 -63
  273. package/dist/esm/dev-helper.js.map +0 -1
  274. package/dist/esm/encrypted-storage.d.ts +0 -19
  275. package/dist/esm/encrypted-storage.d.ts.map +0 -1
  276. package/dist/esm/encrypted-storage.js +0 -48
  277. package/dist/esm/encrypted-storage.js.map +0 -1
  278. package/dist/esm/index.d.ts +0 -129
  279. package/dist/esm/index.d.ts.map +0 -1
  280. package/dist/esm/index.js +0 -853
  281. package/dist/esm/index.js.map +0 -1
  282. package/dist/esm/logger.d.ts +0 -46
  283. package/dist/esm/logger.d.ts.map +0 -1
  284. package/dist/esm/logger.js +0 -100
  285. package/dist/esm/logger.js.map +0 -1
  286. package/dist/esm/nextjs.d.ts +0 -22
  287. package/dist/esm/nextjs.d.ts.map +0 -1
  288. package/dist/esm/nextjs.js +0 -83
  289. package/dist/esm/nextjs.js.map +0 -1
  290. package/dist/esm/package.json +0 -1
  291. package/dist/esm/platform-info.d.ts +0 -74
  292. package/dist/esm/platform-info.d.ts.map +0 -1
  293. package/dist/esm/platform-info.js +0 -293
  294. package/dist/esm/platform-info.js.map +0 -1
  295. package/dist/esm/polling.d.ts +0 -29
  296. package/dist/esm/polling.d.ts.map +0 -1
  297. package/dist/esm/polling.js +0 -76
  298. package/dist/esm/polling.js.map +0 -1
  299. package/dist/esm/registry/index.d.ts +0 -43
  300. package/dist/esm/registry/index.d.ts.map +0 -1
  301. package/dist/esm/registry/index.js +0 -89
  302. package/dist/esm/registry/index.js.map +0 -1
  303. package/dist/esm/registry/knowthat.d.ts +0 -44
  304. package/dist/esm/registry/knowthat.d.ts.map +0 -1
  305. package/dist/esm/registry/knowthat.js +0 -220
  306. package/dist/esm/registry/knowthat.js.map +0 -1
  307. package/dist/esm/rotation.d.ts +0 -57
  308. package/dist/esm/rotation.d.ts.map +0 -1
  309. package/dist/esm/rotation.js +0 -133
  310. package/dist/esm/rotation.js.map +0 -1
  311. package/dist/esm/storage.d.ts +0 -65
  312. package/dist/esm/storage.d.ts.map +0 -1
  313. package/dist/esm/storage.js +0 -160
  314. package/dist/esm/storage.js.map +0 -1
  315. package/dist/esm/transport.d.ts +0 -52
  316. package/dist/esm/transport.d.ts.map +0 -1
  317. package/dist/esm/transport.js +0 -340
  318. package/dist/esm/transport.js.map +0 -1
  319. package/dist/esm/types.d.ts +0 -293
  320. package/dist/esm/types.d.ts.map +0 -1
  321. package/dist/esm/types.js +0 -5
  322. package/dist/esm/types.js.map +0 -1
  323. package/dist/esm/vercel-adapter.d.ts +0 -26
  324. package/dist/esm/vercel-adapter.d.ts.map +0 -1
  325. package/dist/esm/vercel-adapter.js +0 -80
  326. package/dist/esm/vercel-adapter.js.map +0 -1
  327. /package/dist/{cjs → auth/oauth}/types.js +0 -0
  328. /package/dist/{cjs/auto.d.ts → runtime/transports/http/index.d.ts} +0 -0
@@ -1,32 +0,0 @@
1
- export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
2
- export interface Logger {
3
- debug(message: string, ...args: any[]): void;
4
- info(message: string, ...args: any[]): void;
5
- warn(message: string, ...args: any[]): void;
6
- error(message: string, ...args: any[]): void;
7
- }
8
- export declare class SilentLogger implements Logger {
9
- debug(): void;
10
- info(): void;
11
- warn(): void;
12
- error(): void;
13
- }
14
- export declare class ConsoleLogger implements Logger {
15
- private prefix;
16
- private level;
17
- constructor(prefix?: string, level?: LogLevel);
18
- private shouldLog;
19
- debug(message: string, ...args: any[]): void;
20
- info(message: string, ...args: any[]): void;
21
- warn(message: string, ...args: any[]): void;
22
- error(message: string, ...args: any[]): void;
23
- }
24
- export declare class LoggerFactory {
25
- private static instance;
26
- static setLogger(logger: Logger): void;
27
- static getLogger(): Logger;
28
- static createConsoleLogger(level?: LogLevel): Logger;
29
- static createSilentLogger(): Logger;
30
- static reset(): void;
31
- }
32
- export declare function getLogger(logLevel?: LogLevel): Logger;
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LoggerFactory = exports.ConsoleLogger = exports.SilentLogger = void 0;
4
- exports.getLogger = getLogger;
5
- class SilentLogger {
6
- debug() { }
7
- info() { }
8
- warn() { }
9
- error() { }
10
- }
11
- exports.SilentLogger = SilentLogger;
12
- class ConsoleLogger {
13
- constructor(prefix = '[MCP-I]', level = 'info') {
14
- this.prefix = prefix;
15
- this.level = level;
16
- }
17
- shouldLog(level) {
18
- const levels = ['debug', 'info', 'warn', 'error', 'silent'];
19
- const currentIndex = levels.indexOf(this.level);
20
- const messageIndex = levels.indexOf(level);
21
- return messageIndex >= currentIndex;
22
- }
23
- debug(message, ...args) {
24
- if (this.shouldLog('debug')) {
25
- console.log(`${this.prefix} [DEBUG]`, message, ...args);
26
- }
27
- }
28
- info(message, ...args) {
29
- if (this.shouldLog('info')) {
30
- console.log(`${this.prefix} [INFO]`, message, ...args);
31
- }
32
- }
33
- warn(message, ...args) {
34
- if (this.shouldLog('warn')) {
35
- console.warn(`${this.prefix} [WARN]`, message, ...args);
36
- }
37
- }
38
- error(message, ...args) {
39
- if (this.shouldLog('error')) {
40
- if (args.length > 0 && args[0] instanceof Error) {
41
- const error = args[0];
42
- console.error(`${this.prefix} [ERROR]`, message);
43
- console.error(`${this.prefix} [ERROR] Message:`, error.message);
44
- if (this.level === 'debug' && error.stack) {
45
- console.error(`${this.prefix} [ERROR] Stack:`, error.stack);
46
- }
47
- if (args.length > 1) {
48
- console.error(`${this.prefix} [ERROR] Additional info:`, ...args.slice(1));
49
- }
50
- }
51
- else {
52
- console.error(`${this.prefix} [ERROR]`, message, ...args);
53
- }
54
- }
55
- }
56
- }
57
- exports.ConsoleLogger = ConsoleLogger;
58
- class LoggerFactory {
59
- static setLogger(logger) {
60
- LoggerFactory.instance = logger;
61
- }
62
- static getLogger() {
63
- return LoggerFactory.instance;
64
- }
65
- static createConsoleLogger(level) {
66
- return new ConsoleLogger('[MCP-I]', level);
67
- }
68
- static createSilentLogger() {
69
- return new SilentLogger();
70
- }
71
- static reset() {
72
- LoggerFactory.instance = new SilentLogger();
73
- }
74
- }
75
- exports.LoggerFactory = LoggerFactory;
76
- LoggerFactory.instance = new SilentLogger();
77
- function getLogger(logLevel) {
78
- if (logLevel === 'silent') {
79
- return new SilentLogger();
80
- }
81
- else if (logLevel) {
82
- return new ConsoleLogger('[MCP-I]', logLevel);
83
- }
84
- return LoggerFactory.getLogger();
85
- }
@@ -1,10 +0,0 @@
1
- import { MCPIdentity } from "./index";
2
- import { MCPIdentityOptions } from "./types";
3
- export interface NextJSMCPOptions extends Omit<MCPIdentityOptions, "transport" | "storage"> {
4
- storage?: "memory";
5
- transport?: "fetch";
6
- showSetupInstructions?: boolean;
7
- }
8
- export declare function enableMCPIdentityForNextJS(options?: NextJSMCPOptions): Promise<MCPIdentity>;
9
- export { enableMCPIdentity, MCPIdentity } from "./index";
10
- export * from "./types";
@@ -1,83 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.MCPIdentity = exports.enableMCPIdentity = void 0;
18
- exports.enableMCPIdentityForNextJS = enableMCPIdentityForNextJS;
19
- const index_1 = require("./index");
20
- async function enableMCPIdentityForNextJS(options = {}) {
21
- const isProduction = process.env.NODE_ENV === "production";
22
- const isVercel = process.env.VERCEL || process.env.VERCEL_ENV;
23
- try {
24
- console.log(`\n🚀 Initializing MCP-I for Next.js...`);
25
- const identity = await (0, index_1.enableMCPIdentity)({
26
- ...options,
27
- transport: "fetch",
28
- storage: "memory",
29
- logLevel: options.logLevel || (isProduction ? "error" : "info"),
30
- mode: isProduction ? "production" : "development",
31
- });
32
- if (!isProduction && options.showSetupInstructions !== false) {
33
- console.log("\n✅ MCP-I Ready for Next.js!");
34
- console.log(`\n📋 Quick Info:`);
35
- console.log(` Environment: ${isVercel ? "Vercel" : "Local"}`);
36
- console.log(` DID: ${identity.did}`);
37
- if (isVercel && !process.env.MCP_IDENTITY_AGENT_DID) {
38
- console.log("\n⚠️ Remember to set environment variables in Vercel Dashboard!");
39
- console.log(" See console output above for the exact variables to add.");
40
- }
41
- }
42
- return identity;
43
- }
44
- catch (error) {
45
- console.error("\n❌ MCP-I Initialization Failed\n");
46
- if (error?.message?.includes("429")) {
47
- console.error("📛 Rate Limit Hit");
48
- console.error(" You've made too many registration attempts.");
49
- console.error(" Wait a few minutes and try again.");
50
- console.error("\n💡 Tip: In development, you can use environment variables to persist identity:");
51
- console.error(" 1. Copy the MCP_IDENTITY_* variables from a successful run");
52
- console.error(" 2. Add them to your .env.local file");
53
- }
54
- else if (error?.message?.includes("500") ||
55
- error?.message?.includes("fetch failed")) {
56
- console.error("📛 Server Connection Error");
57
- console.error(" Cannot connect to knowthat.ai registry.");
58
- console.error("\n💡 Possible causes:");
59
- console.error(" - Registry is temporarily down");
60
- console.error(" - Network connectivity issues");
61
- console.error(" - Firewall blocking outbound connections");
62
- console.error("\n💡 Workaround for development:");
63
- console.error(' Add to your route: mode: "development" to allow offline mode');
64
- }
65
- else if (error?.message?.includes("MODULE_NOT_FOUND")) {
66
- console.error("📛 Missing Dependencies");
67
- console.error(" Make sure all dependencies are installed:");
68
- console.error(" npm install @kya-os/mcp-i");
69
- }
70
- else {
71
- console.error("📛 Unexpected Error:", error?.message || error);
72
- }
73
- if (!isProduction) {
74
- console.error("\n🔍 Full Error Details:");
75
- console.error(error);
76
- }
77
- throw error;
78
- }
79
- }
80
- var index_2 = require("./index");
81
- Object.defineProperty(exports, "enableMCPIdentity", { enumerable: true, get: function () { return index_2.enableMCPIdentity; } });
82
- Object.defineProperty(exports, "MCPIdentity", { enumerable: true, get: function () { return index_2.MCPIdentity; } });
83
- __exportStar(require("./types"), exports);
@@ -1,36 +0,0 @@
1
- export interface ClientInfo {
2
- sdkVersion: string;
3
- language: string;
4
- platform: string;
5
- runtime?: {
6
- name: string;
7
- version?: string;
8
- environment?: string;
9
- };
10
- processingMode?: 'sync' | 'async';
11
- metadata?: Record<string, any>;
12
- }
13
- export interface PlatformInfo {
14
- platform: string;
15
- runtime: string;
16
- version?: string;
17
- environment?: string;
18
- capabilities: {
19
- fileSystem: boolean;
20
- asyncRuntime: boolean;
21
- persistentStorage: boolean;
22
- longRunning: boolean;
23
- };
24
- }
25
- export declare function detectPlatform(): PlatformInfo;
26
- export declare function generateClientInfo(options?: {
27
- processingMode?: 'sync' | 'async';
28
- customMetadata?: Record<string, any>;
29
- }): ClientInfo;
30
- export declare function getPlatformRecommendations(platformInfo?: PlatformInfo): {
31
- storage: "file" | "memory" | "auto";
32
- transport: "fetch" | "axios" | "auto";
33
- processingMode: "sync" | "async";
34
- logLevel: "debug" | "info" | "warn" | "error" | "silent";
35
- };
36
- export declare function getCachedPlatformInfo(): PlatformInfo;
@@ -1,274 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.detectPlatform = detectPlatform;
37
- exports.generateClientInfo = generateClientInfo;
38
- exports.getPlatformRecommendations = getPlatformRecommendations;
39
- exports.getCachedPlatformInfo = getCachedPlatformInfo;
40
- const fs = __importStar(require("fs"));
41
- const path = __importStar(require("path"));
42
- function getSdkVersion() {
43
- try {
44
- const strategies = [
45
- () => {
46
- if (typeof require !== 'undefined') {
47
- try {
48
- return require('../package.json').version;
49
- }
50
- catch {
51
- const packagePath = path.join(process.cwd(), 'node_modules', '@kya-os', 'mcp-i', 'package.json');
52
- if (fs.existsSync(packagePath)) {
53
- return JSON.parse(fs.readFileSync(packagePath, 'utf-8')).version;
54
- }
55
- }
56
- }
57
- throw new Error('require not available');
58
- },
59
- () => {
60
- const possiblePaths = [
61
- path.join(__dirname, '..', 'package.json'),
62
- path.join(__dirname, '..', '..', 'package.json'),
63
- path.join(process.cwd(), 'packages', 'mcp-i', 'package.json')
64
- ];
65
- for (const packagePath of possiblePaths) {
66
- if (fs.existsSync(packagePath)) {
67
- return JSON.parse(fs.readFileSync(packagePath, 'utf-8')).version;
68
- }
69
- }
70
- throw new Error('package.json not found');
71
- },
72
- () => '0.1.0-alpha.3.6'
73
- ];
74
- for (const strategy of strategies) {
75
- try {
76
- return strategy();
77
- }
78
- catch {
79
- }
80
- }
81
- }
82
- catch {
83
- }
84
- return '0.1.0';
85
- }
86
- function detectPlatform() {
87
- try {
88
- if (typeof window !== 'undefined' && typeof window.document !== 'undefined') {
89
- return {
90
- platform: 'browser',
91
- runtime: 'browser',
92
- capabilities: {
93
- fileSystem: false,
94
- asyncRuntime: true,
95
- persistentStorage: true,
96
- longRunning: false
97
- }
98
- };
99
- }
100
- }
101
- catch {
102
- }
103
- if (typeof Deno !== 'undefined') {
104
- return {
105
- platform: 'deno',
106
- runtime: 'deno',
107
- version: Deno.version?.deno,
108
- capabilities: {
109
- fileSystem: true,
110
- asyncRuntime: true,
111
- persistentStorage: true,
112
- longRunning: true
113
- }
114
- };
115
- }
116
- if (typeof Bun !== 'undefined') {
117
- return {
118
- platform: 'bun',
119
- runtime: 'bun',
120
- version: Bun.version,
121
- capabilities: {
122
- fileSystem: true,
123
- asyncRuntime: true,
124
- persistentStorage: true,
125
- longRunning: true
126
- }
127
- };
128
- }
129
- if (typeof process !== 'undefined' && process.versions?.node) {
130
- let environment;
131
- if (process.env.VERCEL_EDGE || process.env.EDGE_RUNTIME) {
132
- return {
133
- platform: 'edge-light',
134
- runtime: 'vercel-edge',
135
- version: process.versions.node,
136
- environment: 'vercel',
137
- capabilities: {
138
- fileSystem: false,
139
- asyncRuntime: true,
140
- persistentStorage: false,
141
- longRunning: false
142
- }
143
- };
144
- }
145
- if (process.env.CF_WORKERS || (typeof globalThis !== 'undefined' && globalThis.caches)) {
146
- return {
147
- platform: 'edge-light',
148
- runtime: 'cloudflare-workers',
149
- environment: 'cloudflare',
150
- capabilities: {
151
- fileSystem: false,
152
- asyncRuntime: true,
153
- persistentStorage: true,
154
- longRunning: false
155
- }
156
- };
157
- }
158
- if (process.env.AWS_LAMBDA_FUNCTION_NAME || process.env.LAMBDA_TASK_ROOT) {
159
- environment = 'lambda';
160
- return {
161
- platform: 'node',
162
- runtime: 'node',
163
- version: process.versions.node,
164
- environment,
165
- capabilities: {
166
- fileSystem: true,
167
- asyncRuntime: true,
168
- persistentStorage: false,
169
- longRunning: false
170
- }
171
- };
172
- }
173
- if (process.env.VERCEL && !process.env.VERCEL_EDGE) {
174
- environment = 'vercel-functions';
175
- }
176
- if (process.env.NETLIFY) {
177
- environment = 'netlify-functions';
178
- }
179
- if (process.env.DOCKER_CONTAINER) {
180
- environment = 'docker';
181
- }
182
- else {
183
- try {
184
- if (fs.existsSync('/proc/1/cgroup') && fs.readFileSync('/proc/1/cgroup', 'utf-8').includes('docker')) {
185
- environment = 'docker';
186
- }
187
- }
188
- catch {
189
- }
190
- }
191
- if (process.env.NEXT_RUNTIME) {
192
- environment = `nextjs-${process.env.NEXT_RUNTIME}`;
193
- }
194
- return {
195
- platform: 'node',
196
- runtime: 'node',
197
- version: process.versions.node,
198
- environment,
199
- capabilities: {
200
- fileSystem: true,
201
- asyncRuntime: true,
202
- persistentStorage: true,
203
- longRunning: environment !== 'lambda' && environment !== 'vercel-functions'
204
- }
205
- };
206
- }
207
- return {
208
- platform: 'unknown',
209
- runtime: 'unknown',
210
- capabilities: {
211
- fileSystem: false,
212
- asyncRuntime: true,
213
- persistentStorage: false,
214
- longRunning: false
215
- }
216
- };
217
- }
218
- function generateClientInfo(options) {
219
- const platformInfo = detectPlatform();
220
- const sdkVersion = getSdkVersion();
221
- let defaultProcessingMode = 'sync';
222
- if (!platformInfo.capabilities.longRunning || platformInfo.platform === 'edge-light') {
223
- defaultProcessingMode = 'async';
224
- }
225
- const clientInfo = {
226
- sdkVersion,
227
- language: 'javascript',
228
- platform: platformInfo.platform,
229
- processingMode: options?.processingMode || defaultProcessingMode
230
- };
231
- if (platformInfo.runtime !== platformInfo.platform) {
232
- clientInfo.runtime = {
233
- name: platformInfo.runtime,
234
- version: platformInfo.version,
235
- environment: platformInfo.environment
236
- };
237
- }
238
- if (options?.customMetadata) {
239
- clientInfo.metadata = options.customMetadata;
240
- }
241
- return clientInfo;
242
- }
243
- function getPlatformRecommendations(platformInfo) {
244
- const info = platformInfo || detectPlatform();
245
- const recommendations = {
246
- storage: 'auto',
247
- transport: 'auto',
248
- processingMode: 'sync',
249
- logLevel: 'info'
250
- };
251
- if (!info.capabilities.fileSystem || !info.capabilities.persistentStorage) {
252
- recommendations.storage = 'memory';
253
- }
254
- else {
255
- recommendations.storage = 'file';
256
- }
257
- if (info.platform === 'edge-light' || info.platform === 'browser') {
258
- recommendations.transport = 'fetch';
259
- }
260
- if (!info.capabilities.longRunning) {
261
- recommendations.processingMode = 'async';
262
- }
263
- if (info.environment === 'lambda' || info.platform === 'edge-light') {
264
- recommendations.logLevel = 'error';
265
- }
266
- return recommendations;
267
- }
268
- let cachedPlatformInfo = null;
269
- function getCachedPlatformInfo() {
270
- if (!cachedPlatformInfo) {
271
- cachedPlatformInfo = detectPlatform();
272
- }
273
- return cachedPlatformInfo;
274
- }
@@ -1,13 +0,0 @@
1
- import { Transport } from './transport';
2
- import { AutoRegisterResponse } from './types';
3
- import { Logger } from './logger';
4
- export declare function pollRegistrationStatus(statusUrl: string, transport: Transport, options?: {
5
- pollInterval?: number;
6
- maxPollingTime?: number;
7
- logger?: Logger;
8
- onProgress?: (message: string, progress?: number) => void;
9
- }): Promise<AutoRegisterResponse>;
10
- export declare function isAsyncRegistrationResponse(response: any): response is {
11
- jobId: string;
12
- status: string;
13
- };
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pollRegistrationStatus = pollRegistrationStatus;
4
- exports.isAsyncRegistrationResponse = isAsyncRegistrationResponse;
5
- function sleep(ms) {
6
- return new Promise(resolve => setTimeout(resolve, ms));
7
- }
8
- async function pollRegistrationStatus(statusUrl, transport, options = {}) {
9
- const { pollInterval = 2000, maxPollingTime = 60000, logger, onProgress } = options;
10
- const startTime = Date.now();
11
- let attempts = 0;
12
- logger?.debug(`Starting registration polling: ${statusUrl}`);
13
- while (Date.now() - startTime < maxPollingTime) {
14
- attempts++;
15
- try {
16
- const response = await transport.get(statusUrl);
17
- const status = response.data;
18
- logger?.debug(`Poll attempt ${attempts}: ${status.status}`);
19
- const elapsed = Math.floor((Date.now() - startTime) / 1000);
20
- const progressMessage = `Registration ${status.status}... (${elapsed}s elapsed)`;
21
- if (onProgress) {
22
- onProgress(progressMessage, status.progress);
23
- }
24
- if (status.status === 'completed' && status.result) {
25
- logger?.info('Registration completed successfully');
26
- return status.result;
27
- }
28
- if (status.status === 'failed') {
29
- const errorMessage = status.error?.message || 'Registration failed';
30
- logger?.error(`Registration failed: ${errorMessage}`);
31
- throw new Error(errorMessage);
32
- }
33
- await sleep(pollInterval);
34
- }
35
- catch (error) {
36
- if (error.message && !error.message.includes('ECONNREFUSED')) {
37
- throw error;
38
- }
39
- logger?.debug(`Network error during polling (attempt ${attempts}): ${error.message}`);
40
- await sleep(pollInterval);
41
- }
42
- }
43
- const timeoutMessage = `Registration timeout after ${maxPollingTime / 1000} seconds`;
44
- logger?.error(timeoutMessage);
45
- throw new Error(timeoutMessage);
46
- }
47
- function isAsyncRegistrationResponse(response) {
48
- return response &&
49
- typeof response.jobId === 'string' &&
50
- typeof response.status === 'string' &&
51
- !response.did;
52
- }
@@ -1,12 +0,0 @@
1
- import { RegistryAdapter, RegistryName, RegistryTier } from "../types";
2
- export declare const REGISTRY_TIERS: Record<RegistryTier, RegistryName[]>;
3
- export declare class RegistryFactory {
4
- private static adapters;
5
- static getAdapter(name: RegistryName): RegistryAdapter | null;
6
- static getAdaptersByTier(tier: RegistryTier): RegistryAdapter[];
7
- static registerAdapter(name: string, factory: () => RegistryAdapter): void;
8
- }
9
- export declare function resolveRegistries(registries?: RegistryName[] | RegistryTier | {
10
- include?: RegistryName[] | RegistryTier;
11
- exclude?: RegistryName[];
12
- }): RegistryName[];
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RegistryFactory = exports.REGISTRY_TIERS = void 0;
4
- exports.resolveRegistries = resolveRegistries;
5
- const knowthat_1 = require("./knowthat");
6
- exports.REGISTRY_TIERS = {
7
- verified: ["knowthat"],
8
- };
9
- class RegistryFactory {
10
- static getAdapter(name) {
11
- const factory = this.adapters.get(name);
12
- return factory ? factory() : null;
13
- }
14
- static getAdaptersByTier(tier) {
15
- const registries = exports.REGISTRY_TIERS[tier] || [];
16
- return registries
17
- .map((name) => this.getAdapter(name))
18
- .filter((adapter) => adapter !== null);
19
- }
20
- static registerAdapter(name, factory) {
21
- this.adapters.set(name, factory);
22
- }
23
- }
24
- exports.RegistryFactory = RegistryFactory;
25
- RegistryFactory.adapters = new Map([
26
- ["knowthat", () => new knowthat_1.KnowThatRegistry()],
27
- ["knowthat.ai", () => new knowthat_1.KnowThatRegistry()],
28
- ]);
29
- function resolveRegistries(registries) {
30
- if (!registries) {
31
- return exports.REGISTRY_TIERS.verified;
32
- }
33
- if (Array.isArray(registries)) {
34
- return registries;
35
- }
36
- if (typeof registries === "string") {
37
- return exports.REGISTRY_TIERS[registries] || [];
38
- }
39
- const config = registries;
40
- let included = [];
41
- if (config.include) {
42
- if (Array.isArray(config.include)) {
43
- included = config.include;
44
- }
45
- else {
46
- included = exports.REGISTRY_TIERS[config.include] || [];
47
- }
48
- }
49
- else {
50
- included = exports.REGISTRY_TIERS.verified;
51
- }
52
- if (config.exclude && config.exclude.length > 0) {
53
- return included.filter((name) => !config.exclude.includes(name));
54
- }
55
- return included;
56
- }
@@ -1,17 +0,0 @@
1
- import { RegistryAdapter, RegistryPublishData, RegistryPublishResult, RegistryStatus, MCPIdentityOptions } from '../types';
2
- import { Transport } from '../transport';
3
- export declare class KnowThatRegistry implements RegistryAdapter {
4
- name: string;
5
- type: 'primary' | 'secondary';
6
- private endpoint;
7
- private transport;
8
- private options?;
9
- constructor(endpoint?: string, transport?: Transport, options?: MCPIdentityOptions);
10
- private publishViaCLI;
11
- private shouldUseCLIEndpoint;
12
- publish(data: RegistryPublishData): Promise<RegistryPublishResult>;
13
- private publishViaAutoRegister;
14
- verify(did: string): Promise<boolean>;
15
- getStatus(did: string): Promise<RegistryStatus>;
16
- private extractAgentSlug;
17
- }