// SaveMyToken local lab. Run with Node.js 22 or newer. import assert from "node:assert/strict"; // A deterministic controller, not an LLM agent or a live service. const outcomes = ["transient-error", "transient-error", "transient-error", "success"]; const maxAttempts = 3; let attempts = 0, status = "exhausted"; for (const outcome of outcomes) { if (attempts >= maxAttempts) break; attempts++; if (outcome === "success") { status = "complete"; break; } if (outcome === "permanent-error") { status = "failed"; break; } } console.log("Attempts:", attempts); console.log("Final state:", status); assert.equal(attempts, 3); assert.equal(status, "exhausted");