MCPcopy Create free account
hub / github.com/anomalyco/opencode / send

Function send

packages/opencode/test/lib/llm-server.ts:418–431  ·  view source on GitHub ↗
(item: Sse)

Source from the content-addressed store, hash-verified

416}
417
418function send(item: Sse) {
419 const head = bytes(item.head)
420 const tail = bytes([...item.tail, ...(item.hang || item.error ? [] : [done])])
421 const empty = Stream.fromIterable<Uint8Array>([])
422 const wait = item.wait
423 const body: Stream.Stream<Uint8Array, unknown> = wait
424 ? Stream.concat(head, Stream.fromEffect(Effect.promise(() => wait)).pipe(Stream.flatMap(() => tail)))
425 : Stream.concat(head, tail)
426 let end: Stream.Stream<Uint8Array, unknown> = empty
427 if (item.error) end = Stream.concat(empty, Stream.fail(item.error))
428 else if (item.hang) end = Stream.concat(empty, Stream.never)
429
430 return HttpServerResponse.stream(Stream.concat(body, end), { contentType: "text/event-stream" })
431}
432
433const reset = Effect.fn("TestLLMServer.reset")(function* (item: Sse) {
434 const req = yield* HttpServerRequest.HttpServerRequest

Callers 1

TestLLMServerClass · 0.70

Calls 2

bytesFunction · 0.85
streamMethod · 0.80

Tested by

no test coverage detected