import type { Id, Timestamp } from "./common.ts"; export type Role = "owner" | "admin" | "member"; export interface Person { readonly id: Id; readonly name: string; readonly email: string; } export interface AgentIdentity { readonly id: Id; readonly name: string; /** Where the agent runs: a terminal client such as "claude-code" or "codex", or "refs:" for agents built into the platform. */ readonly runtime: string; } export type Actor = | { readonly kind: "anonymous" } | { readonly kind: "human"; readonly person: Person; readonly via: "session" | "token" | "cli" } | { readonly kind: "agent"; readonly agent: AgentIdentity; /** Agents always act for a human; the agent's access is that person's access narrowed by `grant`. */ readonly onBehalfOf: Person; readonly sessionId: Id; readonly grant: Grant; }; export type RepoAccess = "read" | "write"; /** Access that can only ever be narrowed. Every field is intersected with the holder's own access. */ export interface Grant { readonly repos: "all" | readonly { readonly name: string; readonly access: RepoAccess; readonly branches?: readonly string[] }[]; readonly org: "none" | "member" | "admin"; readonly expiresAt?: Timestamp; } /** Who did something. Stored on every change the backend records. */ export interface Attribution { readonly actor: { readonly kind: "human"; readonly id: Id; readonly name: string } | { readonly kind: "agent"; readonly id: Id; readonly name: string; readonly runtime: string }; readonly onBehalfOf?: { readonly id: Id; readonly name: string }; readonly sessionId?: Id; }