MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / makeTheater

Function makeTheater

e2e/src/clients/chat-theater.ts:75–93  ·  view source on GitHub ↗
(push: (event: TheaterEvent) => Effect.Effect<void>)

Source from the content-addressed store, hash-verified

73};
74
75const makeTheater = (push: (event: TheaterEvent) => Effect.Effect<void>): ChatTheater => ({
76 user: (text) => push({ type: "user", text }),
77 assistant: (text) => push({ type: "assistant", text }),
78 status: (text) => push({ type: "status", text }),
79 tool: (call, work) =>
80 Effect.gen(function* () {
81 yield* push({ type: "tool-start", name: call.name, input: inputPreview(call.input) });
82 const startedAt = Date.now();
83 const exit = yield* Effect.exit(work);
84 const seconds = (Date.now() - startedAt) / 1000;
85 if (Exit.isSuccess(exit)) {
86 const line = call.result ? call.result(exit.value) : JSON.stringify(exit.value);
87 yield* push({ type: "tool-end", ok: true, result: line, seconds });
88 return exit.value;
89 }
90 yield* push({ type: "tool-end", ok: false, result: "failed", seconds });
91 return yield* exit;
92 }),
93});
94
95export interface TheaterOptions {
96 readonly title: string;

Callers 2

ptyTheaterFunction · 0.85
deskTheaterFunction · 0.85

Calls 2

pushFunction · 0.85
inputPreviewFunction · 0.85

Tested by

no test coverage detected