| 1 | /** |
| 2 | * An agent's latest step as the pages show it. The sandbox hands a review, |
| 3 | * a plan or an answer back as a file under /work; an agent that says so |
| 4 | * ("The review is written to `/work/review.json`") is saying it finished |
| 5 | * that, not something anyone needs the path for. |
| 6 | */ |
| 7 | const HANDED_BACK: [RegExp, string][] = [ |
| 8 | [/\/work\/review\.json/, "Wrote its review."], |
| 9 | [/\/work\/plan\.json/, "Wrote the plan."], |
| 10 | [/\/work\/answer\.md/, "Wrote its answer."], |
| 11 | ]; |
| 12 | |
| 13 | export function shownStep(step: string): string { |
| 14 | for (const [path, words] of HANDED_BACK) if (path.test(step)) return words; |
| 15 | // Any other file of the checkout, as the repository names it. |
| 16 | return step.replace(/`?\/work\/repo\/([^\s`]+)`?/g, "$1").replace(/`?\/work\/([^\s`]+)`?/g, "$1"); |
| 17 | } |