The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Context from "effect/Context"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Schema from "effect/Schema"; |
| 4 | |
| 5 | import type { HeldHook } from "./HookInboxStore.ts"; |
| 6 | |
| 7 | export class HookInboxError extends Schema.TaggedError<HookInboxError>()("HookInboxError", { |
| 8 | operation: Schema.Literals(["hold", "wake", "clear"]), |
| 9 | endpointKey: Schema.String, |
| 10 | cause: Schema.Defect(), |
| 11 | }) { |
| 12 | override get message(): string { |
| 13 | return `Hook inbox '${this.operation}' failed for endpoint '${this.endpointKey}'`; |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | export class HookInbox extends Context.Service< |
| 18 | HookInbox, |
| 19 | { |
| 20 | /** False when the environment's inbox is full and nothing was stored. */ |
| 21 | readonly hold: (input: { |
| 22 | readonly endpointKey: string; |
| 23 | readonly baseUrl: string; |
| 24 | readonly hook: HeldHook; |
| 25 | }) => Effect.Effect<boolean, HookInboxError>; |
| 26 | readonly wake: (input: { |
| 27 | readonly endpointKey: string; |
| 28 | readonly baseUrl: string; |
| 29 | }) => Effect.Effect<boolean, HookInboxError>; |
| 30 | readonly clear: (input: { |
| 31 | readonly endpointKey: string; |
| 32 | }) => Effect.Effect<void, HookInboxError>; |
| 33 | } |
| 34 | >()("t3code-relay/hooks/HookInbox") {} |