MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / main

Function main

apps/cli/scripts/integration/cases/shutdown-while-running.ts:6–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4 'Run exactly this command and do not summarize until it finishes: sleep 20 && echo "done". After it finishes, reply with exactly "done".'
5
6async function main() {
7 const startRequestId = `start-${Date.now()}`
8 const shutdownRequestId = `shutdown-${Date.now()}`
9
10 let initSeen = false
11 let startAccepted = false
12 let shutdownSent = false
13 let shutdownAck = false
14 let shutdownDone = false
15
16 await runStreamCase({
17 onEvent(event: StreamEvent, context) {
18 if (event.type === "system" && event.subtype === "init" && !initSeen) {
19 initSeen = true
20 context.sendCommand({
21 command: "start",
22 requestId: startRequestId,
23 prompt: LONG_PROMPT,
24 })
25 return
26 }
27
28 if (
29 event.type === "control" &&
30 event.subtype === "ack" &&
31 event.command === "start" &&
32 event.requestId === startRequestId &&
33 !startAccepted
34 ) {
35 startAccepted = true
36 context.sendCommand({
37 command: "shutdown",
38 requestId: shutdownRequestId,
39 })
40 shutdownSent = true
41 return
42 }
43
44 if (
45 event.type === "control" &&
46 event.subtype === "ack" &&
47 event.command === "shutdown" &&
48 event.requestId === shutdownRequestId
49 ) {
50 shutdownAck = true
51 return
52 }
53
54 if (
55 event.type === "control" &&
56 event.subtype === "done" &&
57 event.command === "shutdown" &&
58 event.requestId === shutdownRequestId
59 ) {
60 shutdownDone = true
61 }
62 },
63 onTimeoutMessage() {

Callers 1

Calls 1

runStreamCaseFunction · 0.90

Tested by

no test coverage detected