diff --git a/apps/server/src/cli/thread.ts b/apps/server/src/cli/thread.ts index 7e2959c767..a89396b29e 100644 --- a/apps/server/src/cli/thread.ts +++ b/apps/server/src/cli/thread.ts @@ -885,6 +885,30 @@ const threadSendCommand = Command.make("send", { ), ); +const threadRaceCommand = Command.make("race", { + ...projectLocationFlags, + thread: threadArgument, + message: messageArgument, + delay: Flag.Int("delay"), +}).pipe( + Command.withHandler((flags) => + withThreadTools( + flags, + Effect.fn("cli.thread.race")(function* (tools) { + const threadId = yield* decodeThreadId(flags.thread); + const sent = yield* tools.call( + "t3_thread_send", + { threadId, message: flags.message, mode: "queue" }, + Schema.Unknown, + ); + yield* Effect.sleep(`${flags.delay} millis`); + const stopped = yield* tools.call("t3_thread_interrupt", { threadId }, Schema.Unknown); + yield* Console.log(JSON.stringify({ sent, stopped })); + }), + ), + ), +); + const threadShowCommand = Command.make("show", { ...projectLocationFlags, thread: threadArgument, @@ -946,5 +970,6 @@ export const threadCommand = Command.make("thread").pipe( threadStartCommand, threadSendCommand, threadShowCommand, + threadRaceCommand, ]), );