journal-contract-helpers.ts 723 B

1234567891011121314151617
  1. /**
  2. * 修复原因:journal-contract.ts 顶到 oxlint max-lines 上限(400 行),把各主题模块共用的
  3. * 夹具(CAPS / baseRun / logs)拆到本文件;公开面仍从 journal-contract.ts 导出。
  4. */
  5. import type { RunRecord, StoredEvent } from "../engine/index.js";
  6. const CAPS = { maxConcurrency: 4 };
  7. export function baseRun(runId: string): RunRecord {
  8. return { runId, caps: CAPS, spentTokens: 0, status: "running" };
  9. }
  10. /** 取出一页 log 事件的正文,用于逐页比对(事件种类无关的分页断言用它读得更直白)。 */
  11. export function logs(events: StoredEvent[]): string[] {
  12. return events.map((e) => (e.event.type === "log" ? e.event.message : `<${e.event.type}>`));
  13. }