refactor: centralize paired room role normalization (#193)
This commit is contained in:
@@ -3,6 +3,13 @@ export {
|
||||
type RoomRoleContext,
|
||||
} from './room-role-context.js';
|
||||
export { EJCLAW_ENV, type EjclawEnvName } from './ejclaw-env.js';
|
||||
export {
|
||||
isPairedRoomRole,
|
||||
normalizePairedRoomRole,
|
||||
normalizePairedRoomRoleOrNull,
|
||||
PAIRED_ROOM_ROLES,
|
||||
type PairedRoomRole,
|
||||
} from './paired-room-role.js';
|
||||
export {
|
||||
extractMarkdownImageAttachments,
|
||||
extractMediaAttachments,
|
||||
|
||||
19
runners/shared/src/paired-room-role.ts
Normal file
19
runners/shared/src/paired-room-role.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
export const PAIRED_ROOM_ROLES = ['owner', 'reviewer', 'arbiter'] as const;
|
||||
|
||||
export type PairedRoomRole = (typeof PAIRED_ROOM_ROLES)[number];
|
||||
|
||||
export function isPairedRoomRole(value: unknown): value is PairedRoomRole {
|
||||
return value === 'owner' || value === 'reviewer' || value === 'arbiter';
|
||||
}
|
||||
|
||||
export function normalizePairedRoomRole(
|
||||
value: unknown,
|
||||
): PairedRoomRole | undefined {
|
||||
return isPairedRoomRole(value) ? value : undefined;
|
||||
}
|
||||
|
||||
export function normalizePairedRoomRoleOrNull(
|
||||
value: unknown,
|
||||
): PairedRoomRole | null {
|
||||
return normalizePairedRoomRole(value) ?? null;
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
import type { PairedRoomRole } from './paired-room-role.js';
|
||||
import type { RunnerAgentType } from './reviewer-runtime-policy.js';
|
||||
|
||||
export interface RoomRoleContext {
|
||||
serviceId: string;
|
||||
role: 'owner' | 'reviewer' | 'arbiter';
|
||||
role: PairedRoomRole;
|
||||
ownerServiceId: string;
|
||||
reviewerServiceId: string;
|
||||
ownerAgentType?: RunnerAgentType;
|
||||
|
||||
Reference in New Issue
Block a user