@kya-os/mcp-i 1.5.9 → 1.6.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.
- package/dist/295.js +1 -1
- package/dist/cli-adapter/index.d.ts +2 -0
- package/dist/cli-adapter/index.js +9 -5
- package/dist/cli-adapter/kta-registration.d.ts +9 -0
- package/dist/cli-adapter/kta-registration.js +75 -0
- package/dist/compiler/get-webpack-config/index.js +11 -2
- package/dist/index.js.LICENSE.txt +0 -6
- package/dist/runtime/adapter-express.js +1 -1
- package/dist/runtime/adapter-nextjs.js +1 -1
- package/dist/runtime/audit.d.ts +53 -0
- package/dist/runtime/audit.js +62 -0
- package/dist/runtime/http.js +1 -1
- package/dist/runtime/identity.d.ts +12 -0
- package/dist/runtime/identity.js +15 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/mcpi-runtime-wrapper.d.ts +2 -3
- package/dist/runtime/mcpi-runtime-wrapper.js +20 -17
- package/dist/runtime/stdio.js +1 -1
- package/package.json +22 -18
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.enableMCPIdentityCLI = enableMCPIdentityCLI;
|
|
11
11
|
const identity_1 = require("../runtime/identity");
|
|
12
|
+
const did_helpers_1 = require("@kya-os/mcp-i-core/utils/did-helpers");
|
|
12
13
|
const kta_registration_1 = require("./kta-registration");
|
|
13
14
|
/**
|
|
14
15
|
* Enable MCP Identity for CLI
|
|
@@ -52,7 +53,8 @@ async function enableMCPIdentityCLI(options = {}) {
|
|
|
52
53
|
if (!skipRegistration && isNewIdentity) {
|
|
53
54
|
await emitProgress("registering", "Registering with Know-That-AI...");
|
|
54
55
|
try {
|
|
55
|
-
|
|
56
|
+
// Use fast CLI registration endpoint for immediate response
|
|
57
|
+
registrationResult = await (0, kta_registration_1.registerWithKTACLI)({
|
|
56
58
|
did: identity.did,
|
|
57
59
|
publicKey: identity.publicKey,
|
|
58
60
|
kid: identity.kid,
|
|
@@ -74,10 +76,10 @@ async function enableMCPIdentityCLI(options = {}) {
|
|
|
74
76
|
await emitProgress("complete", "Identity setup complete!", {
|
|
75
77
|
claimUrl: capturedClaimUrl,
|
|
76
78
|
});
|
|
77
|
-
//
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
const registryUrl = `https://knowthat.ai/agents/${
|
|
79
|
+
// Use agent metadata from registration result if available, otherwise extract from DID
|
|
80
|
+
const agentId = registrationResult?.agentId || (0, did_helpers_1.extractAgentId)(identity.did);
|
|
81
|
+
const agentSlug = registrationResult?.agentSlug || (0, did_helpers_1.extractAgentSlug)(identity.did);
|
|
82
|
+
const registryUrl = registrationResult?.agentURL || `https://knowthat.ai/agents/${agentSlug}`;
|
|
81
83
|
return {
|
|
82
84
|
identity,
|
|
83
85
|
metadata: {
|
|
@@ -85,6 +87,8 @@ async function enableMCPIdentityCLI(options = {}) {
|
|
|
85
87
|
did: identity.did,
|
|
86
88
|
claimUrl: capturedClaimUrl,
|
|
87
89
|
registryUrl,
|
|
90
|
+
agentId,
|
|
91
|
+
agentSlug,
|
|
88
92
|
},
|
|
89
93
|
};
|
|
90
94
|
}
|
|
@@ -24,7 +24,9 @@ export interface KTARegistrationResult {
|
|
|
24
24
|
agentDID: string;
|
|
25
25
|
agentURL: string;
|
|
26
26
|
agentId: string;
|
|
27
|
+
agentSlug: string;
|
|
27
28
|
claimURL: string;
|
|
29
|
+
claimToken?: string;
|
|
28
30
|
verificationEndpoint: string;
|
|
29
31
|
conformanceCapabilities: readonly string[];
|
|
30
32
|
mirrorStatus: "pending" | "success" | "error";
|
|
@@ -37,3 +39,10 @@ export interface KTARegistrationResult {
|
|
|
37
39
|
* Returns registration details including claim URL.
|
|
38
40
|
*/
|
|
39
41
|
export declare function registerWithKTA(options: KTARegistrationOptions): Promise<KTARegistrationResult>;
|
|
42
|
+
/**
|
|
43
|
+
* Register agent with Know-That-AI using fast CLI endpoint
|
|
44
|
+
*
|
|
45
|
+
* Uses the /cli-register endpoint which returns immediately without polling.
|
|
46
|
+
* Returns claimUrl and claimToken for browser-based claiming.
|
|
47
|
+
*/
|
|
48
|
+
export declare function registerWithKTACLI(options: KTARegistrationOptions): Promise<KTARegistrationResult>;
|
|
@@ -10,6 +10,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.registerWithKTA = registerWithKTA;
|
|
13
|
+
exports.registerWithKTACLI = registerWithKTACLI;
|
|
13
14
|
const axios_1 = __importDefault(require("axios"));
|
|
14
15
|
/**
|
|
15
16
|
* MCP-I Capabilities (from contracts)
|
|
@@ -62,7 +63,9 @@ async function registerWithKTA(options) {
|
|
|
62
63
|
agentDID: did,
|
|
63
64
|
agentURL: data.agentURL || data.agentUrl || `${endpoint}/agents/by-did/${encodeURIComponent(did)}`,
|
|
64
65
|
agentId: data.agentId || agentId,
|
|
66
|
+
agentSlug: data.agentSlug || data.agent?.slug || agentId,
|
|
65
67
|
claimURL: data.claimURL || data.claimUrl || `${endpoint}/claim/${agentId}`,
|
|
68
|
+
claimToken: data.claimToken,
|
|
66
69
|
verificationEndpoint,
|
|
67
70
|
conformanceCapabilities: MCP_I_CAPABILITIES,
|
|
68
71
|
mirrorStatus: data.mirrorStatus || "pending",
|
|
@@ -91,3 +94,75 @@ async function registerWithKTA(options) {
|
|
|
91
94
|
throw new Error(`Failed to register with KTA: ${error.message}`);
|
|
92
95
|
}
|
|
93
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Register agent with Know-That-AI using fast CLI endpoint
|
|
99
|
+
*
|
|
100
|
+
* Uses the /cli-register endpoint which returns immediately without polling.
|
|
101
|
+
* Returns claimUrl and claimToken for browser-based claiming.
|
|
102
|
+
*/
|
|
103
|
+
async function registerWithKTACLI(options) {
|
|
104
|
+
const { did, publicKey, kid, name, description, repository, endpoint = "https://knowthat.ai", } = options;
|
|
105
|
+
try {
|
|
106
|
+
// Construct verification endpoint from DID
|
|
107
|
+
const verificationEndpoint = did.includes("localhost")
|
|
108
|
+
? `http://localhost:3000/.well-known/did.json`
|
|
109
|
+
: `${did.replace("did:web:", "https://").replace(":", "/")}/.well-known/did.json`;
|
|
110
|
+
// Prepare registration payload for CLI endpoint
|
|
111
|
+
const payload = {
|
|
112
|
+
name,
|
|
113
|
+
description,
|
|
114
|
+
githubRepo: repository,
|
|
115
|
+
publicKey,
|
|
116
|
+
kid,
|
|
117
|
+
did,
|
|
118
|
+
verificationEndpoint,
|
|
119
|
+
capabilities: MCP_I_CAPABILITIES,
|
|
120
|
+
};
|
|
121
|
+
// Make registration request to CLI endpoint
|
|
122
|
+
const response = await axios_1.default.post(`${endpoint}/api/agents/cli-register`, payload, {
|
|
123
|
+
headers: {
|
|
124
|
+
"Content-Type": "application/json",
|
|
125
|
+
"User-Agent": "@kya-os/mcp-i-cli",
|
|
126
|
+
},
|
|
127
|
+
timeout: 30000, // 30 second timeout
|
|
128
|
+
});
|
|
129
|
+
const data = response.data;
|
|
130
|
+
// Extract agent ID and slug from response
|
|
131
|
+
const agentId = data.agent?.id || did.split(":").pop() || `agent-${Date.now()}`;
|
|
132
|
+
const agentSlug = data.agent?.slug || agentId;
|
|
133
|
+
// Build result structure from CLI registration response
|
|
134
|
+
const result = {
|
|
135
|
+
agentDID: data.did || did,
|
|
136
|
+
agentURL: data.agent?.url || `${endpoint}/agents/${agentSlug}`,
|
|
137
|
+
agentId,
|
|
138
|
+
agentSlug,
|
|
139
|
+
claimURL: data.claimUrl || `${endpoint}/agents/claim?did=${encodeURIComponent(did)}`,
|
|
140
|
+
claimToken: data.claimToken,
|
|
141
|
+
verificationEndpoint,
|
|
142
|
+
conformanceCapabilities: MCP_I_CAPABILITIES,
|
|
143
|
+
mirrorStatus: "pending", // CLI register doesn't poll for mirror status
|
|
144
|
+
mirrorLink: `${endpoint}/agents/pending`,
|
|
145
|
+
};
|
|
146
|
+
return result;
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
// Handle different error types
|
|
150
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
151
|
+
if (error.code === "ECONNREFUSED") {
|
|
152
|
+
throw new Error(`Could not connect to KTA registry at ${endpoint}. ` +
|
|
153
|
+
"Please check your internet connection or try again later.");
|
|
154
|
+
}
|
|
155
|
+
if (error.response?.status === 503) {
|
|
156
|
+
throw new Error("KTA registry is temporarily unavailable (maintenance mode). " +
|
|
157
|
+
"Please try again in a few minutes.");
|
|
158
|
+
}
|
|
159
|
+
if (error.response?.status === 429) {
|
|
160
|
+
throw new Error("Rate limit exceeded. Please wait a moment and try again.");
|
|
161
|
+
}
|
|
162
|
+
if (error.response?.data?.message) {
|
|
163
|
+
throw new Error(`KTA registration failed: ${error.response.data.message}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
throw new Error(`Failed to register with KTA: ${error.message}`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -11,8 +11,8 @@ const compiler_context_1 = require("../compiler-context");
|
|
|
11
11
|
const get_entries_1 = require("./get-entries");
|
|
12
12
|
const get_injected_variables_1 = require("./get-injected-variables");
|
|
13
13
|
const resolve_tsconfig_paths_1 = require("./resolve-tsconfig-paths");
|
|
14
|
-
const clean_webpack_plugin_1 = require("clean-webpack-plugin");
|
|
15
14
|
const plugins_1 = require("./plugins");
|
|
15
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
16
16
|
const get_externals_1 = require("./get-externals");
|
|
17
17
|
/** Creates the webpack configuration that xmcp will use to bundle the user's code */
|
|
18
18
|
function getWebpackConfig(xmcpConfig) {
|
|
@@ -87,7 +87,16 @@ function getWebpackConfig(xmcpConfig) {
|
|
|
87
87
|
// add clean plugin
|
|
88
88
|
if (!xmcpConfig.experimental?.adapter) {
|
|
89
89
|
// not needed in adapter mode since it only outputs one file
|
|
90
|
-
|
|
90
|
+
// Simple cleanup plugin using fs-extra (replaces CleanWebpackPlugin)
|
|
91
|
+
config.plugins.push({
|
|
92
|
+
apply: (compiler) => {
|
|
93
|
+
compiler.hooks.beforeCompile.tap("CleanOutputPlugin", () => {
|
|
94
|
+
if (fs_extra_1.default.pathExistsSync(outputPath)) {
|
|
95
|
+
fs_extra_1.default.removeSync(outputPath);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
});
|
|
91
100
|
}
|
|
92
101
|
// add shebang to CLI output on stdio mode
|
|
93
102
|
if (xmcpConfig.stdio) {
|