@kya-os/create-mcpi-app 0.6.4-canary.1
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/.eslintrc.cjs +10 -0
- package/.turbo/turbo-build.log +25 -0
- package/README.md +290 -0
- package/dist/bundles/blank.js +98817 -0
- package/dist/bundles/ecommerce.js +98891 -0
- package/dist/bundles/hardware-world.js +99289 -0
- package/dist/bundles/manifest.json +23 -0
- package/dist/cli-runner.d.ts +2 -0
- package/dist/cli-runner.d.ts.map +1 -0
- package/dist/cli-runner.js +407 -0
- package/dist/cli-runner.js.map +1 -0
- package/dist/effects/index.d.ts +14 -0
- package/dist/effects/index.d.ts.map +1 -0
- package/dist/effects/index.js +51 -0
- package/dist/effects/index.js.map +1 -0
- package/dist/helpers/apply-identity-preset.d.ts +14 -0
- package/dist/helpers/apply-identity-preset.d.ts.map +1 -0
- package/dist/helpers/apply-identity-preset.js +169 -0
- package/dist/helpers/apply-identity-preset.js.map +1 -0
- package/dist/helpers/config-builder.d.ts +53 -0
- package/dist/helpers/config-builder.d.ts.map +1 -0
- package/dist/helpers/config-builder.js +46 -0
- package/dist/helpers/config-builder.js.map +1 -0
- package/dist/helpers/copy-template.d.ts +2 -0
- package/dist/helpers/copy-template.d.ts.map +1 -0
- package/dist/helpers/copy-template.js +11 -0
- package/dist/helpers/copy-template.js.map +1 -0
- package/dist/helpers/create.d.ts +31 -0
- package/dist/helpers/create.d.ts.map +1 -0
- package/dist/helpers/create.js +136 -0
- package/dist/helpers/create.js.map +1 -0
- package/dist/helpers/fetch-cloudflare-mcpi-template.d.ts +25 -0
- package/dist/helpers/fetch-cloudflare-mcpi-template.d.ts.map +1 -0
- package/dist/helpers/fetch-cloudflare-mcpi-template.js +558 -0
- package/dist/helpers/fetch-cloudflare-mcpi-template.js.map +1 -0
- package/dist/helpers/fetch-cloudflare-template.d.ts +11 -0
- package/dist/helpers/fetch-cloudflare-template.d.ts.map +1 -0
- package/dist/helpers/fetch-cloudflare-template.js +338 -0
- package/dist/helpers/fetch-cloudflare-template.js.map +1 -0
- package/dist/helpers/fetch-mcpi-template.d.ts +13 -0
- package/dist/helpers/fetch-mcpi-template.d.ts.map +1 -0
- package/dist/helpers/fetch-mcpi-template.js +237 -0
- package/dist/helpers/fetch-mcpi-template.js.map +1 -0
- package/dist/helpers/fetch-xmcp-template.d.ts +13 -0
- package/dist/helpers/fetch-xmcp-template.d.ts.map +1 -0
- package/dist/helpers/fetch-xmcp-template.js +127 -0
- package/dist/helpers/fetch-xmcp-template.js.map +1 -0
- package/dist/helpers/generate-cloudflare-files.d.ts +89 -0
- package/dist/helpers/generate-cloudflare-files.d.ts.map +1 -0
- package/dist/helpers/generate-cloudflare-files.js +1541 -0
- package/dist/helpers/generate-cloudflare-files.js.map +1 -0
- package/dist/helpers/generate-config.d.ts +2 -0
- package/dist/helpers/generate-config.d.ts.map +1 -0
- package/dist/helpers/generate-config.js +105 -0
- package/dist/helpers/generate-config.js.map +1 -0
- package/dist/helpers/generate-identity.d.ts +38 -0
- package/dist/helpers/generate-identity.d.ts.map +1 -0
- package/dist/helpers/generate-identity.js +123 -0
- package/dist/helpers/generate-identity.js.map +1 -0
- package/dist/helpers/get-package-versions.d.ts +37 -0
- package/dist/helpers/get-package-versions.d.ts.map +1 -0
- package/dist/helpers/get-package-versions.js +92 -0
- package/dist/helpers/get-package-versions.js.map +1 -0
- package/dist/helpers/identity-manager.d.ts +23 -0
- package/dist/helpers/identity-manager.d.ts.map +1 -0
- package/dist/helpers/identity-manager.js +144 -0
- package/dist/helpers/identity-manager.js.map +1 -0
- package/dist/helpers/index.d.ts +14 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +18 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/install.d.ts +3 -0
- package/dist/helpers/install.d.ts.map +1 -0
- package/dist/helpers/install.js +57 -0
- package/dist/helpers/install.js.map +1 -0
- package/dist/helpers/kta-registration.d.ts +58 -0
- package/dist/helpers/kta-registration.d.ts.map +1 -0
- package/dist/helpers/kta-registration.js +77 -0
- package/dist/helpers/kta-registration.js.map +1 -0
- package/dist/helpers/rename.d.ts +2 -0
- package/dist/helpers/rename.d.ts.map +1 -0
- package/dist/helpers/rename.js +15 -0
- package/dist/helpers/rename.js.map +1 -0
- package/dist/helpers/validate-project-structure.d.ts +14 -0
- package/dist/helpers/validate-project-structure.d.ts.map +1 -0
- package/dist/helpers/validate-project-structure.js +102 -0
- package/dist/helpers/validate-project-structure.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/check-node.d.ts +2 -0
- package/dist/utils/check-node.d.ts.map +1 -0
- package/dist/utils/check-node.js +12 -0
- package/dist/utils/check-node.js.map +1 -0
- package/dist/utils/fetch-remote-config.d.ts +74 -0
- package/dist/utils/fetch-remote-config.d.ts.map +1 -0
- package/dist/utils/fetch-remote-config.js +109 -0
- package/dist/utils/fetch-remote-config.js.map +1 -0
- package/dist/utils/is-folder-empty.d.ts +2 -0
- package/dist/utils/is-folder-empty.d.ts.map +1 -0
- package/dist/utils/is-folder-empty.js +55 -0
- package/dist/utils/is-folder-empty.js.map +1 -0
- package/dist/utils/validate-project-name.d.ts +15 -0
- package/dist/utils/validate-project-name.d.ts.map +1 -0
- package/dist/utils/validate-project-name.js +106 -0
- package/dist/utils/validate-project-name.js.map +1 -0
- package/index.js +4 -0
- package/package.json +73 -0
- package/vitest.integration.config.ts +16 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper Exports for @kya-os/create-mcpi-app
|
|
3
|
+
*
|
|
4
|
+
* This module exports helpers for programmatic use.
|
|
5
|
+
* The primary export is generateCloudflareProjectFiles for one-click deployment.
|
|
6
|
+
*/
|
|
7
|
+
// Programmatic file generation (for one-click deployment)
|
|
8
|
+
export { generateCloudflareProjectFiles, } from "./generate-cloudflare-files.js";
|
|
9
|
+
// Identity generation
|
|
10
|
+
export { generateIdentity, isValidDIDKey, extractMultibaseFromDID, } from "./generate-identity.js";
|
|
11
|
+
// Template fetching (writes to disk)
|
|
12
|
+
export { fetchCloudflareMcpiTemplate } from "./fetch-cloudflare-mcpi-template.js";
|
|
13
|
+
export { fetchCloudflareTemplate } from "./fetch-cloudflare-template.js";
|
|
14
|
+
export { fetchMCPITemplate } from "./fetch-mcpi-template.js";
|
|
15
|
+
export { fetchXMCPTemplate } from "./fetch-xmcp-template.js";
|
|
16
|
+
// Project creation
|
|
17
|
+
export { createProject } from "./create.js";
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,0DAA0D;AAC1D,OAAO,EACL,8BAA8B,GAI/B,MAAM,gCAAgC,CAAC;AAExC,sBAAsB;AACtB,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,uBAAuB,GAExB,MAAM,wBAAwB,CAAC;AAEhC,qCAAqC;AACrC,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,mBAAmB;AACnB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/helpers/install.ts"],"names":[],"mappings":"AAKA,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,MAAM,GAClB,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAWhC;AAED,wBAAgB,OAAO,CACrB,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,MAAM,GACtB,IAAI,CAsBN"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { execSync } from "child_process";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
export function detectPackageManager(projectPath) {
|
|
6
|
+
if (fs.existsSync(path.join(projectPath, "pnpm-lock.yaml"))) {
|
|
7
|
+
return "pnpm";
|
|
8
|
+
}
|
|
9
|
+
if (fs.existsSync(path.join(projectPath, "yarn.lock"))) {
|
|
10
|
+
return "yarn";
|
|
11
|
+
}
|
|
12
|
+
if (fs.existsSync(path.join(projectPath, "package-lock.json"))) {
|
|
13
|
+
return "npm";
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
export function install(projectPath, packageManager, _packageVersion) {
|
|
18
|
+
console.log(`\n📦 Installing dependencies with ${packageManager}...`);
|
|
19
|
+
const command = packageManager === "yarn"
|
|
20
|
+
? "yarn install"
|
|
21
|
+
: packageManager === "pnpm"
|
|
22
|
+
? "pnpm install"
|
|
23
|
+
: "npm install";
|
|
24
|
+
try {
|
|
25
|
+
execSync(command, {
|
|
26
|
+
cwd: projectPath,
|
|
27
|
+
stdio: "inherit",
|
|
28
|
+
});
|
|
29
|
+
// Check for lockfile and provide guidance
|
|
30
|
+
checkLockfile(projectPath, packageManager);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.error(`Failed to install dependencies with ${packageManager}.`);
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function checkLockfile(projectPath, packageManager) {
|
|
38
|
+
const lockfiles = {
|
|
39
|
+
npm: "package-lock.json",
|
|
40
|
+
yarn: "yarn.lock",
|
|
41
|
+
pnpm: "pnpm-lock.yaml",
|
|
42
|
+
};
|
|
43
|
+
const expectedLockfile = lockfiles[packageManager];
|
|
44
|
+
// Handle unknown package managers gracefully
|
|
45
|
+
if (!expectedLockfile) {
|
|
46
|
+
console.warn(chalk.yellow(`⚠️ Warning: Unknown package manager "${packageManager}", cannot check lockfile`));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const lockfilePath = path.join(projectPath, expectedLockfile);
|
|
50
|
+
if (fs.existsSync(lockfilePath)) {
|
|
51
|
+
console.log(chalk.gray(`✓ Lockfile created (${expectedLockfile}) - remember to commit it`));
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
console.warn(chalk.yellow(`⚠️ Warning: No lockfile generated (${expectedLockfile})`));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=install.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/helpers/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,UAAU,oBAAoB,CAClC,WAAmB;IAEnB,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC;QAC5D,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC;QACvD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC;QAC/D,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,OAAO,CACrB,WAAmB,EACnB,cAAsB,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V,KAAK,CAAC,MAAM,CAAC,uCAAuC,gBAAgB,GAAG,CAAC,CACzE,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Know That AI Registration Helper
|
|
3
|
+
*
|
|
4
|
+
* Handles registration of MCP-I agents with Know That AI for reputation tracking.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Know That AI registration information
|
|
8
|
+
* @see packages/contracts/src/config/identity.ts
|
|
9
|
+
*/
|
|
10
|
+
export interface KTARegistration {
|
|
11
|
+
/** Whether registration was successful */
|
|
12
|
+
registered: boolean;
|
|
13
|
+
/** ISO 8601 timestamp of registration */
|
|
14
|
+
registeredAt: string;
|
|
15
|
+
/** Claim URL for did:web agents (null for did:key shadow registration) */
|
|
16
|
+
claimUrl: string | null;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Result of a KTA registration attempt
|
|
20
|
+
*/
|
|
21
|
+
export interface RegistrationResult {
|
|
22
|
+
success: boolean;
|
|
23
|
+
did?: string;
|
|
24
|
+
claimUrl?: string | null;
|
|
25
|
+
error?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Options for registration
|
|
29
|
+
*/
|
|
30
|
+
export interface RegisterOptions {
|
|
31
|
+
/** Agent name */
|
|
32
|
+
name: string;
|
|
33
|
+
/** Agent's public key (multibase encoded) */
|
|
34
|
+
publicKey: string;
|
|
35
|
+
/** Agent's DID */
|
|
36
|
+
did: string;
|
|
37
|
+
/** Optional agent description */
|
|
38
|
+
description?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Register an agent with Know That AI
|
|
42
|
+
*
|
|
43
|
+
* Calls the CLI registration endpoint to register a new agent.
|
|
44
|
+
* For did:key agents, this is a "shadow" registration (private).
|
|
45
|
+
* For did:web agents, a claimUrl is returned for public listing.
|
|
46
|
+
*
|
|
47
|
+
* @param options Registration options
|
|
48
|
+
* @returns Registration result
|
|
49
|
+
*/
|
|
50
|
+
export declare function registerWithKTA(options: RegisterOptions): Promise<RegistrationResult>;
|
|
51
|
+
/**
|
|
52
|
+
* Create a KTARegistration object from a successful registration
|
|
53
|
+
*
|
|
54
|
+
* @param claimUrl The claim URL from registration (null for did:key)
|
|
55
|
+
* @returns KTARegistration object
|
|
56
|
+
*/
|
|
57
|
+
export declare function createKTARegistration(claimUrl: string | null): KTARegistration;
|
|
58
|
+
//# sourceMappingURL=kta-registration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kta-registration.d.ts","sourceRoot":"","sources":["../../src/helpers/kta-registration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,0CAA0C;IAC1C,UAAU,EAAE,OAAO,CAAC;IACpB,yCAAyC;IACzC,YAAY,EAAE,MAAM,CAAC;IACrB,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAgBD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,iCAAiC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,kBAAkB,CAAC,CA4C7B;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,GAAG,IAAI,GACtB,eAAe,CAMjB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Know That AI Registration Helper
|
|
3
|
+
*
|
|
4
|
+
* Handles registration of MCP-I agents with Know That AI for reputation tracking.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Know That AI Registry URL
|
|
8
|
+
* @see packages/contracts/src/reputation/api.ts
|
|
9
|
+
*/
|
|
10
|
+
const REGISTRY_URL = "https://knowthat.ai";
|
|
11
|
+
/**
|
|
12
|
+
* API endpoint paths for reputation system
|
|
13
|
+
* @see packages/contracts/src/reputation/api.ts
|
|
14
|
+
*/
|
|
15
|
+
const REPUTATION_API_PATHS = {
|
|
16
|
+
CLI_REGISTER: "/api/agents/cli-register",
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Register an agent with Know That AI
|
|
20
|
+
*
|
|
21
|
+
* Calls the CLI registration endpoint to register a new agent.
|
|
22
|
+
* For did:key agents, this is a "shadow" registration (private).
|
|
23
|
+
* For did:web agents, a claimUrl is returned for public listing.
|
|
24
|
+
*
|
|
25
|
+
* @param options Registration options
|
|
26
|
+
* @returns Registration result
|
|
27
|
+
*/
|
|
28
|
+
export async function registerWithKTA(options) {
|
|
29
|
+
const { name, publicKey, did, description } = options;
|
|
30
|
+
try {
|
|
31
|
+
const response = await fetch(`${REGISTRY_URL}${REPUTATION_API_PATHS.CLI_REGISTER}`, {
|
|
32
|
+
method: "POST",
|
|
33
|
+
headers: {
|
|
34
|
+
"Content-Type": "application/json",
|
|
35
|
+
},
|
|
36
|
+
body: JSON.stringify({
|
|
37
|
+
name,
|
|
38
|
+
publicKey,
|
|
39
|
+
did,
|
|
40
|
+
description,
|
|
41
|
+
}),
|
|
42
|
+
});
|
|
43
|
+
if (!response.ok) {
|
|
44
|
+
const errorText = await response.text();
|
|
45
|
+
return {
|
|
46
|
+
success: false,
|
|
47
|
+
error: `Registration failed: ${response.status} - ${errorText}`,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const data = (await response.json());
|
|
51
|
+
return {
|
|
52
|
+
success: true,
|
|
53
|
+
did: data.did || did,
|
|
54
|
+
claimUrl: data.claimUrl ?? null, // null for did:key (shadow registration)
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
return {
|
|
59
|
+
success: false,
|
|
60
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Create a KTARegistration object from a successful registration
|
|
66
|
+
*
|
|
67
|
+
* @param claimUrl The claim URL from registration (null for did:key)
|
|
68
|
+
* @returns KTARegistration object
|
|
69
|
+
*/
|
|
70
|
+
export function createKTARegistration(claimUrl) {
|
|
71
|
+
return {
|
|
72
|
+
registered: true,
|
|
73
|
+
registeredAt: new Date().toISOString(),
|
|
74
|
+
claimUrl,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=kta-registration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kta-registration.js","sourceRoot":"","sources":["../../src/helpers/kta-registration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAmBH;;;GAGG;AACH,MAAM,YAAY,GAAG,qBAA8B,CAAC;AAEpD;;;GAGG;AACH,MAAM,oBAAoB,GAAG;IAC3B,YAAY,EAAE,0BAA0B;CAChC,CAAC;AA0BX;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAAwB;IAExB,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAEtD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,GAAG,YAAY,GAAG,oBAAoB,CAAC,YAAY,EAAE,EACrD;YACE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,IAAI;gBACJ,SAAS;gBACT,GAAG;gBACH,WAAW;aACZ,CAAC;SACH,CACF,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACxC,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,wBAAwB,QAAQ,CAAC,MAAM,MAAM,SAAS,EAAE;aAChE,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAGlC,CAAC;QAEF,OAAO;YACL,OAAO,EAAE,IAAI;YACb,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,GAAG;YACpB,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI,EAAE,yCAAyC;SAC3E,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;SAChE,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAuB;IAEvB,OAAO;QACL,UAAU,EAAE,IAAI;QAChB,YAAY,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACtC,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename.d.ts","sourceRoot":"","sources":["../../src/helpers/rename.ts"],"names":[],"mappings":"AAGA,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAarD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import path from "path";
|
|
3
|
+
export function renameFiles(projectPath) {
|
|
4
|
+
const filesToRename = [
|
|
5
|
+
{ from: "_gitignore", to: ".gitignore" },
|
|
6
|
+
];
|
|
7
|
+
filesToRename.forEach(({ from, to }) => {
|
|
8
|
+
const fromPath = path.join(projectPath, from);
|
|
9
|
+
const toPath = path.join(projectPath, to);
|
|
10
|
+
if (fs.existsSync(fromPath)) {
|
|
11
|
+
fs.renameSync(fromPath, toPath);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=rename.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename.js","sourceRoot":"","sources":["../../src/helpers/rename.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,UAAU,WAAW,CAAC,WAAmB;IAC7C,MAAM,aAAa,GAAG;QACpB,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,YAAY,EAAE;KACzC,CAAC;IAEF,aAAa,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE;QACrC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAC9C,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAE1C,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAClC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface ProjectStructureValidation {
|
|
2
|
+
valid: boolean;
|
|
3
|
+
issues: string[];
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Validate that the generated project structure meets requirements
|
|
7
|
+
*/
|
|
8
|
+
export declare function validateProjectStructure(projectPath: string, identityEnabled: boolean): ProjectStructureValidation;
|
|
9
|
+
/**
|
|
10
|
+
* Ensure lockfile is written and not mutated post-generation
|
|
11
|
+
*/
|
|
12
|
+
export declare function ensureLockfile(projectPath: string, packageManager: string): void;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=validate-project-structure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-project-structure.d.ts","sourceRoot":"","sources":["../../src/helpers/validate-project-structure.ts"],"names":[],"mappings":"AAIA,UAAU,0BAA0B;IAClC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,OAAO,GACvB,0BAA0B,CAiF5B;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACrB,IAAI,CAsBN"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
/**
|
|
5
|
+
* Validate that the generated project structure meets requirements
|
|
6
|
+
*/
|
|
7
|
+
export function validateProjectStructure(projectPath, identityEnabled) {
|
|
8
|
+
const issues = [];
|
|
9
|
+
// Check package.json scripts
|
|
10
|
+
const packageJsonPath = path.join(projectPath, "package.json");
|
|
11
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
12
|
+
const packageJson = fs.readJsonSync(packageJsonPath);
|
|
13
|
+
const scripts = packageJson.scripts || {};
|
|
14
|
+
const scriptCount = Object.keys(scripts).length;
|
|
15
|
+
if (identityEnabled) {
|
|
16
|
+
// Should have exactly 8 scripts for identity-enabled projects
|
|
17
|
+
if (scriptCount !== 8) {
|
|
18
|
+
issues.push(`Expected exactly 8 scripts for identity project, found ${scriptCount}`);
|
|
19
|
+
}
|
|
20
|
+
const requiredScripts = [
|
|
21
|
+
"dev",
|
|
22
|
+
"build",
|
|
23
|
+
"start",
|
|
24
|
+
"init",
|
|
25
|
+
"register",
|
|
26
|
+
"keys:rotate",
|
|
27
|
+
"identity:clean",
|
|
28
|
+
"status",
|
|
29
|
+
];
|
|
30
|
+
for (const script of requiredScripts) {
|
|
31
|
+
if (!scripts[script]) {
|
|
32
|
+
issues.push(`Missing required script: ${script}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
// Should have exactly 3 scripts for vanilla XMCP projects
|
|
38
|
+
if (scriptCount !== 3) {
|
|
39
|
+
issues.push(`Expected exactly 3 scripts for vanilla project, found ${scriptCount}`);
|
|
40
|
+
}
|
|
41
|
+
const requiredScripts = ["dev", "build", "start"];
|
|
42
|
+
for (const script of requiredScripts) {
|
|
43
|
+
if (!scripts[script]) {
|
|
44
|
+
issues.push(`Missing required script: ${script}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
issues.push("package.json not found");
|
|
51
|
+
}
|
|
52
|
+
// Check required files exist (based on actual XMCP upstream structure)
|
|
53
|
+
const requiredFiles = [
|
|
54
|
+
"src/tools/greet.ts", // XMCP creates greet.ts, not hello.ts
|
|
55
|
+
".gitignore",
|
|
56
|
+
"xmcp.config.ts",
|
|
57
|
+
];
|
|
58
|
+
for (const file of requiredFiles) {
|
|
59
|
+
if (!fs.existsSync(path.join(projectPath, file))) {
|
|
60
|
+
issues.push(`Missing required file: ${file}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Check .gitignore includes .mcpi/ for identity projects
|
|
64
|
+
if (identityEnabled) {
|
|
65
|
+
const gitignorePath = path.join(projectPath, ".gitignore");
|
|
66
|
+
if (fs.existsSync(gitignorePath)) {
|
|
67
|
+
const gitignoreContent = fs.readFileSync(gitignorePath, "utf8");
|
|
68
|
+
if (!gitignoreContent.includes(".mcpi/")) {
|
|
69
|
+
issues.push(".gitignore should include .mcpi/ directory");
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
valid: issues.length === 0,
|
|
75
|
+
issues,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Ensure lockfile is written and not mutated post-generation
|
|
80
|
+
*/
|
|
81
|
+
export function ensureLockfile(projectPath, packageManager) {
|
|
82
|
+
const lockfiles = {
|
|
83
|
+
npm: "package-lock.json",
|
|
84
|
+
yarn: "yarn.lock",
|
|
85
|
+
pnpm: "pnpm-lock.yaml",
|
|
86
|
+
};
|
|
87
|
+
const lockfileName = lockfiles[packageManager];
|
|
88
|
+
if (!lockfileName) {
|
|
89
|
+
console.warn(chalk.yellow(`Unknown package manager: ${packageManager}`));
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const lockfilePath = path.join(projectPath, lockfileName);
|
|
93
|
+
// The lockfile should be created during npm install
|
|
94
|
+
// We just validate it exists after installation
|
|
95
|
+
if (fs.existsSync(lockfilePath)) {
|
|
96
|
+
console.log(chalk.green(`✅ Lockfile created: ${lockfileName}`));
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
console.warn(chalk.yellow(`⚠️ Lockfile not found: ${lockfileName}`));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=validate-project-structure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-project-structure.js","sourceRoot":"","sources":["../../src/helpers/validate-project-structure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B;;GAEG;AACH,MAAM,UAAU,wBAAwB,CACtC,WAAmB,EACnB,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,GAAG,SAAS,CAAC,cAAwC,CAAC,CAAC;IACzE,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,4BAA4B,cAAc,EAAE,CAAC,CAAC,CAAC;QACzE,OAAO;IACT,CAAC;IAED,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAE1D,oDAAoD;IACpD,gDAAgD;IAChD,IAAI,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,uBAAuB,YAAY,EAAE,CAAC,CAAC,CAAC;IAClE,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,2BAA2B,YAAY,EAAE,CAAC,CAAC,CAAC;IACxE,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Load .env file if it exists (for local development/testing)
|
|
3
|
+
import { config } from "dotenv";
|
|
4
|
+
import { resolve, dirname } from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
import { runCLI } from "./cli-runner.js";
|
|
7
|
+
// Try to load .env from package directory first, then from current working directory
|
|
8
|
+
// When compiled, __dirname will be dist/, so we go up one level to find .env
|
|
9
|
+
const currentFile = fileURLToPath(import.meta.url);
|
|
10
|
+
const distDir = dirname(currentFile);
|
|
11
|
+
const packageDir = resolve(distDir, "..");
|
|
12
|
+
config({ path: resolve(packageDir, ".env") });
|
|
13
|
+
config({ path: resolve(process.cwd(), ".env") });
|
|
14
|
+
runCLI(process.argv).catch((error) => {
|
|
15
|
+
console.error(error);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,8DAA8D;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,qFAAqF;AACrF,6EAA6E;AAC7E,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnD,MAAM,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACrC,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAC1C,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;AAC9C,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;AAEjD,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACnC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-node.d.ts","sourceRoot":"","sources":["../../src/utils/check-node.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,IAAI,IAAI,CAcvC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
export function checkNodeVersion() {
|
|
3
|
+
const currentNodeVersion = process.versions.node;
|
|
4
|
+
const [major] = currentNodeVersion.split(".").map(Number);
|
|
5
|
+
if (major < 20) {
|
|
6
|
+
console.error(chalk.red(`Error: Node.js version ${currentNodeVersion} is not supported.\n` +
|
|
7
|
+
`create-mcpi-app requires Node.js 20.0.0 or higher.\n` +
|
|
8
|
+
`Please update your Node.js version.`));
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=check-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-node.js","sourceRoot":"","sources":["../../src/utils/check-node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,UAAU,gBAAgB;IAC9B,MAAM,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;IACjD,MAAM,CAAC,KAAK,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAE1D,IAAI,KAAK,GAAG,EAAE,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CACX,KAAK,CAAC,GAAG,CACP,0BAA0B,kBAAkB,sBAAsB;YAChE,sDAAsD;YACtD,qCAAqC,CACxC,CACF,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remote Configuration Fetching
|
|
3
|
+
*
|
|
4
|
+
* Service for fetching configuration from remote APIs (AgentShield dashboard)
|
|
5
|
+
* with caching support for performance optimization.
|
|
6
|
+
*
|
|
7
|
+
* NOTE: This implementation is extracted from @kya-os/mcp-i-core/src/config/remote-config.ts
|
|
8
|
+
* to avoid runtime dependency on the entire mcp-i-core package.
|
|
9
|
+
*
|
|
10
|
+
* Source: packages/mcp-i-core/src/config/remote-config.ts
|
|
11
|
+
*
|
|
12
|
+
* @module @kya-os/create-mcpi-app/utils/fetch-remote-config
|
|
13
|
+
*/
|
|
14
|
+
import type { MCPIConfig } from '@kya-os/contracts/config';
|
|
15
|
+
/**
|
|
16
|
+
* Options for fetching remote configuration
|
|
17
|
+
*/
|
|
18
|
+
export interface RemoteConfigOptions {
|
|
19
|
+
/**
|
|
20
|
+
* API base URL
|
|
21
|
+
* @example 'https://kya.vouched.id'
|
|
22
|
+
*/
|
|
23
|
+
apiUrl: string;
|
|
24
|
+
/**
|
|
25
|
+
* API key for authentication
|
|
26
|
+
*/
|
|
27
|
+
apiKey: string;
|
|
28
|
+
/**
|
|
29
|
+
* Project ID (optional, preferred over agentDid)
|
|
30
|
+
* Used for project-scoped configuration
|
|
31
|
+
*/
|
|
32
|
+
projectId?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Agent DID (optional, used when projectId not available)
|
|
35
|
+
* Used for agent-scoped configuration
|
|
36
|
+
*/
|
|
37
|
+
agentDid?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Cache TTL in milliseconds
|
|
40
|
+
* @default 300000 (5 minutes)
|
|
41
|
+
*/
|
|
42
|
+
cacheTtl?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Fetch provider function
|
|
45
|
+
* Platform-agnostic fetch implementation
|
|
46
|
+
*/
|
|
47
|
+
fetchProvider: (url: string, options: RequestInit) => Promise<Response>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Cache interface for remote configuration
|
|
51
|
+
* Abstracts platform-specific caching (KV, Redis, Memory, etc.)
|
|
52
|
+
*/
|
|
53
|
+
export interface RemoteConfigCache {
|
|
54
|
+
/**
|
|
55
|
+
* Get a cached value
|
|
56
|
+
*/
|
|
57
|
+
get(key: string): Promise<string | null>;
|
|
58
|
+
/**
|
|
59
|
+
* Set a cached value with TTL
|
|
60
|
+
*/
|
|
61
|
+
set(key: string, value: string, ttl: number): Promise<void>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Fetch configuration from remote API (AgentShield dashboard)
|
|
65
|
+
*
|
|
66
|
+
* Attempts to fetch configuration from the AgentShield API with caching support.
|
|
67
|
+
* Falls back gracefully if remote fetch fails.
|
|
68
|
+
*
|
|
69
|
+
* @param options - Remote config options
|
|
70
|
+
* @param cache - Optional cache implementation
|
|
71
|
+
* @returns Configuration object or null if fetch fails
|
|
72
|
+
*/
|
|
73
|
+
export declare function fetchRemoteConfig(options: RemoteConfigOptions, cache?: RemoteConfigCache): Promise<MCPIConfig | null>;
|
|
74
|
+
//# sourceMappingURL=fetch-remote-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-remote-config.d.ts","sourceRoot":"","sources":["../../src/utils/fetch-remote-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;CACzE;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAEzC;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D;AAED;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,mBAAmB,EAC5B,KAAK,CAAC,EAAE,iBAAiB,GACxB,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CA4F5B"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remote Configuration Fetching
|
|
3
|
+
*
|
|
4
|
+
* Service for fetching configuration from remote APIs (AgentShield dashboard)
|
|
5
|
+
* with caching support for performance optimization.
|
|
6
|
+
*
|
|
7
|
+
* NOTE: This implementation is extracted from @kya-os/mcp-i-core/src/config/remote-config.ts
|
|
8
|
+
* to avoid runtime dependency on the entire mcp-i-core package.
|
|
9
|
+
*
|
|
10
|
+
* Source: packages/mcp-i-core/src/config/remote-config.ts
|
|
11
|
+
*
|
|
12
|
+
* @module @kya-os/create-mcpi-app/utils/fetch-remote-config
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Fetch configuration from remote API (AgentShield dashboard)
|
|
16
|
+
*
|
|
17
|
+
* Attempts to fetch configuration from the AgentShield API with caching support.
|
|
18
|
+
* Falls back gracefully if remote fetch fails.
|
|
19
|
+
*
|
|
20
|
+
* @param options - Remote config options
|
|
21
|
+
* @param cache - Optional cache implementation
|
|
22
|
+
* @returns Configuration object or null if fetch fails
|
|
23
|
+
*/
|
|
24
|
+
export async function fetchRemoteConfig(options, cache) {
|
|
25
|
+
const { apiUrl, apiKey, projectId, agentDid, cacheTtl = 300000, fetchProvider } = options;
|
|
26
|
+
// Generate cache key
|
|
27
|
+
const cacheKey = projectId
|
|
28
|
+
? `config:project:${projectId}`
|
|
29
|
+
: agentDid
|
|
30
|
+
? `config:agent:${agentDid}`
|
|
31
|
+
: null;
|
|
32
|
+
// Try cache first
|
|
33
|
+
if (cache && cacheKey) {
|
|
34
|
+
try {
|
|
35
|
+
const cached = await cache.get(cacheKey);
|
|
36
|
+
if (cached) {
|
|
37
|
+
try {
|
|
38
|
+
const parsed = JSON.parse(cached);
|
|
39
|
+
if (parsed.expiresAt > Date.now()) {
|
|
40
|
+
return parsed.config;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// Invalid cache entry, continue to fetch
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
// Cache read failed, continue to fetch
|
|
50
|
+
console.warn('[RemoteConfig] Cache read failed:', error);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Fetch from API
|
|
54
|
+
try {
|
|
55
|
+
// Build API URL
|
|
56
|
+
let url;
|
|
57
|
+
if (projectId) {
|
|
58
|
+
// Use project-scoped endpoint (preferred)
|
|
59
|
+
// Inlined from @kya-os/contracts/agentshield-api to avoid runtime dependency
|
|
60
|
+
url = `${apiUrl}/api/v1/bouncer/projects/${projectId}/config`;
|
|
61
|
+
}
|
|
62
|
+
else if (agentDid) {
|
|
63
|
+
// Use agent-scoped endpoint
|
|
64
|
+
url = `${apiUrl}/api/v1/bouncer/config?agent_did=${encodeURIComponent(agentDid)}`;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
console.warn('[RemoteConfig] Neither projectId nor agentDid provided');
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
const response = await fetchProvider(url, {
|
|
71
|
+
headers: {
|
|
72
|
+
'Authorization': `Bearer ${apiKey}`,
|
|
73
|
+
'Content-Type': 'application/json'
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
if (!response.ok) {
|
|
77
|
+
console.warn(`[RemoteConfig] API returned ${response.status}: ${response.statusText}`);
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
const data = await response.json();
|
|
81
|
+
// Extract config from API response
|
|
82
|
+
// API response format: { success: boolean, data: { config: MCPIConfig } }
|
|
83
|
+
const responseData = data;
|
|
84
|
+
const config = responseData.config || responseData.data?.config || (responseData.success ? responseData.data : null);
|
|
85
|
+
if (!config) {
|
|
86
|
+
console.warn('[RemoteConfig] No config found in API response');
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
// Cache the result
|
|
90
|
+
if (cache && cacheKey) {
|
|
91
|
+
try {
|
|
92
|
+
await cache.set(cacheKey, JSON.stringify({
|
|
93
|
+
config,
|
|
94
|
+
expiresAt: Date.now() + cacheTtl
|
|
95
|
+
}), cacheTtl);
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
// Cache write failed, but we got the config so continue
|
|
99
|
+
console.warn('[RemoteConfig] Cache write failed:', error);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return config;
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
console.warn('[RemoteConfig] Failed to fetch config:', error);
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=fetch-remote-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-remote-config.js","sourceRoot":"","sources":["../../src/utils/fetch-remote-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA4DH;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAA4B,EAC5B,KAAyB;IAEzB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAE1F,qBAAqB;IACrB,MAAM,QAAQ,GAAG,SAAS;QACxB,CAAC,CAAC,kBAAkB,SAAS,EAAE;QAC/B,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,gBAAgB,QAAQ,EAAE;YAC5B,CAAC,CAAC,IAAI,CAAC;IAET,kBAAkB;IAClB,IAAI,KAAK,IAAI,QAAQ,EAAE,CAAC;QACtB,IAAI,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