fix: stabilize MindSpace local workflows
Signed-off-by: john <cynell@139.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import crypto from 'node:crypto';
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
|
||||
const JOB_TYPES = new Set(['generate_page', 'analyze_asset', 'summarize']);
|
||||
@@ -625,6 +626,20 @@ export function createAgentJobService(pool, options = {}) {
|
||||
return jobResponse({ ...job, progress_json: JSON.stringify(payload), heartbeat_at: now });
|
||||
};
|
||||
|
||||
const setSessionId = async (jobId, token, sessionId) => {
|
||||
await requireJobToken(jobId, token);
|
||||
const normalizedSessionId = String(sessionId ?? '').trim();
|
||||
if (!normalizedSessionId) {
|
||||
throw agentJobError('Agent 会话不能为空', 'invalid_agent_job_input');
|
||||
}
|
||||
await pool.query(
|
||||
`UPDATE h5_agent_jobs
|
||||
SET session_id = ?, updated_at = ?
|
||||
WHERE id = ?`,
|
||||
[normalizedSessionId, nowFactory(), jobId],
|
||||
);
|
||||
};
|
||||
|
||||
const completeJob = async (jobId, token, input) => {
|
||||
const job = await requireJobToken(jobId, token);
|
||||
const now = nowFactory();
|
||||
@@ -722,6 +737,7 @@ export function createAgentJobService(pool, options = {}) {
|
||||
reapStaleJobs,
|
||||
getAssetForJob,
|
||||
heartbeat,
|
||||
setSessionId,
|
||||
completeJob,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user