@kya-os/mcp-i 0.1.0-alpha.3.2 → 0.1.0-alpha.3.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.
@@ -0,0 +1,16 @@
1
+ import { MCPIdentityOptions, MCPIdentityProgressCallback } from './types.js';
2
+ import { MCPIdentity } from './index.js';
3
+ interface MCPIdentityCLIOptions extends Omit<MCPIdentityOptions, 'logLevel'> {
4
+ logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'silent';
5
+ onProgress?: MCPIdentityProgressCallback;
6
+ }
7
+ export declare function enableMCPIdentityCLI(options?: MCPIdentityCLIOptions): Promise<{
8
+ identity: MCPIdentity;
9
+ metadata: {
10
+ isNewIdentity: boolean;
11
+ did: string;
12
+ claimUrl?: string;
13
+ registryUrl: string;
14
+ };
15
+ }>;
16
+ export type { MCPIdentityProgressEvent, MCPIdentityProgressCallback } from './types.js';
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enableMCPIdentityCLI = enableMCPIdentityCLI;
4
+ const index_js_1 = require("./index.js");
5
+ async function enableMCPIdentityCLI(options) {
6
+ let isNewIdentity = false;
7
+ let capturedClaimUrl;
8
+ const wrappedProgress = (event) => {
9
+ if (event.stage === 'complete' && event.data?.claimUrl) {
10
+ capturedClaimUrl = event.data.claimUrl;
11
+ }
12
+ if (event.stage === 'generating_keys') {
13
+ isNewIdentity = true;
14
+ }
15
+ options?.onProgress?.(event);
16
+ };
17
+ const identity = await (0, index_js_1.enableMCPIdentity)({
18
+ ...options,
19
+ logLevel: options?.logLevel || 'silent',
20
+ onProgress: wrappedProgress
21
+ });
22
+ const did = identity.did;
23
+ return {
24
+ identity,
25
+ metadata: {
26
+ isNewIdentity,
27
+ did,
28
+ claimUrl: capturedClaimUrl,
29
+ registryUrl: 'https://knowthat.ai/agents/' + did.split(':').pop()
30
+ }
31
+ };
32
+ }
@@ -8,6 +8,7 @@ export { StorageFactory, MemoryStorage, FileStorage } from './storage';
8
8
  export { TransportFactory, RuntimeDetector } from './transport';
9
9
  export { KeyRotationManager } from './rotation';
10
10
  export { initWithDevExperience, showAgentStatus } from './dev-helper';
