| 298 | }); |
| 299 | |
| 300 | const completePausedResult = async ( |
| 301 | client: Client, |
| 302 | initial: ToolCallResult, |
| 303 | ): Promise<Record<string, unknown>> => { |
| 304 | let result = initial; |
| 305 | for (let attempt = 0; attempt < 5; attempt++) { |
| 306 | if (result.isError) { |
| 307 | fail(`tool returned isError: ${JSON.stringify(result.content)}`); |
| 308 | } |
| 309 | |
| 310 | const structured = result.structuredContent; |
| 311 | if (!isRecord(structured)) { |
| 312 | fail(`tool returned no structured content: ${JSON.stringify(result.content)}`); |
| 313 | } |
| 314 | const structuredRecord = structured as Record<string, unknown>; |
| 315 | |
| 316 | if (structuredRecord.status !== "waiting_for_interaction") { |
| 317 | return structuredRecord; |
| 318 | } |
| 319 | |
| 320 | const executionId = structuredRecord.executionId; |
| 321 | if (typeof executionId !== "string" || executionId.length === 0) { |
| 322 | fail(`paused result missing executionId: ${JSON.stringify(structuredRecord)}`); |
| 323 | } |
| 324 | |
| 325 | console.log(`[smoke-sidecar] auto-accepting paused execution ${executionId}`); |
| 326 | result = await client.callTool({ |
| 327 | name: "resume", |
| 328 | arguments: { executionId, action: "accept", content: "{}" }, |
| 329 | }); |
| 330 | } |
| 331 | |
| 332 | return fail("execute still paused after 5 resume attempts"); |
| 333 | }; |
| 334 | |
| 335 | const stageSidecarWithUnavailableOp = async ( |
| 336 | sidecarRoot: string, |