Skip to content
refs
History
44 lines · 1.6 KBRaw
1import type { Id, Timestamp } from "./common.ts";
2
3export type Role = "owner" | "admin" | "member";
4
5export interface Person {
6 readonly id: Id;
7 readonly name: string;
8 readonly email: string;
9}
10
11export interface AgentIdentity {
12 readonly id: Id;
13 readonly name: string;
14 /** Where the agent runs: a terminal client such as "claude-code" or "codex", or "refs:<name>" for agents built into the platform. */
15 readonly runtime: string;
16}
17
18export type Actor =
19 | { readonly kind: "anonymous" }
20 | { readonly kind: "human"; readonly person: Person; readonly via: "session" | "token" | "cli" }
21 | {
22 readonly kind: "agent";
23 readonly agent: AgentIdentity;
24 /** Agents always act for a human; the agent's access is that person's access narrowed by `grant`. */
25 readonly onBehalfOf: Person;
26 readonly sessionId: Id;
27 readonly grant: Grant;
28 };
29
30export type RepoAccess = "read" | "write";
31
32/** Access that can only ever be narrowed. Every field is intersected with the holder's own access. */
33export interface Grant {
34 readonly repos: "all" | readonly { readonly name: string; readonly access: RepoAccess; readonly branches?: readonly string[] }[];
35 readonly org: "none" | "member" | "admin";
36 readonly expiresAt?: Timestamp;
37}
38
39/** Who did something. Stored on every change the backend records. */
40export interface Attribution {
41 readonly actor: { readonly kind: "human"; readonly id: Id; readonly name: string } | { readonly kind: "agent"; readonly id: Id; readonly name: string; readonly runtime: string };
42 readonly onBehalfOf?: { readonly id: Id; readonly name: string };
43 readonly sessionId?: Id;
44}