The best way to control Claude Code, Codex and more from any computer or phone

main
ts 29 lines 1.1 KB
Raw
1 import { createPeerPairingCodeCommand } from "@t3tools/client-runtime/state/peerPairingCode";
2 import { runAtomCommand, squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
3 import type { AuthMcpClientAccess, EnvironmentId } from "@t3tools/contracts";
4 import * as Result from "effect/Result";
5
6 import { connectionAtomRuntime } from "../connection/runtime";
7 import { appAtomRegistry } from "./atom-registry";
8
9 const mintPairingCode = createPeerPairingCodeCommand(connectionAtomRuntime);
10
11 /**
12 * A fresh pairing code minted on `environmentId` with this client's session
13 * there, for linking with `access`. Fails with `PeerPairingCodeError` when the
14 * session may not create one.
15 */
16 export async function mintPairingCodeOn(
17 environmentId: EnvironmentId,
18 access: AuthMcpClientAccess,
19 ): Promise<Result.Result<string, unknown>> {
20 const result = await runAtomCommand(
21 appAtomRegistry,
22 mintPairingCode,
23 { environmentId, input: access },
24 { reportFailure: false },
25 );
26 return result._tag === "Success"
27 ? Result.succeed(result.value)
28 : Result.fail(squashAtomCommandFailure(result));
29 }