feat: seal isolated worker recovery, parent integration and review console
This commit is contained in:
@@ -139,7 +139,7 @@ export class Runtime {
|
||||
|| !!this.deliveries?.projectActive(projectId) || !!this.changeSets?.projectActive(projectId) || !!this.research?.projectActive(projectId) || !!this.engines?.projectActive(projectId) || !!this.browser?.projectActive(projectId) || !!this.taskPlans?.projectActive(projectId) });
|
||||
}
|
||||
changeSetManager() {
|
||||
return this.changeSets ??= new ChangeSetManager(this.store, { projectBusy: (projectId, exceptId) =>
|
||||
return this.changeSets ??= new ChangeSetManager(this.store, { beforeApply: (session, set) => this.workerManager().verifyMerge(session, set), projectBusy: (projectId, exceptId) =>
|
||||
!!this.workers?.projectActive(projectId) || [...this.active.entries()].some(([id, run]) => id !== exceptId && run.project.id === projectId)
|
||||
|| !!this.checks?.projectActive(projectId) || !!this.deliveries?.projectActive(projectId) || !!this.workspaces?.projectActive(projectId) || !!this.research?.projectActive(projectId) || !!this.engines?.projectActive(projectId) || !!this.browser?.projectActive(projectId) || !!this.taskPlans?.projectActive(projectId) });
|
||||
}
|
||||
@@ -270,6 +270,7 @@ export class Runtime {
|
||||
let response, requestStarted = false, responseAccounted = false;
|
||||
try {
|
||||
signal.throwIfAborted(); checkBudget(run.record, task);
|
||||
if (run.worker) { planned.record.workerDispatchedAt = now(); this.store.save(session, { type: 'worker.request_intent' }); }
|
||||
requestStarted = true;
|
||||
response = await this.provider.complete(config, planned.messages, run.project, signal, progress => {
|
||||
if (!requestEvent) requestEvent = this.store.event(session, { kind: 'model', runId: run.id, source: 'model_connection', label: '请求模型服务', phase: 'running', startedAt: now(), contextPlanId: planned.record.id });
|
||||
@@ -290,17 +291,19 @@ export class Runtime {
|
||||
this.requestPlanner().finish(session, planned.record, { response, attempts: planned.record.requestAttempts });
|
||||
if (run.worker) {
|
||||
this.store.recordResponse(session, run.record, response.usage, planned.record.estimatedInputTokens + Math.ceil(Buffer.byteLength(JSON.stringify(response.message), 'utf8') / 3) + 8);
|
||||
responseAccounted = true; this.store.save(session);
|
||||
planned.record.workerUsageAccounted = true; this.store.save(session); responseAccounted = true;
|
||||
}
|
||||
} catch (error) {
|
||||
this.requestPlanner().finish(session, planned.record, { error: Object.assign(new Error(this.provider.redact(error.message ?? String(error))), { name: signal.aborted ? 'AbortError' : error.name }), attempts: planned.record.requestAttempts });
|
||||
if (run.worker && requestStarted && !responseAccounted) {
|
||||
this.store.recordResponse(session, run.record, null, planned.record.estimatedInputTokens + config.maxOutputTokens);
|
||||
planned.record.workerUsageAccounted = true;
|
||||
this.store.save(session, { type: 'worker.request_usage_unknown' });
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
signal.throwIfAborted();
|
||||
if (run.worker) checkBudget(run.record, task);
|
||||
const message = response.message;
|
||||
const calls = message.tool_calls ?? [];
|
||||
if (run.worker && (calls.length > 16 || workerUsage(this.store, run.worker).toolCalls + calls.length > run.worker.budget.maxToolCalls)) throw new BudgetExceeded('worker_tool_limit', '子任务工具次数超出固定累计预算或单次16项上限;这批工具未执行,原响应和用量已保存。');
|
||||
|
||||
Reference in New Issue
Block a user