import type { Attribution, Role } from "./actor.ts"; import type { Id, Timestamp } from "./common.ts"; import type { Label, PersonRef, TaskStatus, Visibility } from "./views.ts"; /** * The thing an event belongs to. Streams use internal ids, which never change, so a * repository rename or task transfer keeps its history. A task's timeline is its stream. */ export type Stream = "org" | `repo:${string}` | `task:${number}` | `pull:${number}`; interface Payloads { "task.opened": { readonly title: string }; "task.commented": { readonly body: string; readonly html: string; readonly editedAt: Timestamp | null }; "task.closed": { readonly pull?: number }; "task.reopened": Record; "task.renamed": { readonly from: string; readonly to: string }; "task.assigned": { readonly assignee: PersonRef }; "task.unassigned": { readonly assignee: PersonRef }; "task.transferred": { readonly from: { readonly repo: string; readonly number: number }; readonly to: { readonly repo: string; readonly number: number } }; "task.labeled": { readonly label: Pick }; "task.unlabeled": { readonly label: Pick }; "pull.opened": { readonly title: string }; /** With `thread`, a comment in that review thread. */ "pull.commented": { readonly body: string; readonly html: string; readonly editedAt: Timestamp | null; readonly thread?: number }; "pull.thread_addressed": { readonly thread: number; readonly commit: string }; "pull.thread_resolved": { readonly thread: number }; "pull.thread_reopened": { readonly thread: number }; "pull.closed": Record; "pull.reopened": Record; "pull.merged": { readonly head: string }; "pull.renamed": { readonly from: string; readonly to: string }; "repo.created": { readonly name: string; readonly visibility: Visibility }; "repo.forked": { readonly name: string; readonly from: string }; "repo.imported": { readonly name: string; readonly url: string }; "repo.updated": { readonly description?: string; readonly visibility?: Visibility }; "repo.deleted": { readonly name: string }; "repo.pushed": { readonly updates: readonly { readonly ref: string; readonly from: string | null; readonly to: string | null }[] }; "session.started": { readonly runtime: string }; /** The session took a branch, or let it go with `branch: null`. The name is historical: sessions do not take tasks. */ "session.tasked": { readonly session: string; readonly branch?: string | null }; "agent.permission_requested": { readonly session: string; readonly request_id: string; readonly tool: string; readonly description: string; readonly preview: string }; "agent.permission_decided": { readonly session: string; readonly request_id: string; readonly behavior: "allow" | "deny" | "withdrawn" }; "agent.mentioned": { readonly session: string; readonly title: string; readonly comment: number | null; readonly body: string; readonly assigned: boolean; readonly run: boolean; readonly wake?: boolean; readonly pull: number; readonly thread?: number }; /** One model turn of a hosted agent's run: what it thought, when the model shares it, and the tools it called. */ "agent.step": { readonly session: string; readonly step: number; readonly thinking: string; readonly tools: readonly string[] }; "agent.run_finished": { readonly session: string; readonly run: string; readonly mention: string | null; readonly ok: boolean; readonly summary: string }; "session.problem": { readonly commit: string; readonly message: string }; "session.instructed": { readonly session: string; readonly body: string }; "session.ended": { readonly session: string; readonly outcome: "finished" | "failed"; readonly reason: string }; "member.invited": { readonly email: string; readonly role: Role }; "member.joined": { readonly person: PersonRef; readonly role: Role }; "invitation.revoked": { readonly email: string }; } export type EventKind = keyof Payloads; export type RefsEvent = { [K in EventKind]: { readonly id: Id; readonly stream: Stream; readonly kind: K; readonly data: Payloads[K]; readonly by: Attribution; readonly at: Timestamp; /** * The event this one follows from, when it is not simply the previous event on its stream. * Reserved for the code graph, where work can branch from any earlier point. */ readonly parent: Id | null; }; }[EventKind]; export type EventOf = Extract; /** A comment's status from the viewer's side, so the UI can offer edit and delete. */ export interface CommentPermissions { readonly edit: boolean; readonly delete: boolean; } export type TimelineItem = RefsEvent & { readonly can?: CommentPermissions }; export type { TaskStatus };