UNPKG

@phren/cli

Version:

Knowledge layer for AI agents - CLI, MCP server, and data layer

45 lines (44 loc) • 2.72 kB
import { type AccountChoice, type AccountRoom } from "./account-choice.js"; import { type AccountRole } from "./account-pools.js"; /** An account room with what the harness listing says about its pool, role and login. */ export interface PolicyRoom extends AccountRoom { pool?: string; role?: AccountRole; console?: boolean; } /** Whose `allowedPools` a choice must keep to: "project client-a", "computer Desk". No `pools`: any pool. */ export interface PoolRule { owner: string; pools?: readonly string[]; } /** A project's rule, from its `phren.project.yaml` in the store (or the team store holding it). */ export declare function projectRule(phrenPath: string, project: string): PoolRule; /** A computer's rule from what its harness listing reports (its Claude entry's `allowedPools`, or that its * accounts.yaml can't be read). */ export declare function computerRule(computer: string, pools: unknown, unreadable?: boolean): PoolRule; /** The pool, role and Console flag a listed account carries, checked, onto its room. */ export declare function withPolicy<T extends AccountRoom>(room: T, listed: { pool?: unknown; role?: unknown; console?: unknown; } | undefined): T & PolicyRoom; /** Why `room` may not do this work under `rules` at all, or undefined. Applies to a named account too. */ export declare function poolRefusal(room: Pick<PolicyRoom, "account" | "pool">, rules: readonly PoolRule[]): string | undefined; /** Why `room` is never chosen automatically, or undefined. */ export declare function notAutomatic(room: Pick<PolicyRoom, "role" | "console">): string | undefined; /** Whether any pool, role or Console login could change a choice among `rooms` under `rules`. */ export declare function policyApplies(rooms: readonly PolicyRoom[], rules: readonly PoolRule[]): boolean; /** The rooms a rule and the roles allow an automatic choice to take. */ export declare function allowedRooms<T extends PolicyRoom>(rooms: readonly T[], rules: readonly PoolRule[]): T[]; /** Whether an allowed room has room to take work: signed in, not out of quota, not `held` (the limits ledger, a * worker that just stopped there). */ export declare const openRoom: (room: PolicyRoom, held?: (room: PolicyRoom) => boolean) => boolean; /** * `chooseAccount` with pools and roles: rooms a rule refuses or that are not automatic are skipped, with why; * the rest are ranked by headroom as before, `last-resort` ones only when no other account has room. */ export declare function choosePolicyAccount(rooms: readonly PolicyRoom[], rules?: readonly PoolRule[], blocked?: (room: AccountRoom) => string | undefined): { choice?: AccountChoice; skipped: string[]; lastResort?: true; };