feat: verify owned DeepSeek engine connections and responsive task execution
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { createHash } from 'node:crypto';
|
||||
|
||||
export const ENGINE_ACTIVE = new Set(['queued', 'starting', 'initializing', 'checking', 'stopping']);
|
||||
export const ENGINE_SCOPE = 'deepseek-sdk-connection-probe';
|
||||
export const ENGINE_LIMITS = Object.freeze([
|
||||
'当前接入核验启动、会话目录、协议错误和关闭;工程执行接入开发中。',
|
||||
'SDK没有单会话cancel或close;停止以所属独立进程为单位。',
|
||||
'SDK serverInfo.version与发行包版本分别核对,没有有效协议版本协商。',
|
||||
'SDK事件覆盖运行时会话树,idle事件不能直接判项目交付完成。',
|
||||
]);
|
||||
export const engineError = (message, status = 409, code = 'ENGINE_CONTRACT') => Object.assign(new Error(message), { status, code });
|
||||
export const engineDigest = value => createHash('sha256').update(typeof value === 'string' ? value : JSON.stringify(value), 'utf8').digest('hex');
|
||||
|
||||
export function engineInput(job) {
|
||||
return { schemaVersion: 1, jobId: job.id, sessionId: job.sessionId, projectId: job.projectId,
|
||||
taskId: job.taskId, runId: job.runId, engineId: job.engineId, scope: job.scope,
|
||||
installation: job.installation, sdkSessionId: job.sdkSessionId, directory: job.directory,
|
||||
protocolMethods: ['initialize', 'session/working-directory/get', 'session/wait', 'session/resume', 'session/cancel', 'shutdown'],
|
||||
modelRequestsAllowed: 0, externalProjectToolsAllowed: false };
|
||||
}
|
||||
|
||||
export function engineReportContract(job) {
|
||||
return { schemaVersion: 1, inputSha256: job.contractSha256, owner: { sessionId: job.sessionId,
|
||||
projectId: job.projectId, taskId: job.taskId, runId: job.runId, jobId: job.id },
|
||||
engineId: job.engineId, scope: job.scope, installationSha256: job.installation.identitySha256,
|
||||
sdkSessionId: job.sdkSessionId, outcome: { status: job.status, error: job.error ?? null, verification: job.verification }, report: job.report };
|
||||
}
|
||||
|
||||
export function publicEngineJob(job) {
|
||||
const { report, ...value } = job;
|
||||
return { ...value, reportSummary: report ? { status: report.status, modelRequests: report.modelRequests,
|
||||
providerRequests: report.providerRequests, observedResponses: report.responses?.length ?? 0,
|
||||
rootExited: report.cleanup?.rootExited ?? null } : null };
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { randomUUID } from 'node:crypto';
|
||||
|
||||
export const EXECUTION_SCHEMA = 1;
|
||||
export const ACTIVE_STATES = new Set(['running', 'awaiting_approval', 'stopping']);
|
||||
export const CORE_KINDS = ['task', 'run', 'step', 'tool', 'artifact', 'check_plan', 'check_job', 'delivery_plan', 'delivery_job', 'change_set', 'context_plan', 'workspace', 'research_target', 'research_job'];
|
||||
export const CORE_KINDS = ['task', 'run', 'step', 'tool', 'artifact', 'check_plan', 'check_job', 'delivery_plan', 'delivery_job', 'change_set', 'context_plan', 'workspace', 'research_target', 'research_job', 'engine_job'];
|
||||
export const timestamp = () => new Date().toISOString();
|
||||
export const isId = value => typeof value === 'string' && /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(value);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user