MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / waitForCompletedTurn

Function waitForCompletedTurn

scripts/smoke-claw-code-desktop.mjs:134–153  ·  view source on GitHub ↗
(uiUrl)

Source from the content-addressed store, hash-verified

132}
133
134async function waitForCompletedTurn(uiUrl) {
135 let lastState = null
136 for (let index = 0; index < 120; index += 1) {
137 lastState = await waitForJson(`${uiUrl}/api/state`, 1, 1)
138 const lastAssistant = [...(lastState.transcript || [])]
139 .reverse()
140 .find(entry => entry.role === 'assistant')
141
142 if (lastState.run.status === 'idle' && lastAssistant?.content) {
143 return {
144 state: lastState,
145 lastAssistant,
146 }
147 }
148
149 await sleep(500)
150 }
151
152 throw new Error('桌面 launcher 没有在预期时间内完成本轮运行。')
153}
154
155async function main() {
156 await mkdir(launcherDataDir, { recursive: true })

Callers 1

mainFunction · 0.70

Calls 2

waitForJsonFunction · 0.70
sleepFunction · 0.70

Tested by

no test coverage detected