fix: complete unrestricted waits catalog and network flows
This commit is contained in:
@@ -187,7 +187,7 @@ export class Provider {
|
||||
if (key) headers[messagesAuth === 'bearer' ? 'Authorization' : 'x-api-key'] = messagesAuth === 'bearer' ? 'Bearer ' + key : key;
|
||||
} else if (key) headers.Authorization = 'Bearer ' + key;
|
||||
const requestUrl = base + route;
|
||||
const waits = modelWaitSettings(config), timeoutMs = body ? waits.modelResponseTimeoutMs : 20000;
|
||||
const waits = modelWaitSettings(config), timeoutMs = body || unrestricted(config) ? waits.modelResponseTimeoutMs : 20000;
|
||||
const policy = { attempts: 3, delays: [500, 1500], timeoutMs, totalTimeoutMs: timeoutMs,
|
||||
idleTimeoutMs: waits.modelStreamIdleTimeoutMs, ...this.retryPolicy, ...options };
|
||||
if (config.capacityMode === 'passthrough') policy.attempts = 1;
|
||||
@@ -352,7 +352,7 @@ export class Provider {
|
||||
const body = completionBody(config, messages, tools);
|
||||
assertPlannedRequest(body, requestPlan);
|
||||
if (config.executionMode !== 'unrestricted' && config.inputImages?.length && (!config.modelRouting || !this.hub || config.mode==='demo')) throw new Error('图片请求必须通过模型中心的视觉能力选路,尚未发送。');
|
||||
if (config.mode === 'demo') return this.demo(messages, project);
|
||||
if (config.mode === 'demo') return this.demo(messages, project, config);
|
||||
this.validate(config);
|
||||
const execute = async (selected, key, input, progress) => {
|
||||
return this.request(selected, protocolRoute(selected), input, signal, key, progress, { ...(config.modelRouting ? { attempts: 1 } : {}), ...requestPolicy,
|
||||
@@ -379,7 +379,7 @@ export class Provider {
|
||||
...(calls.length ? { tool_calls: calls } : {}) }, usage: result.usage ?? null, finishReason: result.choices[0].finish_reason ?? null,
|
||||
...(result.compatibility?.length ? { compatibility: result.compatibility } : {}) };
|
||||
}
|
||||
demo(messages, project) {
|
||||
demo(messages, project, config = {}) {
|
||||
const lastUser = messages.findLastIndex(message => message.role === 'user');
|
||||
const results = messages.slice(lastUser + 1).filter(message => message.role === 'tool');
|
||||
const count = results.length;
|
||||
@@ -400,9 +400,9 @@ export class Provider {
|
||||
const user = String(messages[lastUser]?.content ?? '').slice(0, 300);
|
||||
return tool('propose_file', { path: 'WORKBENCH-NOTES.md',
|
||||
content: '# 工作台验证记录\n\n这份记录由离线演示脚本准备,用来验证差异审查与文件写入流程;没有调用大模型。\n\n## 本次任务\n' + user + '\n\n## 项目依据\n' + excerpt.slice(0, 1000) + '\n\n## 下一步\n在工作台查看差异,应用后可继续连接真实模型进行项目开发。\n',
|
||||
reason: '用真实的项目读取结果准备一个可审查的文本提案。' }, '已取得项目依据。我会准备一个文件提案,等待你查看差异后应用。');
|
||||
reason: '用真实的项目读取结果准备一个可审查的文本提案。' }, unrestricted(config) ? '已取得项目依据,接下来直接写入文件并保存差异与回滚资料。' : '已取得项目依据。我会准备一个文件提案,等待你查看差异后应用。');
|
||||
}
|
||||
if (count === 3) return tool('run_command', { command: 'node --version', reason: '只读取本机 Node 版本,演示终端确认与执行记录。' }, '最后请求一次只读的环境验证。确认后会记录实际命令输出。');
|
||||
return { message: { role: 'assistant', content: '离线演示已完成:项目读取、文件提案和终端确认流程都有执行记录。待审查改动可以在右侧查看并应用。\n\n这次没有调用大模型。你可以在“模型连接”中配置自己的兼容服务,随后用同一套工具完成真实开发任务。' }, usage: null, finishReason: 'stop' };
|
||||
return { message: { role: 'assistant', content: (unrestricted(config) ? '离线演示已结束:请在任务记录核对项目读取、文件写入和终端操作的实际结果;文件差异与回滚入口可随时查看。' : '离线演示已完成:项目读取、文件提案和终端确认流程都有执行记录。待审查改动可以在右侧查看并应用。') + '\n\n这次没有调用大模型。你可以在“模型连接”中配置自己的兼容服务,随后用同一套工具完成真实开发任务。' }, usage: null, finishReason: 'stop' };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { unrestricted, ceiling, openToolDefinitions, automaticApproval } from '../shared/contracts/execution-policy.mjs';
|
||||
import { scheduleDeadline } from '../core/models/request-deadline.mjs';
|
||||
import { approvalPresentation } from '../shared/approval-presentation.mjs';
|
||||
import { PreviewManager } from '../core/preview/preview-manager.mjs';
|
||||
import { LocalFilePreviews } from '../core/preview/local-file-preview.mjs';
|
||||
@@ -303,9 +304,9 @@ export class Runtime {
|
||||
if (resume) this.store.message(session, 'system', '从已保存的执行记录继续,已完成的工具结果保留。');
|
||||
session.failure = null;
|
||||
this.store.save(session);
|
||||
const deadline = record.budget.maxDurationMs > 0 ? setTimeout(() => controller.abort(new BudgetExceeded('time_limit', '已到达本次运行的时间预算,执行记录已保存。')), record.budget.maxDurationMs) : null;
|
||||
const deadline = scheduleDeadline(() => controller.abort(new BudgetExceeded('time_limit', '已到达本次运行的时间预算,执行记录已保存。')), record.budget.maxDurationMs);
|
||||
run.promise = this.run(session, config, run).finally(() => {
|
||||
clearTimeout(deadline);
|
||||
deadline?.();
|
||||
try {
|
||||
const status = session.status;
|
||||
if (record.purpose === 'diagnostic') session.status = record.taskStatusBefore;
|
||||
|
||||
Reference in New Issue
Block a user