Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Initial g1t: services, event bus, intents and attempts | 1 | import type { |
| 2 | Attempt, | |
| 3 | AttemptRuntime, | |
| 4 | AttemptStatus, | |
| 5 | Intent, | |
| 6 | IntentStatus, | |
| 7 | SessionEntry, | |
| 8 | SessionEntryKind, | |
| 9 | } from "@g1t/contracts"; | |
| 10 | ||
| 11 | export type IntentRow = { | |
| 12 | id: string; | |
| 13 | repo_id: string; | |
| 14 | number: number; | |
| 15 | title: string; | |
| 16 | brief: string; | |
| 17 | checks: string; | |
| 18 | status: IntentStatus; | |
| 19 | author_id: string; | |
| 20 | author_name: string; | |
| 21 | created_at: number; | |
| 22 | attempt_count: number; | |
| 23 | }; | |
| 24 | ||
| 25 | export type AttemptRow = { | |
| 26 | id: string; | |
| 27 | intent_id: string; | |
| 28 | repo_id: string; | |
| 29 | number: number; | |
| 30 | agent: string; | |
| 31 | runtime: AttemptRuntime; | |
| 32 | status: AttemptStatus; | |
| 33 | summary: string | null; | |
| 34 | fork_repo_id: string; | |
| 35 | fork_namespace: string; | |
| 36 | fork_name: string; | |
| 37 | head_commit: string | null; | |
| Diffs on attempts; hosted agent presented as the g1t agent | 38 | landed_base: string | null; |
| Initial g1t: services, event bus, intents and attempts | 39 | started_by_id: string; |
| 40 | started_by_name: string; | |
| 41 | created_at: number; | |
| 42 | updated_at: number; | |
| 43 | }; | |
| 44 | ||
| 45 | export type SessionRow = { | |
| 46 | attempt_id: string; | |
| 47 | seq: number; | |
| 48 | kind: SessionEntryKind; | |
| 49 | text: string; | |
| 50 | tool: string | null; | |
| 51 | commit: string | null; | |
| 52 | at: number; | |
| 53 | }; | |
| 54 | ||
| 55 | export function toIntent(row: IntentRow): Intent { | |
| 56 | return { | |
| 57 | id: row.id, | |
| 58 | repoId: row.repo_id, | |
| 59 | number: row.number, | |
| 60 | title: row.title, | |
| 61 | brief: row.brief, | |
| 62 | checks: JSON.parse(row.checks), | |
| 63 | status: row.status, | |
| 64 | author: { id: row.author_id, username: row.author_name }, | |
| 65 | createdAt: row.created_at, | |
| 66 | attemptCount: row.attempt_count, | |
| 67 | }; | |
| 68 | } | |
| 69 | ||
| 70 | export function toAttempt(row: AttemptRow): Attempt { | |
| 71 | return { | |
| 72 | id: row.id, | |
| 73 | intentId: row.intent_id, | |
| 74 | repoId: row.repo_id, | |
| 75 | number: row.number, | |
| 76 | agent: row.agent, | |
| 77 | runtime: row.runtime, | |
| 78 | status: row.status, | |
| 79 | summary: row.summary, | |
| 80 | fork: { namespace: row.fork_namespace, name: row.fork_name }, | |
| Diffs on attempts; hosted agent presented as the g1t agent | 81 | forkRepoId: row.fork_repo_id, |
| Initial g1t: services, event bus, intents and attempts | 82 | headCommit: row.head_commit, |
| Diffs on attempts; hosted agent presented as the g1t agent | 83 | landedBase: row.landed_base, |
| Initial g1t: services, event bus, intents and attempts | 84 | startedBy: { id: row.started_by_id, username: row.started_by_name }, |
| 85 | createdAt: row.created_at, | |
| 86 | updatedAt: row.updated_at, | |
| 87 | }; | |
| 88 | } | |
| 89 | ||
| 90 | export function toSessionEntry(row: SessionRow): SessionEntry { | |
| 91 | return { | |
| 92 | seq: row.seq, | |
| 93 | kind: row.kind, | |
| 94 | text: row.text, | |
| 95 | tool: row.tool, | |
| 96 | commit: row.commit, | |
| 97 | at: row.at, | |
| 98 | }; | |
| 99 | } |