MCPcopy Create free account
hub / github.com/HKUDS/AgentSpace / generateUniqueWorkspaceJoinCodeSync

Function generateUniqueWorkspaceJoinCodeSync

packages/db/src/workspaces.ts:256–265  ·  view source on GitHub ↗
(excludeWorkspaceId?: string)

Source from the content-addressed store, hash-verified

254}
255
256function generateUniqueWorkspaceJoinCodeSync(excludeWorkspaceId?: string): string {
257 for (let attempt = 0; attempt < JOIN_CODE_MAX_ATTEMPTS; attempt += 1) {
258 const joinCode = generateWorkspaceJoinCode();
259 const existing = readWorkspaceByJoinCodeSync(joinCode);
260 if (!existing || existing.id === excludeWorkspaceId) {
261 return joinCode;
262 }
263 }
264 throw new Error("workspace.join_code.collision");
265}
266
267function generateWorkspaceJoinCode(): string {
268 const bytes = randomBytes(JOIN_CODE_LENGTH);

Callers 3

createWorkspaceSyncFunction · 0.85

Calls 2

Tested by

no test coverage detected