The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 06:00 UTC
| 1 | import * as Effect from "effect/Effect"; |
| 2 | import { CurrentActor } from "../CurrentActor.context.ts"; |
| 3 | import type { CustomerId } from "../Customer/Customer.id.ts"; |
| 4 | import { NotOwner } from "./NotOwner.rejection.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Who may read an account's data: any agent, or the customer who owns the |
| 8 | * account right now. An account that doesn't exist yet reads as empty, so a |
| 9 | * client can watch for it to appear; someone else's is rejected. |
| 10 | */ |
| 11 | export const mustOwn = Effect.fn(function* (owner: CustomerId | null) { |
| 12 | const actor = yield* CurrentActor; |
| 13 | if (actor._tag === "Agent" || owner === null) return; |
| 14 | if (actor._tag !== "Customer" || owner !== actor.customerId) return yield* new NotOwner(); |
| 15 | }); |