@lobehub/market-types 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +33 -0
- package/src/agent/index.ts +8 -0
- package/src/index.ts +2 -0
- package/src/market.ts +29 -0
- package/src/plugin/admin.ts +10 -0
- package/src/plugin/capabilities.ts +46 -0
- package/src/plugin/deploymentOption.ts +63 -0
- package/src/plugin/index.ts +4 -0
- package/src/plugin/plugin.ts +104 -0
- package/tsconfig.json +20 -0
- package/tsup.config.ts +10 -0
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lobehub/market-types",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"main": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.mts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsup",
|
|
10
|
+
"clean": "rimraf .turbo node_modules dist",
|
|
11
|
+
"dev": "tsup --watch",
|
|
12
|
+
"format": "prettier --check . --ignore-path ../../.gitignore",
|
|
13
|
+
"lint": "eslint \"**/*.ts*\"",
|
|
14
|
+
"prepublishOnly": "npm run build",
|
|
15
|
+
"release": "npm publish",
|
|
16
|
+
"typecheck": "tsc --noEmit"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"zod": "^3.22.4"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/node": "^20.11.24",
|
|
23
|
+
"eslint": "^8.57.0",
|
|
24
|
+
"prettier": "^3.2.5",
|
|
25
|
+
"rimraf": "^5.0.5",
|
|
26
|
+
"tsup": "^8.5.0",
|
|
27
|
+
"typescript": "^5.3.3"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public",
|
|
31
|
+
"registry": "https://registry.npmjs.org"
|
|
32
|
+
}
|
|
33
|
+
}
|
package/src/index.ts
ADDED
package/src/market.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 市场列表中单个资源项的基础结构
|
|
3
|
+
*/
|
|
4
|
+
export interface MarketItemBase {
|
|
5
|
+
/** 全局唯一标识符, 通常包含作者/命名空间和名称 */
|
|
6
|
+
identifier: string;
|
|
7
|
+
/** 在市场列表中显示的名称 (已本地化) */
|
|
8
|
+
name: string;
|
|
9
|
+
/** 在市场列表中显示的简短描述 (已本地化) */
|
|
10
|
+
description: string;
|
|
11
|
+
/** 指向该资源详细 Manifest 文件的 URL */
|
|
12
|
+
manifestUrl: string;
|
|
13
|
+
/** 作者或组织名称 */
|
|
14
|
+
author?: string;
|
|
15
|
+
/** 资源在市场中创建的日期 (ISO 8601) */
|
|
16
|
+
createdAt: string;
|
|
17
|
+
/** 资源在市场中最后更新的日期 (ISO 8601) */
|
|
18
|
+
updatedAt: string;
|
|
19
|
+
/** 资源的主页或文档链接 */
|
|
20
|
+
homepage?: string;
|
|
21
|
+
/** 图标 URL 或 Emoji */
|
|
22
|
+
icon?: string;
|
|
23
|
+
/** 标签列表 (已本地化) */
|
|
24
|
+
tags?: string[];
|
|
25
|
+
/** 分类名称 */
|
|
26
|
+
category?: string;
|
|
27
|
+
/** 可选:兼容性信息 */
|
|
28
|
+
compatibility?: Record<string, any>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// 管理端插件项 Schema
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
import { BasePluginItemSchema } from './plugin';
|
|
5
|
+
|
|
6
|
+
export const AdminPluginItemSchema = BasePluginItemSchema.extend({
|
|
7
|
+
status: z.enum(['published', 'unpublished', 'archived', 'deprecated'] as const),
|
|
8
|
+
visibility: z.enum(['public', 'private', 'internal'] as const),
|
|
9
|
+
});
|
|
10
|
+
export type AdminPluginItem = z.infer<typeof AdminPluginItemSchema>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
|
|
2
|
+
// 插件能力定义
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
export const PluginCapabilitiesSchema = z.object({
|
|
6
|
+
tools: z.boolean().default(false),
|
|
7
|
+
prompts: z.boolean().default(false),
|
|
8
|
+
resources: z.boolean().default(false),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 工具项定义
|
|
13
|
+
*/
|
|
14
|
+
export interface PluginTool {
|
|
15
|
+
name: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
inputSchema?: Record<string, any>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 资源项定义
|
|
22
|
+
*/
|
|
23
|
+
export interface PluginResource {
|
|
24
|
+
uri: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
mimeType?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 提示词参数定义
|
|
31
|
+
*/
|
|
32
|
+
export interface PromptArgument {
|
|
33
|
+
name: string;
|
|
34
|
+
required?: boolean;
|
|
35
|
+
description?: string;
|
|
36
|
+
type?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 提示词项定义
|
|
41
|
+
*/
|
|
42
|
+
export interface PluginPrompt {
|
|
43
|
+
name: string;
|
|
44
|
+
description: string;
|
|
45
|
+
arguments?: PromptArgument[];
|
|
46
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 连接类型
|
|
5
|
+
*/
|
|
6
|
+
export const ConnectionTypeEnum = z.enum(['http', 'stdio']);
|
|
7
|
+
export type ConnectionType = z.infer<typeof ConnectionTypeEnum>;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* MCP安装方法
|
|
11
|
+
*/
|
|
12
|
+
export const InstallationMethodEnum = z.enum([
|
|
13
|
+
'npm',
|
|
14
|
+
'go',
|
|
15
|
+
'python',
|
|
16
|
+
'docker',
|
|
17
|
+
'git',
|
|
18
|
+
'binaryUrl',
|
|
19
|
+
'manual',
|
|
20
|
+
'none',
|
|
21
|
+
]);
|
|
22
|
+
export type InstallationMethod = z.infer<typeof InstallationMethodEnum>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 系统依赖项
|
|
26
|
+
*/
|
|
27
|
+
export interface SystemDependency {
|
|
28
|
+
name: string;
|
|
29
|
+
type?: string;
|
|
30
|
+
requiredVersion?: string;
|
|
31
|
+
checkCommand?: string;
|
|
32
|
+
installInstructions?: Record<string, string>;
|
|
33
|
+
versionParsingRequired?: boolean;
|
|
34
|
+
description?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* MCP连接配置
|
|
39
|
+
*/
|
|
40
|
+
export interface ConnectionConfig {
|
|
41
|
+
type: ConnectionType;
|
|
42
|
+
command?: string;
|
|
43
|
+
args?: string[];
|
|
44
|
+
url?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface InstallationDetails {
|
|
48
|
+
packageName?: string;
|
|
49
|
+
repositoryUrlToClone?: string;
|
|
50
|
+
setupSteps?: string[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* MCP部署选项
|
|
55
|
+
*/
|
|
56
|
+
export interface DeploymentOption {
|
|
57
|
+
installationMethod: string;
|
|
58
|
+
installationDetails?: InstallationDetails;
|
|
59
|
+
connection: ConnectionConfig;
|
|
60
|
+
isRecommended?: boolean;
|
|
61
|
+
description?: string;
|
|
62
|
+
systemDependencies?: SystemDependency[];
|
|
63
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
import { MarketItemBase } from '../market';
|
|
4
|
+
import {
|
|
5
|
+
PluginCapabilitiesSchema,
|
|
6
|
+
PluginPrompt,
|
|
7
|
+
PluginResource,
|
|
8
|
+
PluginTool,
|
|
9
|
+
PromptArgument,
|
|
10
|
+
} from './capabilities';
|
|
11
|
+
import { DeploymentOption } from './deploymentOption';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 兼容性信息
|
|
15
|
+
*/
|
|
16
|
+
export interface PluginCompatibility {
|
|
17
|
+
platforms?: string[];
|
|
18
|
+
minAppVersion?: string;
|
|
19
|
+
maxAppVersion?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// 基础插件项 Schema
|
|
23
|
+
export const BasePluginItemSchema = z.object({
|
|
24
|
+
identifier: z.string(),
|
|
25
|
+
name: z.string(),
|
|
26
|
+
description: z.string(),
|
|
27
|
+
manifestUrl: z.string(),
|
|
28
|
+
author: z.string().optional(),
|
|
29
|
+
createdAt: z.string(),
|
|
30
|
+
updatedAt: z.string(),
|
|
31
|
+
homepage: z.string().optional(),
|
|
32
|
+
icon: z.string().optional(),
|
|
33
|
+
tags: z.array(z.string()).optional(),
|
|
34
|
+
category: z.string().optional(),
|
|
35
|
+
capabilities: PluginCapabilitiesSchema,
|
|
36
|
+
toolsCount: z.number().optional(),
|
|
37
|
+
promptsCount: z.number().optional(),
|
|
38
|
+
resourcesCount: z.number().optional(),
|
|
39
|
+
isValidated: z.boolean().default(false),
|
|
40
|
+
installCount: z.number().default(0),
|
|
41
|
+
ratingAverage: z.number().optional(),
|
|
42
|
+
ratingCount: z.number().default(0),
|
|
43
|
+
commentCount: z.number().default(0),
|
|
44
|
+
isFeatured: z.boolean().default(false),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Plugin (MCP Server) 类型资源项的定义 (继承基础结构)
|
|
49
|
+
* 注: 这个定义会与现有的 PluginItem 结构进行整合
|
|
50
|
+
*/
|
|
51
|
+
export interface MarketPluginItem extends MarketItemBase {
|
|
52
|
+
// 能力信息
|
|
53
|
+
capabilities?: {
|
|
54
|
+
tools: boolean;
|
|
55
|
+
prompts: boolean;
|
|
56
|
+
resources: boolean;
|
|
57
|
+
};
|
|
58
|
+
// 数量统计
|
|
59
|
+
toolsCount?: number;
|
|
60
|
+
promptsCount?: number;
|
|
61
|
+
resourcesCount?: number;
|
|
62
|
+
// 验证状态
|
|
63
|
+
isValidated?: boolean;
|
|
64
|
+
// 统计信息
|
|
65
|
+
installCount?: number;
|
|
66
|
+
ratingAverage?: number;
|
|
67
|
+
ratingCount?: number;
|
|
68
|
+
commentCount?: number;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 导出类型
|
|
72
|
+
export type BasePluginItem = z.infer<typeof BasePluginItemSchema>;
|
|
73
|
+
|
|
74
|
+
// 插件清单
|
|
75
|
+
export interface PluginManifest {
|
|
76
|
+
id: string;
|
|
77
|
+
name: string;
|
|
78
|
+
version: string;
|
|
79
|
+
description: string;
|
|
80
|
+
category?: string;
|
|
81
|
+
tags?: string[];
|
|
82
|
+
author?: {
|
|
83
|
+
name: string;
|
|
84
|
+
url?: string;
|
|
85
|
+
};
|
|
86
|
+
homepage?: string;
|
|
87
|
+
icon?: string;
|
|
88
|
+
capabilities?: {
|
|
89
|
+
tools?: boolean;
|
|
90
|
+
prompts?: boolean;
|
|
91
|
+
resources?: boolean;
|
|
92
|
+
};
|
|
93
|
+
deploymentOptions?: DeploymentOption[];
|
|
94
|
+
compatibility?: PluginCompatibility;
|
|
95
|
+
// 工具定义
|
|
96
|
+
tools?: PluginTool[];
|
|
97
|
+
// 资源定义
|
|
98
|
+
resources?: PluginResource[];
|
|
99
|
+
// 提示词定义
|
|
100
|
+
prompts?: PluginPrompt[];
|
|
101
|
+
// 验证信息
|
|
102
|
+
isValidated?: boolean;
|
|
103
|
+
validatedAt?: string;
|
|
104
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2018",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"outDir": "./dist",
|
|
12
|
+
"rootDir": "./src",
|
|
13
|
+
"baseUrl": ".",
|
|
14
|
+
"paths": {
|
|
15
|
+
"@/*": ["src/*"]
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"exclude": ["node_modules", "dist"],
|
|
19
|
+
"include": ["src"]
|
|
20
|
+
}
|