11
+ export { pollRegistrationStatus, isAsyncRegistrationResponse } from './polling';
11
12
  export declare class MCPIdentity {
12
13
  readonly did: string;
13
14
  readonly publicKey: string;
package/dist/cjs/index.js CHANGED
@@ -36,7 +36,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.MCPIdentity = exports.showAgentStatus = exports.initWithDevExperience = exports.KeyRotationManager = exports.RuntimeDetector = exports.TransportFactory = exports.FileStorage = exports.MemoryStorage = exports.StorageFactory = exports.SilentLogger = exports.ConsoleLogger = exports.LoggerFactory = exports.resolveRegistries = exports.REGISTRY_TIERS = exports.RegistryFactory = void 0;
39
+ exports.MCPIdentity = exports.isAsyncRegistrationResponse = exports.pollRegistrationStatus = exports.showAgentStatus = exports.initWithDevExperience = exports.KeyRotationManager = exports.RuntimeDetector = exports.TransportFactory = exports.FileStorage = exports.MemoryStorage = exports.StorageFactory = exports.SilentLogger = exports.ConsoleLogger = exports.LoggerFactory = exports.resolveRegistries = exports.REGISTRY_TIERS = exports.RegistryFactory = void 0;
40
40
  exports.enableMCPIdentity = enableMCPIdentity;
41
41
  exports.createMCPMiddleware = createMCPMiddleware;
42
42
  const crypto = __importStar(require("./crypto"));
@@ -45,6 +45,7 @@ const transport_1 = require("./transport");
45
45
  const logger_1 = require("./logger");
46
46
  const rotation_1 = require("./rotation");
47
47
  const vercel_adapter_1 = require("./vercel-adapter");
48
+ const polling_1 = require("./polling");
48
49
  __exportStar(require("./types"), exports);
49
50
  __exportStar(require("./vercel-adapter"), exports);
50
51
  var registry_1 = require("./registry");
@@ -67,6 +68,9 @@ Object.defineProperty(exports, "KeyRotationManager", { enumerable: true, get: fu
67
68
  var dev_helper_1 = require("./dev-helper");
68
69
  Object.defineProperty(exports, "initWithDevExperience", { enumerable: true, get: function () { return dev_helper_1.initWithDevExperience; } });
69
70
  Object.defineProperty(exports, "showAgentStatus", { enumerable: true, get: function () { return dev_helper_1.showAgentStatus; } });
71
+ var polling_2 = require("./polling");
72
+ Object.defineProperty(exports, "pollRegistrationStatus", { enumerable: true, get: function () { return polling_2.pollRegistrationStatus; } });
73
+ Object.defineProperty(exports, "isAsyncRegistrationResponse", { enumerable: true, get: function () { return polling_2.isAsyncRegistrationResponse; } });
70
74
  let globalIdentity = null;
71
75
  class MCPIdentity {
72
76
  constructor(identity, options = {}) {
@@ -108,17 +112,28 @@ class MCPIdentity {
108
112
  }
109
113
  }
110
114
  static async init(options) {
111
- const logger = options?.logger || (0, logger_1.getLogger)();
115
+ const logger = options?.logger || (0, logger_1.getLogger)(options?.logLevel);
112
116
  if (globalIdentity) {
113
117
  return globalIdentity;
114
118
  }
115
119
  const isVercel = process.env.VERCEL || process.env.VERCEL_ENV;
116
120
  const isServerless = isVercel || process.env.AWS_LAMBDA_FUNCTION_NAME || process.env.FUNCTIONS_WORKER_RUNTIME;
121
+ options?.onProgress?.({
122
+ stage: 'checking_existing',
123
+ progress: 10,
124
+ message: 'Checking for existing identity...'
125
+ });
117
126
  let identity = null;
118
127
  if (isServerless || options?.storage === 'memory') {
119
128
  identity = (0, vercel_adapter_1.loadIdentityFromEnv)();
120
129
  if (identity) {
121
130
  logger.info('✅ Loaded existing identity from environment variables');
131
+ options?.onProgress?.({
132
+ stage: 'complete',
133
+ progress: 100,
134
+ message: 'Loaded existing identity from environment',
135
+ data: { did: identity.did }
136
+ });
122
137
  }
123
138
  }
124
139
  const storage = storage_1.StorageFactory.create({
@@ -132,6 +147,12 @@ class MCPIdentity {
132
147
  }
133
148
  if (identity) {
134
149
  logger.info('Loaded existing identity:', identity.did);
150
+ options?.onProgress?.({
151
+ stage: 'complete',
152
+ progress: 100,
153
+ message: 'Loaded existing identity',
154
+ data: { did: identity.did }
155
+ });
135
156
  globalIdentity = new MCPIdentity(identity, options);
136
157
  return globalIdentity;
137
158
  }
@@ -142,7 +163,17 @@ class MCPIdentity {
142
163
  const apiEndpoint = options?.apiEndpoint || 'https://knowthat.ai';
143
164
  logger.info('Registering with knowthat.ai...');
144
165
  logger.info('Generating cryptographic keys...');
166
+ options?.onProgress?.({
167
+ stage: 'generating_keys',
168
+ progress: 30,
169
+ message: 'Generating cryptographic keys...'
170
+ });
145
171
  const keyPair = await crypto.generateKeyPair();
172
+ options?.onProgress?.({
173
+ stage: 'generating_keys',
174
+ progress: 50,
175
+ message: 'Keys generated successfully'
176
+ });
146
177
  const registrationData = {
147
178
  name: options?.name || process.env.MCP_SERVER_NAME || 'Unnamed MCP Server',
148
179
  description: options?.description,
@@ -161,10 +192,21 @@ class MCPIdentity {
161
192
  });
162
193
  let response;
163
194
  try {
195
+ options?.onProgress?.({
196
+ stage: 'registering',
197
+ progress: 60,
198
+ message: 'Registering with KYA-OS network...'
199
+ });
164
200
  response = await autoRegister(transport, {
165
201
  ...registrationData,
166
202
  apiEndpoint,
167
- directories: options?.directories
203
+ directories: options?.directories,
204
+ onProgress: options?.onProgress
205
+ });
206
+ options?.onProgress?.({
207
+ stage: 'registering',
208
+ progress: 80,
209
+ message: 'Registration successful'
168
210
  });
169
211
  }
170
212
  catch (registrationError) {
@@ -202,7 +244,24 @@ class MCPIdentity {
202
244
  registeredAt: new Date().toISOString(),
203
245
  directories: options?.directories || 'verified'
204
246
  };
247
+ options?.onProgress?.({
248
+ stage: 'saving',
249
+ progress: 90,
250
+ message: 'Saving identity...'
251
+ });
205
252
  await storage.save(identity);
253
+ options?.onProgress?.({
254
+ stage: 'complete',
255
+ progress: 100,
256
+ message: 'Identity created successfully',
257
+ data: {
258
+ did: identity.did,
259
+ publicKey: identity.publicKey,
260
+ agentId: identity.agentId,
261
+ agentSlug: identity.agentSlug,
262
+ claimUrl: response.agent.claimUrl
263
+ }
264
+ });
206
265
  if (isServerless) {
207
266
  (0, vercel_adapter_1.showVercelDeveloperInstructions)(identity, response.agent.claimUrl);
208
267
  }
@@ -537,9 +596,35 @@ async function autoRegister(transport, options) {
537
596
  logger.debug('Registration response received:', {
538
597
  status: response.status,
539
598
  hasData: !!response.data,
540
- hasDid: !!response.data?.did,
541
- hasAgent: !!response.data?.agent
599
+ isAsync: response.status === 202
542
600
  });
601
+ if (response.status === 202 && (0, polling_1.isAsyncRegistrationResponse)(response.data)) {
602
+ logger.info('Registration submitted, waiting for completion...');
603
+ options.onProgress?.({
604
+ stage: 'registering',
605
+ progress: 70,
606
+ message: 'Registration submitted, processing...',
607
+ data: { jobId: response.data.jobId }
608
+ });
609
+ const result = await (0, polling_1.pollRegistrationStatus)(response.data.status, transport, {
610
+ pollInterval: 2000,
611
+ maxPollingTime: 60000,
612
+ logger,
613
+ onProgress: (message, progress) => {
614
+ options.onProgress?.({
615
+ stage: 'registering',
616
+ progress: 70 + (progress || 0) * 0.1,
617
+ message
618
+ });
619
+ }
620
+ });
621
+ logger.debug('Registration completed after polling:', {
622
+ hasDid: !!result.did,
623
+ hasAgent: !!result.agent
624
+ });
625
+ return result;
626
+ }
627
+ logger.debug('Got synchronous registration response');
543
628
  return response.data;
544
629
  }
545
630
  catch (error) {
@@ -29,4 +29,4 @@ export declare class LoggerFactory {
29
29
  static createSilentLogger(): Logger;
30
30
  static reset(): void;
31
31
  }
32
- export declare function getLogger(): Logger;
32
+ export declare function getLogger(logLevel?: LogLevel): Logger;
@@ -74,6 +74,12 @@ class LoggerFactory {
74
74
  }
75
75
  exports.LoggerFactory = LoggerFactory;
76
76
  LoggerFactory.instance = new SilentLogger();
77
- function getLogger() {
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
+ }
78
84
  return LoggerFactory.getLogger();
79
85
  }
@@ -1,10 +1,10 @@
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';
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
6
  showSetupInstructions?: boolean;
7
7
  }
8
8
  export declare function enableMCPIdentityForNextJS(options?: NextJSMCPOptions): Promise<MCPIdentity>;
9
- export { enableMCPIdentity, MCPIdentity } from './index';
10
- export * from './types';
9
+ export { enableMCPIdentity, MCPIdentity } from "./index";
10
+ export * from "./types";
@@ -18,59 +18,60 @@ exports.MCPIdentity = exports.enableMCPIdentity = void 0;
18
18
  exports.enableMCPIdentityForNextJS = enableMCPIdentityForNextJS;
19
19
  const index_1 = require("./index");
20
20
  async function enableMCPIdentityForNextJS(options = {}) {
21
- const isProduction = process.env.NODE_ENV === 'production';
21
+ const isProduction = process.env.NODE_ENV === "production";
22
22
  const isVercel = process.env.VERCEL || process.env.VERCEL_ENV;
23
23
  try {
24
24
  console.log(`\n🚀 Initializing MCP-I for Next.js...`);
25
25
  const identity = await (0, index_1.enableMCPIdentity)({
26
26
  ...options,
27
- transport: 'fetch',
28
- storage: 'memory',
29
- logLevel: options.logLevel || (isProduction ? 'error' : 'info'),
30
- mode: isProduction ? 'production' : 'development',
27
+ transport: "fetch",
28
+ storage: "memory",
29
+ logLevel: options.logLevel || (isProduction ? "error" : "info"),
30
+ mode: isProduction ? "production" : "development",
31
31
  });
32
32
  if (!isProduction && options.showSetupInstructions !== false) {
33
- console.log('\n✅ MCP-I Ready for Next.js!');
33
+ console.log("\n✅ MCP-I Ready for Next.js!");
34
34
  console.log(`\n📋 Quick Info:`);
35
- console.log(` Environment: ${isVercel ? 'Vercel' : 'Local'}`);
35
+ console.log(` Environment: ${isVercel ? "Vercel" : "Local"}`);
36
36
  console.log(` DID: ${identity.did}`);
37
- if (isVercel && !process.env.MCP_IDENTITY_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.');
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
40
  }
41
41
  }
42
42
  return identity;
43
43
  }
44
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');
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
53
  }
54
- else if (error?.message?.includes('500') || error?.message?.includes('fetch failed')) {
55
- console.error('📛 Server Connection Error');
56
- console.error(' Cannot connect to knowthat.ai registry.');
57
- console.error('\n💡 Possible causes:');
58
- console.error(' - Registry is temporarily down');
59
- console.error(' - Network connectivity issues');
60
- console.error(' - Firewall blocking outbound connections');
61
- console.error('\n💡 Workaround for development:');
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:");
62
63
  console.error(' Add to your route: mode: "development" to allow offline mode');
63
64
  }
64
- else if (error?.message?.includes('MODULE_NOT_FOUND')) {
65
- console.error('📛 Missing Dependencies');
66
- console.error(' Make sure all dependencies are installed:');
67
- console.error(' npm install @kya-os/mcp-i');
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");
68
69
  }
69
70
  else {
70
- console.error('📛 Unexpected Error:', error?.message || error);
71
+ console.error("📛 Unexpected Error:", error?.message || error);
71
72
  }
72
73
  if (!isProduction) {
73
- console.error('\n🔍 Full Error Details:');
74
+ console.error("\n🔍 Full Error Details:");
74
75
  console.error(error);
75
76
  }
76
77
  throw error;
@@ -0,0 +1,13 @@
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
+ };
@@ -0,0 +1,52 @@
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
+ }
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.KnowThatRegistry = void 0;
4
4
  const transport_1 = require("../transport");
5
+ const polling_1 = require("../polling");
6
+ const logger_1 = require("../logger");
5
7
  class KnowThatRegistry {
6
8
  constructor(endpoint = 'https://knowthat.ai', transport) {
7
9
  this.name = 'knowthat';
@@ -10,6 +12,7 @@ class KnowThatRegistry {
10
12
  this.transport = transport || transport_1.TransportFactory.create();
11
13
  }
12
14
  async publish(data) {
15
+ const logger = (0, logger_1.getLogger)();
13
16
  try {
14
17
  const response = await this.transport.post(`${this.endpoint}/api/agents/auto-register`, {
15
18
  metadata: {
@@ -31,10 +34,27 @@ class KnowThatRegistry {
31
34
  'User-Agent': '@kya-os/mcp-i/0.2.0'
32
35
  }
33
36
  });
37
+ if (response.status === 202 && (0, polling_1.isAsyncRegistrationResponse)(response.data)) {
38
+ logger.debug('Got async registration response, polling for completion...');
39
+ const result = await (0, polling_1.pollRegistrationStatus)(response.data.status, this.transport, {
40
+ pollInterval: 2000,
41
+ maxPollingTime: 60000,
42
+ logger,
43
+ onProgress: (message) => {
44
+ logger.debug(message);
45
+ }
46
+ });
47
+ return {
48
+ success: true,
49
+ registryAgentId: result.agent.id,
50
+ profileUrl: result.agent.url
51
+ };
52
+ }
53
+ const syncResponse = response.data;
34
54
  return {
35
55
  success: true,
36
- registryAgentId: response.data.agent.id,
37
- profileUrl: response.data.agent.url
56
+ registryAgentId: syncResponse.agent.id,
57
+ profileUrl: syncResponse.agent.url
38
58
  };
39
59
  }
40
60
  catch (error) {
@@ -33,6 +33,15 @@ export interface RegistryPublishResult {
33
33
  }
34
34
  export type DirectoryPreference = string[] | 'verified' | 'none';
35
35
  export type DirectoryName = 'smithery' | 'glama' | string;
36
+ export interface MCPIdentityProgressEvent {
37
+ stage: 'checking_existing' | 'generating_keys' | 'registering' | 'saving' | 'complete';
38
+ progress: number;
39
+ message?: string;
40
+ data?: any;
41
+ }
42
+ export interface MCPIdentityProgressCallback {
43
+ (event: MCPIdentityProgressEvent): void;
44
+ }
36
45
  export interface MCPIdentityOptions {
37
46
  name?: string;
38
47
  description?: string;
@@ -49,6 +58,10 @@ export interface MCPIdentityOptions {
49
58
  mode?: 'development' | 'production';
50
59
  logger?: Logger;
51
60
  logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'silent';
61
+ onProgress?: MCPIdentityProgressCallback;
62
+ registrationPollInterval?: number;
63
+ registrationMaxPollingTime?: number;
64
+ registrationPollBackoff?: boolean;
52
65
  }
53
66
  export interface MCPServer {
54
67
  setRequestHandler(method: string, handler: Function): void;
@@ -91,6 +104,24 @@ export interface AutoRegisterResponse {
91
104
  privateKey?: string;
92
105
  };
93
106
  }
107
+ export interface AsyncRegistrationResponse {
108
+ success: boolean;
109
+ jobId: string;
110
+ status: string;
111
+ message: string;
112
+ estimatedTime: string;
113
+ }
114
+ export interface RegistrationStatusResponse {
115
+ jobId: string;
116
+ status: 'pending' | 'processing' | 'completed' | 'failed';
117
+ result?: AutoRegisterResponse;
118
+ error?: {
119
+ message: string;
120
+ code?: string;
121
+ };
122
+ progress?: number;
123
+ estimatedTimeRemaining?: number;
124
+ }
94
125
  export interface PersistedIdentity {
95
126
  did: string;
96
127
  publicKey: string;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * CLI Mode for MCP-I Package
3
+ * @internal - For use by @kya-os/cli package only
4
+ * @private
5
+ *
6
+ * This module provides a specialized interface for the KYA-OS CLI
7
+ * with enhanced progress reporting and silent logging by default.
8
+ */
9
+ import { MCPIdentityOptions, MCPIdentityProgressCallback } from './types.js';
10
+ import { MCPIdentity } from './index.js';
11
+ /**
12
+ * CLI-specific options that extend the base options
13
+ * @internal
14
+ */
15
+ interface MCPIdentityCLIOptions extends Omit<MCPIdentityOptions, 'logLevel'> {
16
+ /**
17
+ * Log level - defaults to 'silent' for CLI usage
18
+ */
19
+ logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'silent';
20
+ /**
21
+ * Progress callback is strongly recommended for CLI usage
22
+ */
23
+ onProgress?: MCPIdentityProgressCallback;
24
+ }
25
+ /**
26
+ * Enable MCP Identity with CLI-optimized defaults
27
+ * @internal - For use by @kya-os/cli package only
28
+ *
29
+ * This function:
30
+ * - Sets silent logging by default
31
+ * - Provides structured progress events
32
+ * - Returns additional metadata useful for CLI animations
33
+ * - Optimizes for the best CLI experience
34
+ *
35
+ * @param options Configuration options
36
+ * @returns MCPIdentity instance with additional CLI metadata
37
+ */
38
+ export declare function enableMCPIdentityCLI(options?: MCPIdentityCLIOptions): Promise<{
39
+ identity: MCPIdentity;
40
+ metadata: {
41
+ isNewIdentity: boolean;
42
+ did: string;
43
+ claimUrl?: string;
44
+ registryUrl: string;
45
+ };
46
+ }>;
47
+ /**
48
+ * Re-export types that CLI might need
49
+ * @internal
50
+ */
51
+ export type { MCPIdentityProgressEvent, MCPIdentityProgressCallback } from './types.js';
52
+ //# sourceMappingURL=cli-mode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-mode.d.ts","sourceRoot":"","sources":["../../src/cli-mode.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC;;;GAGG;AACH,UAAU,qBAAsB,SAAQ,IAAI,CAAC,kBAAkB,EAAE,UAAU,CAAC;IAC1E;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAE1D;;OAEG;IACH,UAAU,CAAC,EAAE,2BAA2B,CAAC;CAC1C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC;IACT,QAAQ,EAAE,WAAW,CAAC;IACtB,QAAQ,EAAE;QACR,aAAa,EAAE,OAAO,CAAC;QACvB,GAAG,EAAE,MAAM,CAAC;QACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH,CAAC,CAyCD;AAED;;;GAGG;AACH,YAAY,EACV,wBAAwB,EACxB,2BAA2B,EAC5B,MAAM,YAAY,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * CLI Mode for MCP-I Package
3
+ * @internal - For use by @kya-os/cli package only
4
+ * @private
5
+ *
6
+ * This module provides a specialized interface for the KYA-OS CLI
7
+ * with enhanced progress reporting and silent logging by default.
8
+ */
9
+ import { enableMCPIdentity } from './index.js';
10
+ /**
11
+ * Enable MCP Identity with CLI-optimized defaults
12
+ * @internal - For use by @kya-os/cli package only
13
+ *
14
+ * This function:
15
+ * - Sets silent logging by default
16
+ * - Provides structured progress events
17
+ * - Returns additional metadata useful for CLI animations
18
+ * - Optimizes for the best CLI experience
19
+ *
20
+ * @param options Configuration options
21
+ * @returns MCPIdentity instance with additional CLI metadata
22
+ */
23
+ export async function enableMCPIdentityCLI(options) {
24
+ // Track if this is a new identity
25
+ let isNewIdentity = false;
26
+ let capturedClaimUrl;
27
+ // Wrap the progress callback to capture metadata
28
+ const wrappedProgress = (event) => {
29
+ // Capture claim URL from complete event
30
+ if (event.stage === 'complete' && event.data?.claimUrl) {
31
+ capturedClaimUrl = event.data.claimUrl;
32
+ }
33
+ // Detect if this is a new identity
34
+ if (event.stage === 'generating_keys') {
35
+ isNewIdentity = true;
36
+ }
37
+ // Call the original callback if provided
38
+ options?.onProgress?.(event);
39
+ };
40
+ // Initialize with CLI-optimized defaults
41
+ const identity = await enableMCPIdentity({
42
+ ...options,
43
+ logLevel: options?.logLevel || 'silent', // Silent by default
44
+ onProgress: wrappedProgress
45
+ });
46
+ // Get DID for metadata
47
+ const did = identity.did;
48
+ // Return identity with additional CLI metadata
49
+ return {
50
+ identity,
51
+ metadata: {
52
+ isNewIdentity,
53
+ did,
54
+ claimUrl: capturedClaimUrl,
55
+ registryUrl: 'https://knowthat.ai/agents/' + did.split(':').pop()
56
+ }
57
+ };
58
+ }
59
+ //# sourceMappingURL=cli-mode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-mode.js","sourceRoot":"","sources":["../../src/cli-mode.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAoB/C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,OAA+B;IAU/B,kCAAkC;IAClC,IAAI,aAAa,GAAG,KAAK,CAAC;IAC1B,IAAI,gBAAoC,CAAC;IAEzC,iDAAiD;IACjD,MAAM,eAAe,GAAgC,CAAC,KAAK,EAAE,EAAE;QAC7D,wCAAwC;QACxC,IAAI,KAAK,CAAC,KAAK,KAAK,UAAU,IAAI,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC;YACvD,gBAAgB,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;QACzC,CAAC;QAED,mCAAmC;QACnC,IAAI,KAAK,CAAC,KAAK,KAAK,iBAAiB,EAAE,CAAC;YACtC,aAAa,GAAG,IAAI,CAAC;QACvB,CAAC;QAED,yCAAyC;QACzC,OAAO,EAAE,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC,CAAC;IAEF,yCAAyC;IACzC,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC;QACvC,GAAG,OAAO;QACV,QAAQ,EAAE,OAAO,EAAE,QAAQ,IAAI,QAAQ,EAAE,oBAAoB;QAC7D,UAAU,EAAE,eAAe;KAC5B,CAAC,CAAC;IAEH,uBAAuB;IACvB,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;IAEzB,+CAA+C;IAC/C,OAAO;QACL,QAAQ;QACR,QAAQ,EAAE;YACR,aAAa;YACb,GAAG;YACH,QAAQ,EAAE,gBAAgB;YAC1B,WAAW,EAAE,6BAA6B,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE;SAClE;KACF,CAAC;AACJ,CAAC"}