tencent-edu-assistant-connector 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generation-store.js +12 -0
- package/dist/internal.js +6 -0
- package/dist/leader.js +1 -0
- package/dist/stdio.js +2 -0
- package/dist/tools.js +22 -1
- package/package.json +1 -1
- package/plugin/.codebuddy-plugin/marketplace.json +1 -1
- package/plugin/plugins/tencent-edu-assistant/.codebuddy-plugin/plugin.json +1 -1
package/dist/generation-store.js
CHANGED
|
@@ -465,6 +465,18 @@ export function createGenerationStore(options = {}) {
|
|
|
465
465
|
}
|
|
466
466
|
return changed;
|
|
467
467
|
},
|
|
468
|
+
markSentByRequestId(requestId, sessionId) {
|
|
469
|
+
prune();
|
|
470
|
+
const found = findLive(requestId);
|
|
471
|
+
if (!found)
|
|
472
|
+
return false;
|
|
473
|
+
const [key, task] = found;
|
|
474
|
+
const next = applyMarkSent(task, now(), sessionId);
|
|
475
|
+
if (next === task)
|
|
476
|
+
return false;
|
|
477
|
+
slots.set(key, next);
|
|
478
|
+
return true;
|
|
479
|
+
},
|
|
468
480
|
finalStop(sessionId, reason, currentTopicId) {
|
|
469
481
|
if (!isFinalStopReason(reason))
|
|
470
482
|
return [];
|
package/dist/internal.js
CHANGED
|
@@ -28,6 +28,7 @@ export const INTERNAL_TOOL_NAMES = Object.freeze([
|
|
|
28
28
|
'listExperts',
|
|
29
29
|
'deliverFile',
|
|
30
30
|
'reportGenerationProgress',
|
|
31
|
+
'markPromptSent',
|
|
31
32
|
]);
|
|
32
33
|
/** leader 不可达(切换中)时的提示 */
|
|
33
34
|
export const LEADER_UNAVAILABLE_MESSAGE = '腾讯教育学习助手 本地服务正在切换,请稍后重试';
|
|
@@ -77,6 +78,10 @@ const TOOL_BINDERS = new Map([
|
|
|
77
78
|
'reportGenerationProgress',
|
|
78
79
|
bindTool(z.object({ requestId: z.string().min(1).max(128), report: z.object(PROGRESS_REPORT_SHAPE) }), (backend, args) => backend.reportGenerationProgress(args.requestId, args.report)),
|
|
79
80
|
],
|
|
81
|
+
[
|
|
82
|
+
'markPromptSent',
|
|
83
|
+
bindTool(z.object({ requestId: z.string().min(1).max(128), sessionId: z.string().max(128).optional() }), (backend, args) => backend.markPromptSent(args.requestId, args.sessionId)),
|
|
84
|
+
],
|
|
80
85
|
]);
|
|
81
86
|
/** 请求体 schema */
|
|
82
87
|
const internalBodySchema = z.object({ args: z.unknown().optional() });
|
|
@@ -300,5 +305,6 @@ export function createForwardingToolBackend(options) {
|
|
|
300
305
|
listExperts: () => call('listExperts', {}, timeoutMs),
|
|
301
306
|
deliverFile: async (requestId, filePath) => (await call('deliverFile', { requestId, filePath }, deliverTimeoutMs)),
|
|
302
307
|
reportGenerationProgress: async (requestId, report) => (await call('reportGenerationProgress', { requestId, report }, timeoutMs)),
|
|
308
|
+
markPromptSent: async (requestId, sessionId) => (await call('markPromptSent', sessionId === undefined ? { requestId } : { requestId, sessionId }, timeoutMs)),
|
|
303
309
|
};
|
|
304
310
|
}
|
package/dist/leader.js
CHANGED
package/dist/stdio.js
CHANGED
|
@@ -119,6 +119,7 @@ function createUnavailableBackend(message) {
|
|
|
119
119
|
listExperts: fail,
|
|
120
120
|
deliverFile: fail,
|
|
121
121
|
reportGenerationProgress: fail,
|
|
122
|
+
markPromptSent: fail,
|
|
122
123
|
};
|
|
123
124
|
}
|
|
124
125
|
/**
|
|
@@ -135,6 +136,7 @@ function createDynamicBackend(current) {
|
|
|
135
136
|
listExperts: () => current().listExperts(),
|
|
136
137
|
deliverFile: (requestId, filePath) => current().deliverFile(requestId, filePath),
|
|
137
138
|
reportGenerationProgress: (requestId, report) => current().reportGenerationProgress(requestId, report),
|
|
139
|
+
markPromptSent: (requestId, sessionId) => current().markPromptSent(requestId, sessionId),
|
|
138
140
|
};
|
|
139
141
|
}
|
|
140
142
|
/**
|
package/dist/tools.js
CHANGED
|
@@ -292,6 +292,13 @@ export function createLocalToolBackend(deps = {}) {
|
|
|
292
292
|
throw new Error(PROGRESS_FAILURE_MESSAGES[result.reason]);
|
|
293
293
|
return { requestId, status: result.status };
|
|
294
294
|
},
|
|
295
|
+
markPromptSent: async (requestId, sessionId) => {
|
|
296
|
+
// 只迁移命中的那一个任务:不含 requestId 的答疑对话不会走到这里,天然不影响正常对话
|
|
297
|
+
const changed = resolved.generationStore.markSentByRequestId(requestId, sessionId);
|
|
298
|
+
if (changed)
|
|
299
|
+
resolved.contextStore.markPromptSent();
|
|
300
|
+
return changed;
|
|
301
|
+
},
|
|
295
302
|
};
|
|
296
303
|
}
|
|
297
304
|
/**
|
|
@@ -384,7 +391,20 @@ function registerContextTools(server, backend) {
|
|
|
384
391
|
'以及页面登记的 [待完成的生成任务](requestId、技能包、产物文件名、表单参数、进度上报与交付要求)。' +
|
|
385
392
|
'用户要求生成笔记 / 测验 / 闪卡 / 课程,或消息中出现学习空间任务 requestId 时,必须先调用本工具获取任务要求再执行。' +
|
|
386
393
|
'资料原文只能通过返回的签名地址下载读取,禁止在本地磁盘搜索同名文件。',
|
|
387
|
-
|
|
394
|
+
inputSchema: {
|
|
395
|
+
requestId: z
|
|
396
|
+
.string()
|
|
397
|
+
.min(1)
|
|
398
|
+
.max(128)
|
|
399
|
+
.optional()
|
|
400
|
+
.describe('仅当用户本条消息里出现「学习空间任务 requestId:xxx」时原样传入;用于让页面立即进入生成中。' +
|
|
401
|
+
'普通答疑 / 总结 / 闲聊不要传。'),
|
|
402
|
+
},
|
|
403
|
+
}, ({ requestId }, extra) => runTool(async () => {
|
|
404
|
+
// 连接器形态没有 UserPromptSubmit Hook:由模型回传的 requestId 兜底把该任务标为「已发送」,
|
|
405
|
+
// 只影响该 requestId,未传时不改变任何状态(正常对话零影响)。
|
|
406
|
+
if (requestId !== undefined)
|
|
407
|
+
await backend.markPromptSent(requestId, extra?.sessionId).catch(() => false);
|
|
388
408
|
const [ctx, tasks] = await Promise.all([backend.getPageContext(), backend.getPendingTasks()]);
|
|
389
409
|
return renderPageContext(ctx, tasks);
|
|
390
410
|
}));
|
|
@@ -509,6 +529,7 @@ const SERVER_INSTRUCTIONS = [
|
|
|
509
529
|
'本服务连接用户在 WorkBuddy 内打开的「学习空间」专题详情页。',
|
|
510
530
|
'用户提到「这页 / 这篇 / 这个专题 / 当前资料」而对话中没有 [学习空间页面上下文] 时,调用 get_page_context;',
|
|
511
531
|
'用户要求生成笔记 / 测验 / 闪卡 / 课程,或消息中带有学习空间任务 requestId 而对话中没有 [待完成的生成任务] 时,先调用 get_page_context,严格按其中的技能、进度上报与交付要求执行;',
|
|
532
|
+
'调用 get_page_context 时,若用户本条消息里出现「学习空间任务 requestId:xxx」,把该 id 作为 requestId 入参原样传入(页面据此立即显示生成中),并把它作为本次回复的第一个动作,不要先输出大段文字;其它答疑 / 总结 / 闲聊场景不要传该入参;',
|
|
512
533
|
'资料原文请通过上下文中的签名地址下载,不要在本地磁盘搜索同名文件;',
|
|
513
534
|
`执行页面登记的生成任务时,各阶段调用 ${PROGRESS_TOOL_NAME} 上报进度;`,
|
|
514
535
|
`完成页面登记的生成任务后,调用 ${DELIVER_TOOL_NAME} 交付产物文件。`,
|
package/package.json
CHANGED