(host)
| 138 | ]; |
| 139 | |
| 140 | function initTranscript(host) { |
| 141 | if (!host) return; |
| 142 | host.innerHTML = ""; |
| 143 | host.classList.add("lc-transcript"); |
| 144 | const head = htmlEl("div", { class: "lc-transcript__head" }); |
| 145 | head.appendChild(htmlEl("span", { class: "lc-transcript__title" }, "$ agents-cli playground · root_agent")); |
| 146 | const status = htmlEl("span", { class: "lc-transcript__status" }, "auto · idle"); |
| 147 | head.appendChild(status); |
| 148 | const body = htmlEl("div", { class: "lc-transcript__body" }); |
| 149 | const foot = htmlEl("div", { class: "lc-transcript__foot" }); |
| 150 | const replayBtn = htmlEl("button", { class: "lc-btn lc-btn--ghost", type: "button" }, "↺ Replay"); |
| 151 | replayBtn.style.display = "none"; |
| 152 | replayBtn.addEventListener("click", () => play()); |
| 153 | foot.appendChild(replayBtn); |
| 154 | foot.appendChild(htmlEl("span", { class: "lc-muted" }, "a recorded session — different scenario in /lifecycle")); |
| 155 | host.appendChild(head); |
| 156 | host.appendChild(body); |
| 157 | host.appendChild(foot); |
| 158 | |
| 159 | function turnNode(t) { |
| 160 | if (t.kind === "user") { |
| 161 | const wrap = htmlEl("div", { class: "lc-row lc-row--right" }); |
| 162 | wrap.appendChild(htmlEl("div", { class: "lc-bubble lc-bubble--user" }, t.text)); |
| 163 | return wrap; |
| 164 | } |
| 165 | if (t.kind === "tool") { |
| 166 | const wrap = htmlEl("div", { class: "lc-row" }); |
| 167 | const card = htmlEl("div", { class: "lc-tool" }); |
| 168 | card.appendChild( |
| 169 | htmlEl("div", { class: "lc-tool__sig" }, [ |
| 170 | htmlEl("span", { class: "lc-tool__name" }, t.tool), |
| 171 | htmlEl("span", { class: "lc-muted" }, "(" + t.args + ")"), |
| 172 | ]) |
| 173 | ); |
| 174 | card.appendChild(htmlEl("div", { class: "lc-tool__result" }, "↳ " + t.result)); |
| 175 | wrap.appendChild(card); |
| 176 | return wrap; |
| 177 | } |
| 178 | const wrap = htmlEl("div", { class: "lc-row" }); |
| 179 | wrap.appendChild(htmlEl("div", { class: "lc-bubble lc-bubble--agent" }, t.text)); |
| 180 | return wrap; |
| 181 | } |
| 182 | |
| 183 | function play() { |
| 184 | body.innerHTML = ""; |
| 185 | replayBtn.style.display = "none"; |
| 186 | status.textContent = "auto · playing"; |
| 187 | let i = 0; |
| 188 | function step() { |
| 189 | if (i >= TRANSCRIPT_TURNS.length) { |
| 190 | status.textContent = "auto · done"; |
| 191 | replayBtn.style.display = ""; |
| 192 | return; |
| 193 | } |
| 194 | const node = turnNode(TRANSCRIPT_TURNS[i]); |
| 195 | node.classList.add("lc-fade-in"); |
| 196 | body.appendChild(node); |
| 197 | body.scrollTop = body.scrollHeight; |
no test coverage detected