mcp-paike 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/LICENSE +674 -0
- package/README.md +124 -0
- package/dist/__tests__/__mocks__/open.d.ts +2 -0
- package/dist/__tests__/__mocks__/open.d.ts.map +1 -0
- package/dist/__tests__/__mocks__/open.js +5 -0
- package/dist/__tests__/__mocks__/open.js.map +1 -0
- package/dist/__tests__/toolRegistry.test.d.ts +2 -0
- package/dist/__tests__/toolRegistry.test.d.ts.map +1 -0
- package/dist/__tests__/toolRegistry.test.js +160 -0
- package/dist/__tests__/toolRegistry.test.js.map +1 -0
- package/dist/api/client.d.ts +10 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +58 -0
- package/dist/api/client.js.map +1 -0
- package/dist/auth/tokenManager.d.ts +30 -0
- package/dist/auth/tokenManager.d.ts.map +1 -0
- package/dist/auth/tokenManager.js +107 -0
- package/dist/auth/tokenManager.js.map +1 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +20 -0
- package/dist/config/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +144 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/attendances.d.ts +145 -0
- package/dist/tools/attendances.d.ts.map +1 -0
- package/dist/tools/attendances.js +202 -0
- package/dist/tools/attendances.js.map +1 -0
- package/dist/tools/auth.d.ts +62 -0
- package/dist/tools/auth.d.ts.map +1 -0
- package/dist/tools/auth.js +193 -0
- package/dist/tools/auth.js.map +1 -0
- package/dist/tools/classes.d.ts +125 -0
- package/dist/tools/classes.d.ts.map +1 -0
- package/dist/tools/classes.js +195 -0
- package/dist/tools/classes.js.map +1 -0
- package/dist/tools/finance.d.ts +152 -0
- package/dist/tools/finance.d.ts.map +1 -0
- package/dist/tools/finance.js +319 -0
- package/dist/tools/finance.js.map +1 -0
- package/dist/tools/index.d.ts +29 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +46 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/sessions.d.ts +126 -0
- package/dist/tools/sessions.d.ts.map +1 -0
- package/dist/tools/sessions.js +169 -0
- package/dist/tools/sessions.js.map +1 -0
- package/dist/tools/students.d.ts +171 -0
- package/dist/tools/students.d.ts.map +1 -0
- package/dist/tools/students.js +295 -0
- package/dist/tools/students.js.map +1 -0
- package/dist/utils/logger.d.ts +8 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +73 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import open from 'open';
|
|
2
|
+
import { config } from '../config/index.js';
|
|
3
|
+
import { tokenManager } from '../auth/tokenManager.js';
|
|
4
|
+
import { logger } from '../utils/logger.js';
|
|
5
|
+
// Login tool - opens browser and instructs user to paste token
|
|
6
|
+
export const loginTool = {
|
|
7
|
+
name: 'login',
|
|
8
|
+
description: '企业微信登录 - 打开浏览器获取访问令牌',
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: 'object',
|
|
11
|
+
properties: {
|
|
12
|
+
token: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
description: '从网页复制的访问令牌(如果已有令牌,直接提供;否则会打开浏览器)',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
required: [],
|
|
18
|
+
},
|
|
19
|
+
handler: async (args) => {
|
|
20
|
+
// If token is provided, validate and store it
|
|
21
|
+
if (args.token) {
|
|
22
|
+
try {
|
|
23
|
+
logger.info('验证用户提供的 Token');
|
|
24
|
+
// Validate token by calling /auth/me
|
|
25
|
+
const user = await validateToken(args.token);
|
|
26
|
+
// Store credentials with expiry parsed from JWT
|
|
27
|
+
const expiresIn = parseTokenExpiry(args.token);
|
|
28
|
+
await tokenManager.storeCredentials({
|
|
29
|
+
accessToken: args.token,
|
|
30
|
+
issuedAt: Date.now(),
|
|
31
|
+
expiresIn,
|
|
32
|
+
user,
|
|
33
|
+
});
|
|
34
|
+
// Format expiry for display
|
|
35
|
+
const expiryHours = Math.floor(expiresIn / 3600);
|
|
36
|
+
const expiryMinutes = Math.floor((expiresIn % 3600) / 60);
|
|
37
|
+
const expiryText = expiryHours > 0
|
|
38
|
+
? `${expiryHours}小时${expiryMinutes > 0 ? expiryMinutes + '分钟' : ''}`
|
|
39
|
+
: `${expiryMinutes}分钟`;
|
|
40
|
+
return {
|
|
41
|
+
content: [
|
|
42
|
+
{
|
|
43
|
+
type: 'text',
|
|
44
|
+
text: `登录成功!欢迎回来,${user.realName}\n\n` +
|
|
45
|
+
`角色: ${formatRole(user.role)}\n` +
|
|
46
|
+
`Token 有效期: ${expiryText}\n\n` +
|
|
47
|
+
`现在可以使用其他工具查询数据了。`,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
logger.error('Token 验证失败:', error.message);
|
|
54
|
+
return {
|
|
55
|
+
content: [
|
|
56
|
+
{
|
|
57
|
+
type: 'text',
|
|
58
|
+
text: `Token 验证失败: ${error.message}\n\n请确保 Token 正确且未过期。`,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
isError: true,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// No token provided - open browser
|
|
66
|
+
try {
|
|
67
|
+
logger.info('打开浏览器进行登录');
|
|
68
|
+
await open(config.authPageUrl);
|
|
69
|
+
return {
|
|
70
|
+
content: [
|
|
71
|
+
{
|
|
72
|
+
type: 'text',
|
|
73
|
+
text: `已打开浏览器,请完成以下步骤:\n\n` +
|
|
74
|
+
`1. 使用企业微信扫描二维码\n` +
|
|
75
|
+
`2. 在手机上确认授权\n` +
|
|
76
|
+
`3. 登录成功后复制显示的 Token\n` +
|
|
77
|
+
`4. 再次调用 login 工具,并提供 token 参数\n\n` +
|
|
78
|
+
`示例: login(token: "eyJhbGc...")`,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
logger.error('打开浏览器失败:', error.message);
|
|
85
|
+
return {
|
|
86
|
+
content: [
|
|
87
|
+
{
|
|
88
|
+
type: 'text',
|
|
89
|
+
text: `打开浏览器失败: ${error.message}\n\n` +
|
|
90
|
+
`请手动访问: ${config.authPageUrl}`,
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
isError: true,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
// Get current user tool
|
|
99
|
+
export const getCurrentUserTool = {
|
|
100
|
+
name: 'get_current_user',
|
|
101
|
+
description: '获取当前登录用户信息',
|
|
102
|
+
inputSchema: {
|
|
103
|
+
type: 'object',
|
|
104
|
+
properties: {},
|
|
105
|
+
required: [],
|
|
106
|
+
},
|
|
107
|
+
handler: async () => {
|
|
108
|
+
const user = tokenManager.getUser();
|
|
109
|
+
if (!user) {
|
|
110
|
+
return {
|
|
111
|
+
content: [
|
|
112
|
+
{
|
|
113
|
+
type: 'text',
|
|
114
|
+
text: '未登录,请先调用 login 工具进行企业微信登录',
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
isError: true,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
if (!tokenManager.isAuthenticated()) {
|
|
121
|
+
return {
|
|
122
|
+
content: [
|
|
123
|
+
{
|
|
124
|
+
type: 'text',
|
|
125
|
+
text: '登录已过期,请重新调用 login 工具登录',
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
isError: true,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
const loginDuration = tokenManager.getLoginDuration();
|
|
132
|
+
const timeUntilExpiry = tokenManager.getTimeUntilExpiry();
|
|
133
|
+
return {
|
|
134
|
+
content: [
|
|
135
|
+
{
|
|
136
|
+
type: 'text',
|
|
137
|
+
text: `当前用户: ${user.realName}\n` +
|
|
138
|
+
`用户名: ${user.username}\n` +
|
|
139
|
+
`角色: ${formatRole(user.role)}\n` +
|
|
140
|
+
`用户ID: ${user.id}\n\n` +
|
|
141
|
+
`登录状态: ${loginDuration}\n` +
|
|
142
|
+
`Token 状态: ${timeUntilExpiry}`,
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
};
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
// Helper function to validate token
|
|
149
|
+
async function validateToken(token) {
|
|
150
|
+
// Temporarily set the token for validation
|
|
151
|
+
const response = await fetch(`${config.apiBaseUrl}/api/auth/me`, {
|
|
152
|
+
headers: {
|
|
153
|
+
'Authorization': `Bearer ${token}`,
|
|
154
|
+
'Content-Type': 'application/json',
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
if (!response.ok) {
|
|
158
|
+
const errorData = await response.json().catch(() => ({}));
|
|
159
|
+
throw new Error(errorData.message || `验证失败 (${response.status})`);
|
|
160
|
+
}
|
|
161
|
+
const result = await response.json();
|
|
162
|
+
return result.data;
|
|
163
|
+
}
|
|
164
|
+
// Helper function to format role
|
|
165
|
+
function formatRole(role) {
|
|
166
|
+
const roleMap = {
|
|
167
|
+
SUPER_ADMIN: '超级管理员',
|
|
168
|
+
ADMIN: '管理员',
|
|
169
|
+
STAFF: '员工',
|
|
170
|
+
};
|
|
171
|
+
return roleMap[role] || role;
|
|
172
|
+
}
|
|
173
|
+
// Parse token expiry from JWT exp field
|
|
174
|
+
function parseTokenExpiry(token) {
|
|
175
|
+
try {
|
|
176
|
+
const payload = token.split('.')[1];
|
|
177
|
+
if (!payload)
|
|
178
|
+
return 86400;
|
|
179
|
+
const decoded = JSON.parse(Buffer.from(payload, 'base64').toString());
|
|
180
|
+
if (decoded.exp) {
|
|
181
|
+
// exp is Unix timestamp in seconds
|
|
182
|
+
const expiresAt = decoded.exp * 1000;
|
|
183
|
+
const expiresIn = Math.floor((expiresAt - Date.now()) / 1000);
|
|
184
|
+
return Math.max(expiresIn, 0);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
// Parse failed, use default
|
|
189
|
+
}
|
|
190
|
+
return 86400; // Default 24 hours
|
|
191
|
+
}
|
|
192
|
+
export const authTools = [loginTool, getCurrentUserTool];
|
|
193
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/tools/auth.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAqB,MAAM,yBAAyB,CAAC;AAE1E,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAO5C,+DAA+D;AAC/D,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,OAAO;IACb,WAAW,EAAE,sBAAsB;IACnC,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,kCAAkC;aAChD;SACF;QACD,QAAQ,EAAE,EAAE;KACb;IACD,OAAO,EAAE,KAAK,EAAE,IAAwB,EAAuB,EAAE;QAC/D,8CAA8C;QAC9C,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,IAAI,CAAC;gBACH,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;gBAE7B,qCAAqC;gBACrC,MAAM,IAAI,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAE7C,gDAAgD;gBAChD,MAAM,SAAS,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAC/C,MAAM,YAAY,CAAC,gBAAgB,CAAC;oBAClC,WAAW,EAAE,IAAI,CAAC,KAAK;oBACvB,QAAQ,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AS,gBAAgB,CAAC,KAAa;IACrC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACpC,IAAI,CAAC,OAAO;YAAE,OAAO,KAAK,CAAC;QAE3B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QACtE,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YAChB,mCAAmC;YACnC,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;YACrC,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YAC9D,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,4BAA4B;IAC9B,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,mBAAmB;AACnC,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
interface ToolResult {
|
|
2
|
+
content: Array<{
|
|
3
|
+
type: 'text';
|
|
4
|
+
text: string;
|
|
5
|
+
}>;
|
|
6
|
+
isError?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const listClassesTool: {
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: "object";
|
|
13
|
+
properties: {
|
|
14
|
+
search: {
|
|
15
|
+
type: string;
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
status: {
|
|
19
|
+
type: string;
|
|
20
|
+
enum: string[];
|
|
21
|
+
description: string;
|
|
22
|
+
};
|
|
23
|
+
page: {
|
|
24
|
+
type: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
pageSize: {
|
|
28
|
+
type: string;
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
required: never[];
|
|
33
|
+
};
|
|
34
|
+
handler: (args: {
|
|
35
|
+
search?: string;
|
|
36
|
+
status?: string;
|
|
37
|
+
page?: number;
|
|
38
|
+
pageSize?: number;
|
|
39
|
+
}) => Promise<ToolResult>;
|
|
40
|
+
};
|
|
41
|
+
export declare const getClassTool: {
|
|
42
|
+
name: string;
|
|
43
|
+
description: string;
|
|
44
|
+
inputSchema: {
|
|
45
|
+
type: "object";
|
|
46
|
+
properties: {
|
|
47
|
+
classId: {
|
|
48
|
+
type: string;
|
|
49
|
+
description: string;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
required: string[];
|
|
53
|
+
};
|
|
54
|
+
handler: (args: {
|
|
55
|
+
classId: string;
|
|
56
|
+
}) => Promise<ToolResult>;
|
|
57
|
+
};
|
|
58
|
+
export declare const getClassStudentsTool: {
|
|
59
|
+
name: string;
|
|
60
|
+
description: string;
|
|
61
|
+
inputSchema: {
|
|
62
|
+
type: "object";
|
|
63
|
+
properties: {
|
|
64
|
+
classId: {
|
|
65
|
+
type: string;
|
|
66
|
+
description: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
required: string[];
|
|
70
|
+
};
|
|
71
|
+
handler: (args: {
|
|
72
|
+
classId: string;
|
|
73
|
+
}) => Promise<ToolResult>;
|
|
74
|
+
};
|
|
75
|
+
export declare const classTools: ({
|
|
76
|
+
name: string;
|
|
77
|
+
description: string;
|
|
78
|
+
inputSchema: {
|
|
79
|
+
type: "object";
|
|
80
|
+
properties: {
|
|
81
|
+
search: {
|
|
82
|
+
type: string;
|
|
83
|
+
description: string;
|
|
84
|
+
};
|
|
85
|
+
status: {
|
|
86
|
+
type: string;
|
|
87
|
+
enum: string[];
|
|
88
|
+
description: string;
|
|
89
|
+
};
|
|
90
|
+
page: {
|
|
91
|
+
type: string;
|
|
92
|
+
description: string;
|
|
93
|
+
};
|
|
94
|
+
pageSize: {
|
|
95
|
+
type: string;
|
|
96
|
+
description: string;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
required: never[];
|
|
100
|
+
};
|
|
101
|
+
handler: (args: {
|
|
102
|
+
search?: string;
|
|
103
|
+
status?: string;
|
|
104
|
+
page?: number;
|
|
105
|
+
pageSize?: number;
|
|
106
|
+
}) => Promise<ToolResult>;
|
|
107
|
+
} | {
|
|
108
|
+
name: string;
|
|
109
|
+
description: string;
|
|
110
|
+
inputSchema: {
|
|
111
|
+
type: "object";
|
|
112
|
+
properties: {
|
|
113
|
+
classId: {
|
|
114
|
+
type: string;
|
|
115
|
+
description: string;
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
required: string[];
|
|
119
|
+
};
|
|
120
|
+
handler: (args: {
|
|
121
|
+
classId: string;
|
|
122
|
+
}) => Promise<ToolResult>;
|
|
123
|
+
})[];
|
|
124
|
+
export {};
|
|
125
|
+
//# sourceMappingURL=classes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classes.d.ts","sourceRoot":"","sources":["../../src/tools/classes.ts"],"names":[],"mappings":"AAGA,UAAU,UAAU;IAClB,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAGD,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;oBA0BJ;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,KAAG,OAAO,CAAC,UAAU,CAAC;CAmDxB,CAAC;AAGF,eAAO,MAAM,YAAY;;;;;;;;;;;;;oBAaD;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,KAAG,OAAO,CAAC,UAAU,CAAC;CAgChE,CAAC;AAGF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;oBAaT;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,KAAG,OAAO,CAAC,UAAU,CAAC;CAkChE,CAAC;AA2BF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;oBArLC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,KAAG,OAAO,CAAC,UAAU,CAAC;;;;;;;;;;;;;;oBAmED;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,KAAG,OAAO,CAAC,UAAU,CAAC;IAiHhE,CAAC"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { apiClient } from '../api/client.js';
|
|
2
|
+
import { logger } from '../utils/logger.js';
|
|
3
|
+
// List classes
|
|
4
|
+
export const listClassesTool = {
|
|
5
|
+
name: 'list_classes',
|
|
6
|
+
description: '查询班级列表,支持按名称搜索、状态筛选',
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
search: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
description: '班级名称或编号搜索关键词',
|
|
13
|
+
},
|
|
14
|
+
status: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
enum: ['ACTIVE', 'PAUSED', 'GRADUATED', 'DELETED'],
|
|
17
|
+
description: '班级状态筛选: ACTIVE(进行中), PAUSED(暂停), GRADUATED(已结业), DELETED(已删除)',
|
|
18
|
+
},
|
|
19
|
+
page: {
|
|
20
|
+
type: 'number',
|
|
21
|
+
description: '页码,默认1',
|
|
22
|
+
},
|
|
23
|
+
pageSize: {
|
|
24
|
+
type: 'number',
|
|
25
|
+
description: '每页数量,默认20',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
required: [],
|
|
29
|
+
},
|
|
30
|
+
handler: async (args) => {
|
|
31
|
+
try {
|
|
32
|
+
logger.debug('查询班级列表', args);
|
|
33
|
+
const params = {};
|
|
34
|
+
if (args.search)
|
|
35
|
+
params.search = args.search;
|
|
36
|
+
if (args.status)
|
|
37
|
+
params.status = args.status;
|
|
38
|
+
const result = await apiClient.get('/api/classes', params);
|
|
39
|
+
if (!result || result.length === 0) {
|
|
40
|
+
return {
|
|
41
|
+
content: [{ type: 'text', text: '暂无班级数据' }],
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const classes = result.map((c) => ({
|
|
45
|
+
id: c.id,
|
|
46
|
+
name: c.name,
|
|
47
|
+
classNumber: c.classNumber,
|
|
48
|
+
status: formatStatus(c.status),
|
|
49
|
+
course: c.course?.name,
|
|
50
|
+
teacher: c.primaryTeacher?.realName,
|
|
51
|
+
classroom: c.primaryClassroom?.name,
|
|
52
|
+
studentCount: c._count?.classStudents || 0,
|
|
53
|
+
}));
|
|
54
|
+
return {
|
|
55
|
+
content: [
|
|
56
|
+
{
|
|
57
|
+
type: 'text',
|
|
58
|
+
text: `查询结果: 共 ${classes.length} 个班级\n\n` +
|
|
59
|
+
classes.map((c, index) => `${index + 1}. ${c.name} [ID: ${c.id}]\n` +
|
|
60
|
+
` 班号: ${c.classNumber} | 状态: ${c.status}\n` +
|
|
61
|
+
` 课程: ${c.course || '-'}\n` +
|
|
62
|
+
` 教师: ${c.teacher || '-'} | 教室: ${c.classroom || '-'}\n` +
|
|
63
|
+
` 学员数: ${c.studentCount}`).join('\n\n'),
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
logger.error('查询班级列表失败:', error.message);
|
|
70
|
+
return {
|
|
71
|
+
content: [{ type: 'text', text: `查询失败: ${error.message}` }],
|
|
72
|
+
isError: true,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
// Get class detail
|
|
78
|
+
export const getClassTool = {
|
|
79
|
+
name: 'get_class',
|
|
80
|
+
description: '获取班级详细信息',
|
|
81
|
+
inputSchema: {
|
|
82
|
+
type: 'object',
|
|
83
|
+
properties: {
|
|
84
|
+
classId: {
|
|
85
|
+
type: 'string',
|
|
86
|
+
description: '班级ID',
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
required: ['classId'],
|
|
90
|
+
},
|
|
91
|
+
handler: async (args) => {
|
|
92
|
+
try {
|
|
93
|
+
logger.debug('获取班级详情', args);
|
|
94
|
+
const cls = await apiClient.get(`/api/classes/${args.classId}`);
|
|
95
|
+
return {
|
|
96
|
+
content: [
|
|
97
|
+
{
|
|
98
|
+
type: 'text',
|
|
99
|
+
text: `班级详情:\n\n` +
|
|
100
|
+
`名称: ${cls.name}\n` +
|
|
101
|
+
`编号: ${cls.classNumber}\n` +
|
|
102
|
+
`状态: ${formatStatus(cls.status)}\n` +
|
|
103
|
+
`课程: ${cls.course?.name || '-'}\n` +
|
|
104
|
+
`课程类别: ${cls.course?.category?.name || '-'}\n\n` +
|
|
105
|
+
`主讲教师: ${cls.primaryTeacher?.realName || '-'}\n` +
|
|
106
|
+
`教室: ${cls.classroom?.name || '-'}\n\n` +
|
|
107
|
+
`学员数: ${cls._count?.classStudents || 0}\n` +
|
|
108
|
+
`已排课时数: ${cls._count?.courseSessions || 0}\n\n` +
|
|
109
|
+
(cls.notes ? `备注: ${cls.notes}\n` : ''),
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
logger.error('获取班级详情失败:', error.message);
|
|
116
|
+
return {
|
|
117
|
+
content: [{ type: 'text', text: `查询失败: ${error.message}` }],
|
|
118
|
+
isError: true,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
// Get class students
|
|
124
|
+
export const getClassStudentsTool = {
|
|
125
|
+
name: 'get_class_students',
|
|
126
|
+
description: '获取班级学员名单',
|
|
127
|
+
inputSchema: {
|
|
128
|
+
type: 'object',
|
|
129
|
+
properties: {
|
|
130
|
+
classId: {
|
|
131
|
+
type: 'string',
|
|
132
|
+
description: '班级ID',
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
required: ['classId'],
|
|
136
|
+
},
|
|
137
|
+
handler: async (args) => {
|
|
138
|
+
try {
|
|
139
|
+
logger.debug('获取班级学员', args);
|
|
140
|
+
const students = await apiClient.get(`/api/classes/${args.classId}/students`);
|
|
141
|
+
if (!students || students.length === 0) {
|
|
142
|
+
return {
|
|
143
|
+
content: [{ type: 'text', text: '该班级暂无学员' }],
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
const formatted = students.map((s, index) => `${index + 1}. ${s.student?.name || '未知'}\n` +
|
|
147
|
+
` 状态: ${formatStudentStatus(s.student?.status)} | 类型: ${s.student?.studentType === 'FORMAL' ? '正式' : '意向'}\n` +
|
|
148
|
+
` 加入时间: ${formatDate(s.joinedAt)}`).join('\n\n');
|
|
149
|
+
return {
|
|
150
|
+
content: [
|
|
151
|
+
{
|
|
152
|
+
type: 'text',
|
|
153
|
+
text: `班级学员名单 (共 ${students.length} 人):\n\n${formatted}`,
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
logger.error('获取班级学员失败:', error.message);
|
|
160
|
+
return {
|
|
161
|
+
content: [{ type: 'text', text: `查询失败: ${error.message}` }],
|
|
162
|
+
isError: true,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
// Helper functions
|
|
168
|
+
function formatStatus(status) {
|
|
169
|
+
const statusMap = {
|
|
170
|
+
ACTIVE: '进行中',
|
|
171
|
+
PAUSED: '暂停',
|
|
172
|
+
GRADUATED: '已结业',
|
|
173
|
+
DELETED: '已删除',
|
|
174
|
+
};
|
|
175
|
+
return statusMap[status] || status;
|
|
176
|
+
}
|
|
177
|
+
function formatStudentStatus(status) {
|
|
178
|
+
const statusMap = {
|
|
179
|
+
ACTIVE: '学习中',
|
|
180
|
+
PAUSED: '暂停',
|
|
181
|
+
GRADUATED: '毕业',
|
|
182
|
+
};
|
|
183
|
+
return statusMap[status] || status;
|
|
184
|
+
}
|
|
185
|
+
function formatDate(dateStr) {
|
|
186
|
+
if (!dateStr)
|
|
187
|
+
return '-';
|
|
188
|
+
return new Date(dateStr).toLocaleDateString('zh-CN');
|
|
189
|
+
}
|
|
190
|
+
export const classTools = [
|
|
191
|
+
listClassesTool,
|
|
192
|
+
getClassTool,
|
|
193
|
+
getClassStudentsTool,
|
|
194
|
+
];
|
|
195
|
+
//# sourceMappingURL=classes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classes.js","sourceRoot":"","sources":["../../src/tools/classes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAO5C,eAAe;AACf,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,qBAAqB;IAClC,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,cAAc;aAC5B;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,CAAC;gBAClD,WAAW,EAAE,+DAA+D;aAC7E;YACD,IAAI,EAAE;gBACJ,IAAI,E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|
9
|
+
* Query teacher sales and session fees by date range
|
|
10
|
+
*
|
|
11
|
+
* Access Control:
|
|
12
|
+
* - STAFF: Can only query their own data
|
|
13
|
+
* - ADMIN/SUPER_ADMIN: Can query any teacher's data
|
|
14
|
+
*
|
|
15
|
+
* @returns Formatted report with:
|
|
16
|
+
* - Total sessions count
|
|
17
|
+
* - Total sales amount (课销)
|
|
18
|
+
* - Total session fees (课次费)
|
|
19
|
+
* - Session-by-session breakdown
|
|
20
|
+
*/
|
|
21
|
+
export declare const getTeacherSalesTool: {
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
inputSchema: {
|
|
25
|
+
type: "object";
|
|
26
|
+
properties: {
|
|
27
|
+
startDate: {
|
|
28
|
+
type: string;
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
endDate: {
|
|
32
|
+
type: string;
|
|
33
|
+
description: string;
|
|
34
|
+
};
|
|
35
|
+
teacherId: {
|
|
36
|
+
type: string;
|
|
37
|
+
description: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
required: string[];
|
|
41
|
+
};
|
|
42
|
+
handler: (args: {
|
|
43
|
+
startDate: string;
|
|
44
|
+
endDate: string;
|
|
45
|
+
teacherId?: string;
|
|
46
|
+
}) => Promise<ToolResult>;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Query student session balance details
|
|
50
|
+
*
|
|
51
|
+
* Access Control:
|
|
52
|
+
* - All authenticated users can query
|
|
53
|
+
*
|
|
54
|
+
* @returns Student info with:
|
|
55
|
+
* - Name, status, type
|
|
56
|
+
* - Balance per course category
|
|
57
|
+
* - Used vs total sessions breakdown
|
|
58
|
+
*/
|
|
59
|
+
export declare const getStudentBalanceDetailTool: {
|
|
60
|
+
name: string;
|
|
61
|
+
description: string;
|
|
62
|
+
inputSchema: {
|
|
63
|
+
type: "object";
|
|
64
|
+
properties: {
|
|
65
|
+
studentId: {
|
|
66
|
+
type: string;
|
|
67
|
+
description: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
required: string[];
|
|
71
|
+
};
|
|
72
|
+
handler: (args: {
|
|
73
|
+
studentId: string;
|
|
74
|
+
}) => Promise<ToolResult>;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Query session fee rules for all course categories
|
|
78
|
+
*
|
|
79
|
+
* Access Control:
|
|
80
|
+
* - ADMIN/SUPER_ADMIN only (requiredRole: 'ADMIN')
|
|
81
|
+
*
|
|
82
|
+
* @returns List of fee rules organized by category:
|
|
83
|
+
* - Category name
|
|
84
|
+
* - Student count ranges (min-max)
|
|
85
|
+
* - Session rate per student count tier
|
|
86
|
+
*/
|
|
87
|
+
export declare const getSessionFeeRulesTool: {
|
|
88
|
+
name: string;
|
|
89
|
+
description: string;
|
|
90
|
+
inputSchema: {
|
|
91
|
+
type: "object";
|
|
92
|
+
properties: {};
|
|
93
|
+
required: never[];
|
|
94
|
+
};
|
|
95
|
+
requiredRole: "ADMIN";
|
|
96
|
+
handler: () => Promise<ToolResult>;
|
|
97
|
+
};
|
|
98
|
+
export declare const financeTools: ({
|
|
99
|
+
name: string;
|
|
100
|
+
description: string;
|
|
101
|
+
inputSchema: {
|
|
102
|
+
type: "object";
|
|
103
|
+
properties: {
|
|
104
|
+
startDate: {
|
|
105
|
+
type: string;
|
|
106
|
+
description: string;
|
|
107
|
+
};
|
|
108
|
+
endDate: {
|
|
109
|
+
type: string;
|
|
110
|
+
description: string;
|
|
111
|
+
};
|
|
112
|
+
teacherId: {
|
|
113
|
+
type: string;
|
|
114
|
+
description: string;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
required: string[];
|
|
118
|
+
};
|
|
119
|
+
handler: (args: {
|
|
120
|
+
startDate: string;
|
|
121
|
+
endDate: string;
|
|
122
|
+
teacherId?: string;
|
|
123
|
+
}) => Promise<ToolResult>;
|
|
124
|
+
} | {
|
|
125
|
+
name: string;
|
|
126
|
+
description: string;
|
|
127
|
+
inputSchema: {
|
|
128
|
+
type: "object";
|
|
129
|
+
properties: {
|
|
130
|
+
studentId: {
|
|
131
|
+
type: string;
|
|
132
|
+
description: string;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
required: string[];
|
|
136
|
+
};
|
|
137
|
+
handler: (args: {
|
|
138
|
+
studentId: string;
|
|
139
|
+
}) => Promise<ToolResult>;
|
|
140
|
+
} | {
|
|
141
|
+
name: string;
|
|
142
|
+
description: string;
|
|
143
|
+
inputSchema: {
|
|
144
|
+
type: "object";
|
|
145
|
+
properties: {};
|
|
146
|
+
required: never[];
|
|
147
|
+
};
|
|
148
|
+
requiredRole: "ADMIN";
|
|
149
|
+
handler: () => Promise<ToolResult>;
|
|
150
|
+
})[];
|
|
151
|
+
export {};
|
|
152
|
+
//# sourceMappingURL=finance.d.ts.map
|