The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Effect from "effect/Effect"; |
| 2 | |
| 3 | /** |
| 4 | * Generate an instance ID: a 16-byte (128-bit) random hex-encoded string that |
| 5 | * identifies one physical instance of a logical resource. The running |
| 6 | * resource's instance ID is available as `ResourceContext.instanceId`. |
| 7 | * @returns Hex-encoded instance ID (16 random bytes) |
| 8 | */ |
| 9 | export const generateInstanceId = () => |
| 10 | Effect.sync(() => { |
| 11 | const bytes = new Uint8Array(16); |
| 12 | crypto.getRandomValues(bytes); |
| 13 | return Array.from(bytes) |
| 14 | .map((b) => b.toString(16).padStart(2, "0")) |
| 15 | .join(""); |
| 16 | }); |