Bläddra i källkod

fix(tui): 展示科研预算用量与硬上限追加建议

科研执行采用完成优先策略后,终端需要区分软目标超额与硬上限暂停。

- 结果卡片展示实际用量、计划预算及服务端预算提示
- 单独展示建议追加上限,不声称已自动增加额度
- 20 项结果卡片测试及 TUI 类型检查通过
邵勃源 1 dag sedan
förälder
incheckning
223a85ed80
2 ändrade filer med 23 tillägg och 0 borttagningar
  1. 3 0
      packages/tui/src/util/agentpaas.ts
  2. 20 0
      packages/tui/test/util/agentpaas.test.ts

+ 3 - 0
packages/tui/src/util/agentpaas.ts

@@ -40,6 +40,7 @@ export function paasCard(metadata: Record<string, unknown>, input: Record<string
   const observations = record(science?.observations)
   const decisionSupport = record(science?.decision_support)
   const control = record(science?.control)
+  const budget = record(science?.budget)
   const capabilities = record(science?.capabilities)
   const schedule = record(science?.study_schedule)
   const synthesis = record(science?.synthesis)
@@ -80,6 +81,8 @@ export function paasCard(metadata: Record<string, unknown>, input: Record<string
       operation?.operation === "clarify" ? "本次操作:等待说明研究意图;未启动研究或实验" : "",
       record(acceptance?.plan_review)?.status === "not_reassessed" ? "原方案:本次未重审,原有待修订项继续保留;review-parent-gate.json" : "",
       text(science?.next_step) ? `下一步研究:${text(science?.next_step)}` : "",
+      budget ? `科研预算:已用 ${number(budget.actual_tokens)} / 计划 ${number(budget.token_budget)} tokens;${text(budget.budget_message)}` : "",
+      record(budget?.extension_request) ? `追加建议:将 max_actual_tokens 调整至 ${number(record(budget?.extension_request)?.suggested_limit)} 后继续;未自动增加上限` : "",
       decisionSupport ? `验证选择:${number(decisionSupport.hypotheses)} 个假设、${number(decisionSupport.candidate_checks)} 项候选检查;未代表执行或独立验收;research-decisions.json 查看依据与缺口` : "",
       control?.continue_automatically === false ? "本次已停止;上述后续建议尚未自动执行,可在当前会话继续补充条件或反馈" : "",
       capabilities?.status === "plans_only_no_registered_input" ? "当前可生成研究计划;实际计算需先注册数据或选择模拟器" : "",

+ 20 - 0
packages/tui/test/util/agentpaas.test.ts

@@ -195,3 +195,23 @@ test("candidate check counts do not imply completed studies", () => {
   expect(card.lines.join("\n")).toContain("0/2 项计算完成")
   expect(card.lines.join("\n")).toContain("research-decisions.json 查看依据与缺口")
 })
+
+test("shows research soft overrun and the explicit hard-limit extension separately", () => {
+  const card = paasCard({
+    status: "completed",
+    research: { science: { budget: {
+      actual_tokens: 210000, token_budget: 180000, budget_status: "exceeded",
+      budget_message: "已超过计划预算 30000 tokens,流程已完成。",
+    } } },
+  })
+  expect(card.lines.join("\n")).toContain("210000 / 计划 180000")
+  expect(card.lines.join("\n")).toContain("超过计划预算 30000")
+  const blocked = paasCard({
+    status: "completed",
+    research: { science: { budget: {
+      actual_tokens: 210000, token_budget: 180000, budget_message: "下一步触及硬上限",
+      extension_request: { suggested_limit: 300000 },
+    } } },
+  })
+  expect(blocked.lines.join("\n")).toContain("300000 后继续;未自动增加上限")
+})