@auto-ai/agent 2.1.120 → 2.1.122
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/.env.example +2 -1
- package/dist/404/index.html +1 -1
- package/dist/404.html +1 -1
- package/dist/_next/static/chunks/19aa69c07b3642d5.js +1 -0
- package/dist/_next/static/chunks/24459c7365a2b28b.js +1 -0
- package/dist/_next/static/chunks/{d3e2070a86378cfb.js → 33eeef286c328da0.js} +1 -1
- package/dist/_next/static/chunks/3407244006d6a98a.js +1 -0
- package/dist/_next/static/chunks/566e152e480b267a.js +1 -0
- package/dist/_next/static/chunks/6ad4268160f361a6.js +1 -0
- package/dist/_next/static/chunks/{d9a278a2a26e8ee5.js → 6f9a48a7f83e669a.js} +1 -1
- package/dist/_next/static/chunks/7658b5b9c2865eb1.js +1 -0
- package/dist/_next/static/chunks/7a5fd448b280dd64.js +1 -0
- package/dist/_next/static/chunks/{fa677aa06f1c0539.js → 98f0c5604e839ba2.js} +1 -1
- package/dist/_next/static/chunks/a38eccf0bb5ca1e9.js +1 -0
- package/dist/_next/static/chunks/b29a354245bfc377.css +1 -0
- package/dist/_next/static/chunks/b76778c5811ef7a1.js +1 -0
- package/dist/_next/static/chunks/c2bed9d5fa7be4bd.js +1 -0
- package/dist/_next/static/chunks/c5a4977aae6a008c.js +1 -0
- package/dist/_next/static/chunks/e7bd145455a541af.css +4 -0
- package/dist/_next/static/chunks/f2bb685629307d4d.js +1 -0
- package/dist/_next/static/chunks/f7e71ce1c236f806.js +1 -0
- package/dist/_next/static/chunks/{67acc15b8a448e1a.js → fc4be3bcf72559a0.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/index.txt +16 -16
- package/dist/manage/about/index.html +2 -2
- package/dist/manage/about/index.txt +19 -19
- package/dist/manage/add-account/basic/index.html +2 -2
- package/dist/manage/add-account/basic/index.txt +23 -22
- package/dist/manage/add-account/index.html +2 -2
- package/dist/manage/add-account/index.txt +22 -23
- package/dist/manage/agent-teams/index.html +2 -2
- package/dist/manage/agent-teams/index.txt +21 -21
- package/dist/manage/env/index.html +2 -2
- package/dist/manage/env/index.txt +21 -21
- package/dist/manage/general/index.html +2 -2
- package/dist/manage/general/index.txt +19 -19
- package/dist/manage/index.html +1 -1
- package/dist/manage/index.txt +16 -16
- package/dist/manage/mcp/index.html +2 -2
- package/dist/manage/mcp/index.txt +21 -21
- package/dist/manage/permissions/index.html +2 -2
- package/dist/manage/permissions/index.txt +19 -19
- package/dist/manage/skills/index.html +2 -2
- package/dist/manage/skills/index.txt +21 -21
- package/dist/manage/task/index.html +2 -2
- package/dist/manage/task/index.txt +19 -19
- package/dist/manage/teams/index.html +2 -2
- package/dist/manage/teams/index.txt +19 -19
- package/dist/manage/tools/index.html +2 -2
- package/dist/manage/tools/index.txt +21 -21
- package/dist/ws-test.html +129 -191
- package/mcps-runtime/claude-geelib-channel/.mcp.json +18 -0
- package/mcps-runtime/claude-geelib-channel/server/boot.mjs +32 -0
- package/mcps-runtime/claude-geelib-channel/server/geelib-api.mjs +192 -0
- package/mcps-runtime/claude-geelib-channel/server/geelib-auth.mjs +147 -0
- package/mcps-runtime/claude-geelib-channel/server/geelib-client.mjs +63 -0
- package/mcps-runtime/claude-geelib-channel/server/index.mjs +451 -0
- package/mcps-runtime/claude-geelib-channel/server/poll.mjs +457 -0
- package/mcps-runtime/claude-geelib-channel/server/state.mjs +216 -0
- package/package.json +6 -6
- package/tools-runtime/code-tool/index.cjs +1 -0
- package/tools-runtime/code-tool/src/index.ts +7 -1
- package/tools-runtime/git-tool/index.cjs +69 -5
- package/tools-runtime/git-tool/src/workspace.ts +101 -4
- package/tools-runtime/git-tool/src/wsInit.ts +26 -3
- package/dist/_next/static/chunks/249606605eed1993.js +0 -1
- package/dist/_next/static/chunks/424d3f3f176d43d7.js +0 -1
- package/dist/_next/static/chunks/4302af16b34bf750.js +0 -1
- package/dist/_next/static/chunks/4a073924e062c459.css +0 -1
- package/dist/_next/static/chunks/6209b42cbfcf288a.js +0 -1
- package/dist/_next/static/chunks/83bf6e4bc0aad48b.css +0 -4
- package/dist/_next/static/chunks/8b34d657c6bbb8df.js +0 -1
- package/dist/_next/static/chunks/904ad158fd721117.js +0 -1
- package/dist/_next/static/chunks/99063f8d79783308.js +0 -1
- package/dist/_next/static/chunks/9cd912a1967f10df.js +0 -1
- package/dist/_next/static/chunks/c52dcbe269bb02d0.js +0 -1
- package/dist/_next/static/chunks/d01957b1055b357a.js +0 -1
- package/dist/_next/static/chunks/dacc94cf10289334.js +0 -1
- package/dist/_next/static/chunks/fff9d250e482f00e.js +0 -1
- package/skills-runtime/geelib/SKILL.md +0 -229
- package/skills-runtime/geelib/geelib-poller-state.json +0 -17
- package/skills-runtime/geelib/geelib.mjs +0 -762
- /package/dist/_next/static/{fg4nA8liSSLEgWV4WTZDt → pVB1xZbEW09ksdJlV12Zn}/_buildManifest.js +0 -0
- /package/dist/_next/static/{fg4nA8liSSLEgWV4WTZDt → pVB1xZbEW09ksdJlV12Zn}/_clientMiddlewareManifest.json +0 -0
- /package/dist/_next/static/{fg4nA8liSSLEgWV4WTZDt → pVB1xZbEW09ksdJlV12Zn}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
import { homedir } from 'node:os'
|
|
2
|
+
import { join } from 'node:path'
|
|
3
|
+
import { appendFileSync, mkdirSync } from 'node:fs'
|
|
4
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
5
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
6
|
+
import * as z from 'zod'
|
|
7
|
+
import {
|
|
8
|
+
cmdAddComment,
|
|
9
|
+
cmdGetComments,
|
|
10
|
+
cmdGetMatter,
|
|
11
|
+
cmdGetProjectDetail,
|
|
12
|
+
cmdGetUserInfo,
|
|
13
|
+
cmdListMatterStatuses,
|
|
14
|
+
cmdListMatterTypes,
|
|
15
|
+
cmdListMatters,
|
|
16
|
+
cmdListProjectMembers,
|
|
17
|
+
cmdListProjects,
|
|
18
|
+
cmdUpdateMatter,
|
|
19
|
+
} from './geelib-api.mjs'
|
|
20
|
+
import {
|
|
21
|
+
extractMatterTitle,
|
|
22
|
+
markMatterInProgress,
|
|
23
|
+
markMatterProcessed,
|
|
24
|
+
rollbackDispatch,
|
|
25
|
+
syncUnstartedTaskQueue,
|
|
26
|
+
takeNextForDispatch,
|
|
27
|
+
resolveSelfTestStatusId,
|
|
28
|
+
} from './poll.mjs'
|
|
29
|
+
import { GeelibStateStore } from './state.mjs'
|
|
30
|
+
|
|
31
|
+
const stateDir =
|
|
32
|
+
process.env.GEELIB_STATE_DIR ||
|
|
33
|
+
join(homedir(), '.claude', 'channels', 'geelib')
|
|
34
|
+
const bootLogFile = join(stateDir, 'boot.log')
|
|
35
|
+
const DEFAULT_POLL_MS = 60_000
|
|
36
|
+
const pollIntervalMs = Math.max(
|
|
37
|
+
10_000,
|
|
38
|
+
Number(process.env.GEELIB_POLL_INTERVAL_MS) || DEFAULT_POLL_MS,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
mkdirSync(stateDir, { recursive: true })
|
|
42
|
+
|
|
43
|
+
function logBoot(line) {
|
|
44
|
+
try {
|
|
45
|
+
appendFileSync(bootLogFile, `${new Date().toISOString()} ${line}\n`, {
|
|
46
|
+
encoding: 'utf8',
|
|
47
|
+
mode: 0o600,
|
|
48
|
+
flag: 'a',
|
|
49
|
+
})
|
|
50
|
+
} catch {}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
logBoot(`[BOOT] geelib-channel index.mjs start pid=${process.pid}`)
|
|
54
|
+
|
|
55
|
+
process.on('uncaughtException', err => {
|
|
56
|
+
logBoot(`[BOOT] uncaughtException ${err?.stack || err}`)
|
|
57
|
+
})
|
|
58
|
+
process.on('unhandledRejection', err => {
|
|
59
|
+
logBoot(`[BOOT] unhandledRejection ${err?.stack || err}`)
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
const store = new GeelibStateStore(stateDir)
|
|
63
|
+
const server = new McpServer(
|
|
64
|
+
{
|
|
65
|
+
name: 'geelib-channel',
|
|
66
|
+
version: '0.1.0',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
capabilities: {
|
|
70
|
+
experimental: {
|
|
71
|
+
'claude/channel': {},
|
|
72
|
+
},
|
|
73
|
+
tools: {},
|
|
74
|
+
},
|
|
75
|
+
instructions: [
|
|
76
|
+
'GeeLib 新任务通过 notifications/claude/channel 入站。',
|
|
77
|
+
'处理完成后使用 add_comment 写回说明;geelib_mark_processed 标记已处理。',
|
|
78
|
+
'也可主动调用 list_matters / get_matter_detail 等工具查询。',
|
|
79
|
+
].join('\n'),
|
|
80
|
+
},
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
let pollTimer = null
|
|
84
|
+
let pollInFlight = false
|
|
85
|
+
|
|
86
|
+
function jsonText(data) {
|
|
87
|
+
return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] }
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function emitClaudeChannelNotification(envelope) {
|
|
91
|
+
const matterId = String(envelope.matterId ?? '')
|
|
92
|
+
const meta = Object.fromEntries(
|
|
93
|
+
Object.entries({
|
|
94
|
+
matter_id: matterId,
|
|
95
|
+
message_id: matterId,
|
|
96
|
+
sub_id: envelope.subId != null ? String(envelope.subId) : '',
|
|
97
|
+
type_id: envelope.typeId != null ? String(envelope.typeId) : '',
|
|
98
|
+
title: envelope.title ?? '',
|
|
99
|
+
}).filter(([, v]) => v !== ''),
|
|
100
|
+
)
|
|
101
|
+
const params = {
|
|
102
|
+
content: envelope.content,
|
|
103
|
+
meta,
|
|
104
|
+
}
|
|
105
|
+
logBoot(
|
|
106
|
+
`[NOTIFY] matter_id=${matterId} title=${String(envelope.title || '').slice(0, 80)}`,
|
|
107
|
+
)
|
|
108
|
+
await server.server.notification({
|
|
109
|
+
method: 'notifications/claude/channel',
|
|
110
|
+
params,
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** 推送单条任务 channel 通知,并写入 inbox。 */
|
|
115
|
+
async function notifyTaskItem(item) {
|
|
116
|
+
const matterId = Number(item.matterId)
|
|
117
|
+
const subId = Number(item.subId)
|
|
118
|
+
const typeId = Number(item.typeId)
|
|
119
|
+
const title = item.title ?? extractMatterTitle(item.matter ?? {})
|
|
120
|
+
const content = [
|
|
121
|
+
`[GeeLib 新任务] #${matterId} ${title}`,
|
|
122
|
+
`sub_id=${subId} type_id=${typeId}`,
|
|
123
|
+
].join('\n')
|
|
124
|
+
|
|
125
|
+
store.appendInbox({
|
|
126
|
+
matterId: String(matterId),
|
|
127
|
+
subId,
|
|
128
|
+
typeId,
|
|
129
|
+
title,
|
|
130
|
+
text: content,
|
|
131
|
+
matter: item.matter,
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
await emitClaudeChannelNotification({
|
|
135
|
+
matterId,
|
|
136
|
+
subId,
|
|
137
|
+
typeId,
|
|
138
|
+
title,
|
|
139
|
+
content,
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** 空闲时从队列头 dispatch 下一条任务:先改「处理中」,再 NOTIFY 启动 agent。 */
|
|
144
|
+
async function dispatchOneIfIdle() {
|
|
145
|
+
const item = takeNextForDispatch(store)
|
|
146
|
+
if (!item) {
|
|
147
|
+
return false
|
|
148
|
+
}
|
|
149
|
+
const matterId = Number(item.matterId)
|
|
150
|
+
try {
|
|
151
|
+
const progress = await markMatterInProgress(store, item)
|
|
152
|
+
logBoot(
|
|
153
|
+
`[DISPATCH] matter_id=${matterId} status=处理中 status_id=${progress.inProgressStatusId}`,
|
|
154
|
+
)
|
|
155
|
+
await notifyTaskItem(item)
|
|
156
|
+
return true
|
|
157
|
+
} catch (err) {
|
|
158
|
+
rollbackDispatch(store, item)
|
|
159
|
+
logBoot(
|
|
160
|
+
`[DISPATCH] matter_id=${matterId} rollback err=${err?.message || err}`,
|
|
161
|
+
)
|
|
162
|
+
throw err
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** 后台轮询:一次拉全量未开始任务入队,再串行 dispatch 一条。 */
|
|
167
|
+
async function pollAndNotify() {
|
|
168
|
+
if (pollInFlight) {
|
|
169
|
+
return
|
|
170
|
+
}
|
|
171
|
+
pollInFlight = true
|
|
172
|
+
try {
|
|
173
|
+
const sync = await syncUnstartedTaskQueue(store)
|
|
174
|
+
logBoot(
|
|
175
|
+
`[POLL] queue=${sync.queueLength} newly=${sync.newlyEnqueued} active=${sync.activeMatterId ?? 'none'}`,
|
|
176
|
+
)
|
|
177
|
+
await dispatchOneIfIdle()
|
|
178
|
+
} catch (err) {
|
|
179
|
+
logBoot(`[POLL] error ${err?.stack || err}`)
|
|
180
|
+
console.error('[geelib-channel] poll error:', err?.message || err)
|
|
181
|
+
} finally {
|
|
182
|
+
pollInFlight = false
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** 任务完成后立即尝试 dispatch 队列中下一条。 */
|
|
187
|
+
async function continueQueueAfterComplete(matterId) {
|
|
188
|
+
markMatterProcessed(store, matterId)
|
|
189
|
+
logBoot(`[POLL] completed matter_id=${matterId}, try dispatch next`)
|
|
190
|
+
try {
|
|
191
|
+
await dispatchOneIfIdle()
|
|
192
|
+
} catch (err) {
|
|
193
|
+
logBoot(`[POLL] dispatch-after-complete error ${err?.stack || err}`)
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function startPollLoop() {
|
|
198
|
+
if (pollTimer) {
|
|
199
|
+
return
|
|
200
|
+
}
|
|
201
|
+
logBoot(`[POLL] start intervalMs=${pollIntervalMs}`)
|
|
202
|
+
void pollAndNotify()
|
|
203
|
+
pollTimer = setInterval(() => {
|
|
204
|
+
void pollAndNotify()
|
|
205
|
+
}, pollIntervalMs)
|
|
206
|
+
pollTimer.unref?.()
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
server.registerTool(
|
|
210
|
+
'get_user_info',
|
|
211
|
+
{ description: '获取当前 GeeLib 登录用户信息', inputSchema: {} },
|
|
212
|
+
async () => jsonText(await cmdGetUserInfo()),
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
server.registerTool(
|
|
216
|
+
'list_projects',
|
|
217
|
+
{
|
|
218
|
+
description: '列出当前用户可访问的项目',
|
|
219
|
+
inputSchema: { query: z.string().optional().default('') },
|
|
220
|
+
},
|
|
221
|
+
async ({ query }) => jsonText(await cmdListProjects(query)),
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
server.registerTool(
|
|
225
|
+
'get_project_detail',
|
|
226
|
+
{
|
|
227
|
+
description: '获取项目详情',
|
|
228
|
+
inputSchema: { sub_id: z.number() },
|
|
229
|
+
},
|
|
230
|
+
async ({ sub_id }) => jsonText(await cmdGetProjectDetail(sub_id)),
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
server.registerTool(
|
|
234
|
+
'list_project_members',
|
|
235
|
+
{
|
|
236
|
+
description: '列出项目成员',
|
|
237
|
+
inputSchema: { sub_id: z.number() },
|
|
238
|
+
},
|
|
239
|
+
async ({ sub_id }) => jsonText(await cmdListProjectMembers(sub_id)),
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
server.registerTool(
|
|
243
|
+
'list_matter_types',
|
|
244
|
+
{
|
|
245
|
+
description: '列出项目下的工作项类型',
|
|
246
|
+
inputSchema: { sub_id: z.number() },
|
|
247
|
+
},
|
|
248
|
+
async ({ sub_id }) => jsonText(await cmdListMatterTypes(sub_id)),
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
server.registerTool(
|
|
252
|
+
'list_matter_statuses',
|
|
253
|
+
{
|
|
254
|
+
description: '列出工作项类型下的状态列表',
|
|
255
|
+
inputSchema: { sub_id: z.number(), type_id: z.number() },
|
|
256
|
+
},
|
|
257
|
+
async ({ sub_id, type_id }) =>
|
|
258
|
+
jsonText(await cmdListMatterStatuses(sub_id, type_id)),
|
|
259
|
+
)
|
|
260
|
+
|
|
261
|
+
server.registerTool(
|
|
262
|
+
'list_matters',
|
|
263
|
+
{
|
|
264
|
+
description: '分页查询工作项列表',
|
|
265
|
+
inputSchema: {
|
|
266
|
+
sub_id: z.number(),
|
|
267
|
+
type_id: z.number(),
|
|
268
|
+
page: z.number().optional().default(1),
|
|
269
|
+
page_size: z.number().optional().default(20),
|
|
270
|
+
keyword: z.string().optional(),
|
|
271
|
+
status_id: z.number().optional(),
|
|
272
|
+
assignee_id: z.number().optional(),
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
async ({
|
|
276
|
+
sub_id,
|
|
277
|
+
type_id,
|
|
278
|
+
page,
|
|
279
|
+
page_size,
|
|
280
|
+
keyword,
|
|
281
|
+
status_id,
|
|
282
|
+
assignee_id,
|
|
283
|
+
}) =>
|
|
284
|
+
jsonText(
|
|
285
|
+
await cmdListMatters({
|
|
286
|
+
subId: sub_id,
|
|
287
|
+
typeId: type_id,
|
|
288
|
+
page,
|
|
289
|
+
pageSize: page_size,
|
|
290
|
+
keyword,
|
|
291
|
+
statusId: status_id,
|
|
292
|
+
assigneeId: assignee_id,
|
|
293
|
+
}),
|
|
294
|
+
),
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
server.registerTool(
|
|
298
|
+
'get_matter_detail',
|
|
299
|
+
{
|
|
300
|
+
description: '获取工作项详情',
|
|
301
|
+
inputSchema: { sub_id: z.number(), matter_id: z.number() },
|
|
302
|
+
},
|
|
303
|
+
async ({ sub_id, matter_id }) =>
|
|
304
|
+
jsonText(await cmdGetMatter(sub_id, matter_id)),
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
server.registerTool(
|
|
308
|
+
'update_matter',
|
|
309
|
+
{
|
|
310
|
+
description: '更新工作项字段或状态',
|
|
311
|
+
inputSchema: {
|
|
312
|
+
sub_id: z.number(),
|
|
313
|
+
matter_id: z.number(),
|
|
314
|
+
title: z.string().optional(),
|
|
315
|
+
description: z.string().optional(),
|
|
316
|
+
status_id: z.number().optional(),
|
|
317
|
+
assignee_id: z.number().optional(),
|
|
318
|
+
priority: z.enum(['low', 'medium', 'high', 'urgent']).optional(),
|
|
319
|
+
progress: z.number().optional(),
|
|
320
|
+
sprint_id: z.number().optional(),
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
async args =>
|
|
324
|
+
jsonText(
|
|
325
|
+
await cmdUpdateMatter({
|
|
326
|
+
subId: args.sub_id,
|
|
327
|
+
matterId: args.matter_id,
|
|
328
|
+
title: args.title,
|
|
329
|
+
description: args.description,
|
|
330
|
+
statusId: args.status_id,
|
|
331
|
+
assigneeId: args.assignee_id,
|
|
332
|
+
priority: args.priority,
|
|
333
|
+
progress: args.progress,
|
|
334
|
+
sprintId: args.sprint_id,
|
|
335
|
+
}),
|
|
336
|
+
),
|
|
337
|
+
)
|
|
338
|
+
|
|
339
|
+
server.registerTool(
|
|
340
|
+
'get_comments',
|
|
341
|
+
{
|
|
342
|
+
description: '获取工作项评论列表',
|
|
343
|
+
inputSchema: { sub_id: z.number(), matter_id: z.number() },
|
|
344
|
+
},
|
|
345
|
+
async ({ sub_id, matter_id }) =>
|
|
346
|
+
jsonText(await cmdGetComments(sub_id, matter_id)),
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
server.registerTool(
|
|
350
|
+
'add_comment',
|
|
351
|
+
{
|
|
352
|
+
description: '向工作项添加评论',
|
|
353
|
+
inputSchema: {
|
|
354
|
+
sub_id: z.number(),
|
|
355
|
+
matter_id: z.number(),
|
|
356
|
+
content: z.string(),
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
async ({ sub_id, matter_id, content }) => {
|
|
360
|
+
const resp = await cmdAddComment(sub_id, matter_id, content)
|
|
361
|
+
return {
|
|
362
|
+
content: [{ type: 'text', text: JSON.stringify(resp, null, 2) }],
|
|
363
|
+
structuredContent: {
|
|
364
|
+
matter_id,
|
|
365
|
+
comment_id: resp?.data?.id ?? resp?.data?.comment_id,
|
|
366
|
+
},
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
)
|
|
370
|
+
|
|
371
|
+
server.registerTool(
|
|
372
|
+
'geelib_check_new',
|
|
373
|
+
{
|
|
374
|
+
description: '检查本地 inbox 是否有未读 GeeLib 新任务',
|
|
375
|
+
inputSchema: { after_cursor: z.number().optional().default(0) },
|
|
376
|
+
},
|
|
377
|
+
async ({ after_cursor }) => {
|
|
378
|
+
const rows = store.listInbox(20, true, after_cursor)
|
|
379
|
+
return {
|
|
380
|
+
content: [
|
|
381
|
+
{
|
|
382
|
+
type: 'text',
|
|
383
|
+
text: rows.length
|
|
384
|
+
? `There are ${rows.length} unread GeeLib tasks.`
|
|
385
|
+
: 'No unread GeeLib tasks.',
|
|
386
|
+
},
|
|
387
|
+
],
|
|
388
|
+
structuredContent: { unread: rows.length, tasks: rows },
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
)
|
|
392
|
+
|
|
393
|
+
server.registerTool(
|
|
394
|
+
'geelib_mark_processed',
|
|
395
|
+
{
|
|
396
|
+
description:
|
|
397
|
+
'agent 处理完成后调用:将工作项状态改为「自测&联调中」并标记已处理,停止重复轮询推送',
|
|
398
|
+
inputSchema: {
|
|
399
|
+
sub_id: z.number(),
|
|
400
|
+
matter_id: z.number(),
|
|
401
|
+
},
|
|
402
|
+
},
|
|
403
|
+
async ({ sub_id, matter_id }) => {
|
|
404
|
+
const pollerState = store.loadPollerState()
|
|
405
|
+
const selfTestStatusId = resolveSelfTestStatusId(pollerState, sub_id)
|
|
406
|
+
if (selfTestStatusId === null) {
|
|
407
|
+
throw new Error(
|
|
408
|
+
`未找到 sub_id=${sub_id} 的完成后目标状态,请确认 GEELIB_SUB_ID 已配置且 poll 已完成发现`,
|
|
409
|
+
)
|
|
410
|
+
}
|
|
411
|
+
const statusResult = await cmdUpdateMatter({
|
|
412
|
+
subId: sub_id,
|
|
413
|
+
matterId: matter_id,
|
|
414
|
+
statusId: selfTestStatusId,
|
|
415
|
+
})
|
|
416
|
+
await continueQueueAfterComplete(matter_id)
|
|
417
|
+
return {
|
|
418
|
+
content: [
|
|
419
|
+
{
|
|
420
|
+
type: 'text',
|
|
421
|
+
text: `Matter ${matter_id} moved to 自测&联调中 and marked processed.`,
|
|
422
|
+
},
|
|
423
|
+
],
|
|
424
|
+
structuredContent: {
|
|
425
|
+
matter_id,
|
|
426
|
+
sub_id,
|
|
427
|
+
self_test_status_id: selfTestStatusId,
|
|
428
|
+
status_result: statusResult,
|
|
429
|
+
},
|
|
430
|
+
}
|
|
431
|
+
},
|
|
432
|
+
)
|
|
433
|
+
|
|
434
|
+
async function main() {
|
|
435
|
+
logBoot('[BOOT] main() starting')
|
|
436
|
+
const transport = new StdioServerTransport()
|
|
437
|
+
await server.connect(transport)
|
|
438
|
+
startPollLoop()
|
|
439
|
+
logBoot('[BOOT] server.connect completed')
|
|
440
|
+
console.error('[geelib-channel] MCP server running')
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
main()
|
|
444
|
+
.then(() => {
|
|
445
|
+
logBoot('[BOOT] main resolved')
|
|
446
|
+
})
|
|
447
|
+
.catch(err => {
|
|
448
|
+
logBoot(`[BOOT] fatal ${err?.stack || err}`)
|
|
449
|
+
console.error('[geelib-channel] fatal', err)
|
|
450
|
+
process.exit(1)
|
|
451
|
+
})
|