(args)
| 462 | } |
| 463 | async function delay(ms) { |
| 464 | await new Promise((resolve) => setTimeout(resolve, ms)); |
| 465 | } |
| 466 | async function writeFileAtomically(target, contents, options = {}) { |
| 467 | const encoding = options.encoding || "utf8"; |
| 468 | const attempts = Math.max(1, Number(options.attempts) || 5); |
| 469 | const temp = path.join(os.tmpdir(), `opencode-loop-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}.tmp`); |
| 470 | await fs.writeFile(temp, contents, encoding); |
| 471 | try { |
| 472 | let lastError; |